From 50ee7105bbdf4775050eeb44cf9fe8c5f31f7f6a Mon Sep 17 00:00:00 2001 From: LianaHus Date: Wed, 25 Mar 2020 17:52:24 +0100 Subject: [PATCH] transform toaster to inform message --- src/app/files/fileManager.js | 62 +++++++----------------------------- 1 file changed, 11 insertions(+), 51 deletions(-) diff --git a/src/app/files/fileManager.js b/src/app/files/fileManager.js index fc04454455..0071e5da9f 100644 --- a/src/app/files/fileManager.js +++ b/src/app/files/fileManager.js @@ -149,63 +149,23 @@ class FileManager extends Plugin { } async setFile (path, content) { - let reject = false - let saveAsCopy = false - - function acceptFileRewriting (e, toaster) { - reject = false - e.target.innerHTML = 'Accepted' - toaster.hide() - toaster.forceResolve() - } - function cancelFileRewriting (e, toaster) { - reject = true - e.target.innerHTML = 'Canceled' - toaster.hide() - } - const saveFileAsCopy = (e, toaster) => { - if (saveAsCopy) return - this._saveAsCopy(path, content) - - saveAsCopy = true - e.target.innerHTML = 'Saved' - toaster.hide() - } if (this.currentRequest) { const canCall = await this.askUserPermission('setFile', '') if (canCall) { this._setFileInternal(path, content) - return - } - - let actions = (toaster) => { - return yo` -
- - - + // inform the user about modification after permission is granted and even if permission was saved before + await toaster(yo` +
+ + + ${this.currentRequest.from} + + is modifying + ${path} +
- ` + `, '', { time: 5000 }) } - await toaster(yo` -
- - - ${this.currentRequest.from} - - is trying to create or modify - ${path} - -
- `, actions, { time: 5000 }) - if (reject) throw new Error(`set file operation on ${path} aborted by user.`) - if (saveAsCopy) return } this._setFileInternal(path, content) }