mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-12 12:40:08 +08:00
a48fc2dd34
Summary: Fixes T1975 Fixes T1900 Fixes T1899 Fixes T1979 Attachments downloading update progress downloads will restart if the file on disk isn't complete can drag images onto drive Test Plan: edgehill --test Reviewers: bengotow Reviewed By: bengotow Maniphest Tasks: T1900, T1899, T1975, T1979 Differential Revision: https://phab.nylas.com/D1638
55 lines
1.2 KiB
CoffeeScript
55 lines
1.2 KiB
CoffeeScript
Reflux = require 'reflux'
|
|
_ = require 'underscore'
|
|
fs = require 'fs'
|
|
|
|
{WorkspaceStore,
|
|
FocusedContentStore,
|
|
FileDownloadStore,
|
|
Actions} = require 'nylas-exports'
|
|
|
|
module.exports =
|
|
FileFrameStore = Reflux.createStore
|
|
init: ->
|
|
@_resetInstanceVars()
|
|
@_afterViewUpdate = []
|
|
|
|
@listenTo FocusedContentStore, @_onFocusedContentChange
|
|
@listenTo FileDownloadStore, @_onFileDownloadChange
|
|
|
|
file: ->
|
|
@_file
|
|
|
|
ready: ->
|
|
@_ready
|
|
|
|
download: ->
|
|
@_download
|
|
|
|
_resetInstanceVars: ->
|
|
@_file = null
|
|
@_download = null
|
|
@_ready = false
|
|
|
|
_update: ->
|
|
|
|
_onFileDownloadChange: ->
|
|
@_download = FileDownloadStore.downloadDataForFile(@_file.id) if @_file
|
|
if @_file and @_ready is false and not @_download
|
|
@_ready = true
|
|
@trigger()
|
|
|
|
_onFocusedContentChange: (change) ->
|
|
return unless change.impactsCollection('file')
|
|
|
|
@_file = FocusedContentStore.focused('file')
|
|
if @_file
|
|
filepath = FileDownloadStore.pathForFile(@_file)
|
|
fs.exists filepath, (exists) =>
|
|
Actions.fetchFile(@_file) if not exists
|
|
@_download = FileDownloadStore.downloadDataForFile(@_file.id)
|
|
@_ready = not @_download
|
|
@trigger()
|
|
else
|
|
@_ready = false
|
|
@_download = null
|
|
@trigger()
|