From 9caefdc6879827c5c48ddc7a5bc4689e7beadf52 Mon Sep 17 00:00:00 2001 From: Halla Moore Date: Wed, 22 Mar 2017 12:10:20 -0700 Subject: [PATCH] [client-app] Rename downloadDataForFile(s) -> getDownloadDataForFile(s) Summary: The original name seems like it's initiating the download, when really it's just returning the data of an already in-progress/completed download. Test Plan: Manual, specs Reviewers: evan, juan Reviewed By: juan Differential Revision: https://phab.nylas.com/D4251 --- .../internal_packages/message-list/lib/message-item.cjsx | 4 ++-- .../message-list/spec/message-item-spec.cjsx | 2 +- packages/client-app/spec/stores/draft-factory-spec.es6 | 2 +- .../client-app/spec/stores/file-download-store-spec.coffee | 5 +++-- packages/client-app/src/flux/stores/draft-factory.coffee | 2 +- packages/client-app/src/flux/stores/file-download-store.es6 | 6 +++--- 6 files changed, 11 insertions(+), 10 deletions(-) diff --git a/packages/client-app/internal_packages/message-list/lib/message-item.cjsx b/packages/client-app/internal_packages/message-list/lib/message-item.cjsx index 0abc956ca..9fab5758d 100644 --- a/packages/client-app/internal_packages/message-list/lib/message-item.cjsx +++ b/packages/client-app/internal_packages/message-list/lib/message-item.cjsx @@ -35,7 +35,7 @@ class MessageItem extends React.Component @state = # Holds the downloadData (if any) for all of our files. It's a hash # keyed by a fileId. The value is the downloadData. - downloads: FileDownloadStore.downloadDataForFiles(fileIds) + downloads: FileDownloadStore.getDownloadDataForFiles(fileIds) filePreviewPaths: FileDownloadStore.previewPathsForFiles(fileIds) detailedHeaders: false detailedHeadersTogglePos: {top: 18} @@ -273,7 +273,7 @@ class MessageItem extends React.Component _onDownloadStoreChange: => fileIds = @props.message.fileIds() @setState - downloads: FileDownloadStore.downloadDataForFiles(fileIds) + downloads: FileDownloadStore.getDownloadDataForFiles(fileIds) filePreviewPaths: FileDownloadStore.previewPathsForFiles(fileIds) module.exports = MessageItem diff --git a/packages/client-app/internal_packages/message-list/spec/message-item-spec.cjsx b/packages/client-app/internal_packages/message-list/spec/message-item-spec.cjsx index 583c58c3d..0cfca138e 100644 --- a/packages/client-app/internal_packages/message-list/spec/message-item-spec.cjsx +++ b/packages/client-app/internal_packages/message-list/spec/message-item-spec.cjsx @@ -96,7 +96,7 @@ xdescribe "MessageItem", -> return '/fake/path-inline.png' if f.id is file_inline.id return '/fake/path-downloading.png' if f.id is file_inline_downloading.id return null - spyOn(FileDownloadStore, 'downloadDataForFiles').andCallFake (ids) -> + spyOn(FileDownloadStore, 'getDownloadDataForFiles').andCallFake (ids) -> return {'file_1_id': download, 'file_inline_downloading_id': download_inline} spyOn(MessageBodyProcessor, '_addToCache').andCallFake -> diff --git a/packages/client-app/spec/stores/draft-factory-spec.es6 b/packages/client-app/spec/stores/draft-factory-spec.es6 index 56d9b1cdf..f73685c16 100644 --- a/packages/client-app/spec/stores/draft-factory-spec.es6 +++ b/packages/client-app/spec/stores/draft-factory-spec.es6 @@ -32,7 +32,7 @@ describe('DraftFactory', function draftFactory() { // Out of the scope of these specs spyOn(InlineStyleTransformer, 'run').andCallFake((input) => Promise.resolve(input)); spyOn(SanitizeTransformer, 'run').andCallFake((input) => Promise.resolve(input)); - spyOn(FileDownloadStore, 'downloadDataForFile').andCallFake((fid) => { + spyOn(FileDownloadStore, 'getDownloadDataForFile').andCallFake((fid) => { return downloadData[fid] }); diff --git a/packages/client-app/spec/stores/file-download-store-spec.coffee b/packages/client-app/spec/stores/file-download-store-spec.coffee index dd2ed0f7b..a89ed7837 100644 --- a/packages/client-app/spec/stores/file-download-store-spec.coffee +++ b/packages/client-app/spec/stores/file-download-store-spec.coffee @@ -38,7 +38,8 @@ xdescribe 'FileDownloadStoreSpecs', -> @download.run() expect(NylasAPIRequest.prototype.run).toHaveBeenCalled() - it "should create a request with a null encoding to prevent the request library from attempting to parse the (potentially very large) response", -> + it "should create a request with a null encoding to prevent the request library" + + " from attempting to parse the (potentially very large) response", -> expect(NylasAPIRequest.prototype.run.mostRecentCall.object.options.json).toBe(false) expect(NylasAPIRequest.prototype.run.mostRecentCall.object.options.encoding).toBe(null) @@ -167,7 +168,7 @@ xdescribe 'FileDownloadStoreSpecs', -> it "should register the download with the right attributes", -> FileDownloadStore._runDownload(@testfile) advanceClock(0) - expect(FileDownloadStore.downloadDataForFile(@testfile.id)).toEqual({ + expect(FileDownloadStore.getDownloadDataForFile(@testfile.id)).toEqual({ state : 'unstarted',fileId : 'id', percent : 0, filename : '123.png', diff --git a/packages/client-app/src/flux/stores/draft-factory.coffee b/packages/client-app/src/flux/stores/draft-factory.coffee index 0efba8271..698795224 100644 --- a/packages/client-app/src/flux/stores/draft-factory.coffee +++ b/packages/client-app/src/flux/stores/draft-factory.coffee @@ -152,7 +152,7 @@ class DraftFactory """ ).then (draft) => draft.uploads = message.files.map((f) => - {fileId, filename, filesize, targetPath} = FileDownloadStore.downloadDataForFile(f.id) + {fileId, filename, filesize, targetPath} = FileDownloadStore.getDownloadDataForFile(f.id) # Return an object that can act as an Upload instance. return ( messageClientId: draft.clientId, diff --git a/packages/client-app/src/flux/stores/file-download-store.es6 b/packages/client-app/src/flux/stores/file-download-store.es6 index 386664a54..900fc60d0 100644 --- a/packages/client-app/src/flux/stores/file-download-store.es6 +++ b/packages/client-app/src/flux/stores/file-download-store.es6 @@ -207,7 +207,7 @@ class FileDownloadStore extends NylasStore { return path.join(this._downloadDirectory, file.id, file.safeDisplayName()); } - downloadDataForFile(fileId) { + getDownloadDataForFile(fileId) { const download = this._downloads[fileId] if (!download) { return null; } return download.data() @@ -215,10 +215,10 @@ class FileDownloadStore extends NylasStore { // Returns a hash of download objects keyed by fileId // - downloadDataForFiles(fileIds = []) { + getDownloadDataForFiles(fileIds = []) { const downloadData = {}; fileIds.forEach((fileId) => { - downloadData[fileId] = this.downloadDataForFile(fileId); + downloadData[fileId] = this.getDownloadDataForFile(fileId); }); return downloadData; }