diff options
Diffstat (limited to 'webapp/stores')
-rw-r--r-- | webapp/stores/file_store.jsx | 43 | ||||
-rw-r--r-- | webapp/stores/notification_store.jsx | 2 | ||||
-rw-r--r-- | webapp/stores/post_store.jsx | 6 |
3 files changed, 34 insertions, 17 deletions
diff --git a/webapp/stores/file_store.jsx b/webapp/stores/file_store.jsx index 2692e6959..18a35e1fd 100644 --- a/webapp/stores/file_store.jsx +++ b/webapp/stores/file_store.jsx @@ -16,41 +16,58 @@ class FileStore extends EventEmitter { this.handleEventPayload = this.handleEventPayload.bind(this); this.dispatchToken = AppDispatcher.register(this.handleEventPayload); - this.fileInfo = new Map(); + this.setMaxListeners(600); + + this.fileInfosByPost = new Map(); } addChangeListener(callback) { this.on(CHANGE_EVENT, callback); } + removeChangeListener(callback) { this.removeListener(CHANGE_EVENT, callback); } - emitChange(filename) { - this.emit(CHANGE_EVENT, filename); + + emitChange() { + this.emit(CHANGE_EVENT); + } + + hasInfosForPost(postId) { + return this.fileInfosByPost.has(postId); + } + + getInfosForPost(postId) { + return this.fileInfosByPost.get(postId); + } + + saveInfos(postId, infos) { + this.fileInfosByPost.set(postId, infos); } - hasInfo(filename) { - return this.fileInfo.has(filename); + getFileUrl(fileId) { + return `/api/v3/files/${fileId}/get`; } - getInfo(filename) { - return this.fileInfo.get(filename); + getFileThumbnailUrl(fileId) { + return `/api/v3/files/${fileId}/get_thumbnail`; } - setInfo(filename, info) { - this.fileInfo.set(filename, info); + getFilePreviewUrl(fileId) { + return `/api/v3/files/${fileId}/get_preview`; } handleEventPayload(payload) { const action = payload.action; switch (action.type) { - case ActionTypes.RECEIVED_FILE_INFO: - this.setInfo(action.filename, action.info); - this.emitChange(action.filename); + case ActionTypes.RECEIVED_FILE_INFOS: + // This assumes that all received file infos are for a single post + this.saveInfos(action.postId, action.infos); + this.emitChange(action.postId); break; } } } -export default new FileStore(); +export default new FileStore();
\ No newline at end of file diff --git a/webapp/stores/notification_store.jsx b/webapp/stores/notification_store.jsx index c5122dd7a..917b86df8 100644 --- a/webapp/stores/notification_store.jsx +++ b/webapp/stores/notification_store.jsx @@ -84,7 +84,7 @@ class NotificationStoreClass extends EventEmitter { if (msgProps.image) { body = username + Utils.localizeMessage('channel_loader.uploadedImage', ' uploaded an image'); } else if (msgProps.otherFile) { - body = Utils.localizeMessage('channel_loader.uploadedFile', ' uploaded a file'); + body = username + Utils.localizeMessage('channel_loader.uploadedFile', ' uploaded a file'); } else { body = username + Utils.localizeMessage('channel_loader.something', ' did something new'); } diff --git a/webapp/stores/post_store.jsx b/webapp/stores/post_store.jsx index 62283dacd..22f47fd40 100644 --- a/webapp/stores/post_store.jsx +++ b/webapp/stores/post_store.jsx @@ -224,7 +224,7 @@ class PostStoreClass extends EventEmitter { } else if (combinedPosts.posts.hasOwnProperty(pid)) { combinedPosts.posts[pid] = Object.assign({}, np, { state: Constants.POST_DELETED, - filenames: [] + fileIds: [] }); } } @@ -318,7 +318,7 @@ class PostStoreClass extends EventEmitter { // make sure to copy the post so that component state changes work properly postList.posts[post.id] = Object.assign({}, post, { state: Constants.POST_DELETED, - filenames: [] + fileIds: [] }); } } @@ -514,7 +514,7 @@ class PostStoreClass extends EventEmitter { } getEmptyDraft() { - return {message: '', uploadsInProgress: [], previews: []}; + return {message: '', uploadsInProgress: [], fileInfos: []}; } storeCurrentDraft(draft) { |