mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-09-22 08:16:09 +08:00
[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
This commit is contained in:
parent
470e6563ec
commit
9caefdc687
|
@ -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
|
||||
|
|
|
@ -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 ->
|
||||
|
|
|
@ -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]
|
||||
});
|
||||
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -152,7 +152,7 @@ class DraftFactory
|
|||
</div>"""
|
||||
).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,
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue