Skip to content

Commit

Permalink
0.7.0_hotfix_1
Browse files Browse the repository at this point in the history
  • Loading branch information
indeyets committed Mar 4, 2016
2 parents c716047 + caebd59 commit 69ccf44
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/components/dev.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default (props) => (
<h3>Roadmap</h3>

<p>[x] v 0.6 React frontend<br/>
[ &nbsp;] v 0.7 Add real-time updates to the frontend<br/>
[x] v 0.7 Add real-time updates to the frontend<br/>
[ &nbsp;] v 0.8 Add support for private groups<br/>
[ &nbsp;] v 0.9 Migrate to Postgres<br/>
[ &nbsp;] v 1.0 Support for search and #hashtags</p>
Expand Down
12 changes: 10 additions & 2 deletions src/components/post-attachment-image.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,23 @@ import numeral from 'numeral'

export default (props) => {
const formattedFileSize = numeral(props.fileSize).format('0.[0] b')
const nameAndSize = props.fileName + ' (' + formattedFileSize + ')'
const formattedImageSize = (props.imageSizes.o ? `, ${props.imageSizes.o.w}×${props.imageSizes.o.h}px` : '')
const nameAndSize = props.fileName + ' (' + formattedFileSize + formattedImageSize + ')'

const removeAttachment = () => props.removeAttachment(props.id)

const imageAttributes = {
src: props.thumbnailUrl,
alt: nameAndSize,
width: props.imageSizes.t ? props.imageSizes.t.w : undefined,
height: props.imageSizes.t ? props.imageSizes.t.h : undefined
}

return (
<div className="attachment">
<a href={props.url} title={nameAndSize} target="_blank">
{props.thumbnailUrl ? (
<img src={props.thumbnailUrl} alt={nameAndSize} />
<img {...imageAttributes}/>
) : (
props.id
)}
Expand Down
6 changes: 0 additions & 6 deletions src/components/post-comment.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@ export default class PostComment extends React.Component{
}
}

componentWillReceiveProps = (newProps) => {
this.setState({
editText: newProps.editText || ''
})
}

handleChange = (event) => {
this.setState({
editText: event.target.value
Expand Down
1 change: 1 addition & 0 deletions src/components/post-comments.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const renderComment = (entryUrl, openAnsweringComment, isModeratingComments, com
const renderAddingComment = props => (
<PostComment
id={props.post.id}
key={`${props.post.id}-comment-adding`}
isEditing={true}
isSinglePost={props.post.isSinglePost}
editText={props.post.newCommentText}
Expand Down
20 changes: 16 additions & 4 deletions src/redux/reducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,10 @@ export function postsViewState(state = {}, action) {
case ActionTypes.REALTIME_POST_NEW:
case ActionTypes.REALTIME_POST_UPDATE: {
const id = action.post.id
const postAlreadyAdded = !!state[id]
if (postAlreadyAdded){
return state
}
return { ...state, [id]: initPostViewState(action.post) }
}
case fail(ActionTypes.GET_SINGLE_POST): {
Expand Down Expand Up @@ -368,6 +372,9 @@ export function postsViewState(state = {}, action) {
}
case ActionTypes.REALTIME_COMMENT_NEW: {
const post = state[action.comment.postId]
if (!post){
return state
}
return {...state,
[post.id] : {
...post,
Expand Down Expand Up @@ -698,7 +705,10 @@ export function posts(state = {}, action) {
}
case response(ActionTypes.DELETE_COMMENT): {
const commentId = action.request.commentId
const post = _(state).find(post => (post.comments||[]).indexOf(commentId) !== -1)
const post = _(state).find(_post => (_post.comments||[]).indexOf(commentId) !== -1)
if (!post){
return state
}
const comments = _.without(post.comments, commentId)
return {...state,
[post.id]: {...post,
Expand Down Expand Up @@ -1022,12 +1032,14 @@ export function users(state = {}, action) {
case ActionTypes.REALTIME_POST_NEW:
case ActionTypes.REALTIME_LIKE_NEW:
case ActionTypes.REALTIME_COMMENT_NEW: {
const safeUsers = action.users || [{}]
const userAlreadyAdded = state[safeUsers[0].id]
if (!action.users || !action.users.length){
return state
}
const userAlreadyAdded = state[action.users[0].id]
if (userAlreadyAdded) {
return state
}
return mergeByIds(state, safeUsers.map(userParser))
return mergeByIds(state, action.users.map(userParser))
}
case ActionTypes.UNAUTHENTICATED:
return {}
Expand Down

0 comments on commit 69ccf44

Please sign in to comment.