From c338c1b84440cc031e04cc902c3db1eb7ff1afb5 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 25 Feb 2017 13:23:54 +0900 Subject: [PATCH] [Client] Fix bug --- src/web/app/desktop/tags/drive/browser.tag | 20 ++++++++++++++----- src/web/app/desktop/tags/drive/file.tag | 1 + .../tags/select-file-from-drive-window.tag | 4 ++-- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/web/app/desktop/tags/drive/browser.tag b/src/web/app/desktop/tags/drive/browser.tag index 7eaa7ed6e3..9f3c14f821 100644 --- a/src/web/app/desktop/tags/drive/browser.tag +++ b/src/web/app/desktop/tags/drive/browser.tag @@ -516,13 +516,23 @@ }; this.chooseFile = file => { - if (this.selectedFiles.some(f => f.id == file.id)) { - this.selectedFiles = this.selectedFiles.filter(f => f.id != file.id); + const isAlreadySelected = this.selectedFiles.some(f => f.id == file.id); + if (this.multiple) { + if (isAlreadySelected) { + this.selectedFiles = this.selectedFiles.filter(f => f.id != file.id); + } else { + this.selectedFiles.push(file); + } + this.update(); + this.trigger('change-selection', this.selectedFiles); } else { - this.selectedFiles.push(file); + if (isAlreadySelected) { + this.trigger('selected', file); + } else { + this.selectedFiles = [file]; + this.trigger('change-selection', [file]); + } } - this.update(); - this.trigger('change-selection', this.selectedFiles); }; this.newWindow = folderId => { diff --git a/src/web/app/desktop/tags/drive/file.tag b/src/web/app/desktop/tags/drive/file.tag index 47416db0bd..519d04f6dc 100644 --- a/src/web/app/desktop/tags/drive/file.tag +++ b/src/web/app/desktop/tags/drive/file.tag @@ -156,6 +156,7 @@ this.browser.on('change-selection', selections => { this.isSelected = selections.some(f => f.id == this.file.id); + this.update(); }); this.onclick = () => { diff --git a/src/web/app/desktop/tags/select-file-from-drive-window.tag b/src/web/app/desktop/tags/select-file-from-drive-window.tag index ed1c1bce6c..5dba76d1fe 100644 --- a/src/web/app/desktop/tags/select-file-from-drive-window.tag +++ b/src/web/app/desktop/tags/select-file-from-drive-window.tag @@ -142,7 +142,7 @@ this.on('mount', () => { this.refs.window.refs.browser.on('selected', file => { - this.files = file; + this.files = [file]; this.ok(); }); @@ -166,7 +166,7 @@ }; this.ok = () => { - this.trigger('selected', this.files); + this.trigger('selected', this.multiple ? this.files : this.files[0]); this.refs.window.close(); };