aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_trashbin
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_trashbin')
-rw-r--r--apps/files_trashbin/src/actions/restoreAction.ts14
1 files changed, 10 insertions, 4 deletions
diff --git a/apps/files_trashbin/src/actions/restoreAction.ts b/apps/files_trashbin/src/actions/restoreAction.ts
index d65ff3f0799..201fffe6a53 100644
--- a/apps/files_trashbin/src/actions/restoreAction.ts
+++ b/apps/files_trashbin/src/actions/restoreAction.ts
@@ -19,12 +19,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
-import { registerFileAction, Permission, FileAction } from '@nextcloud/files'
+import { registerFileAction, Permission, FileAction, Node } from '@nextcloud/files'
import { translate as t } from '@nextcloud/l10n'
import axios from '@nextcloud/axios'
import History from '@mdi/svg/svg/history.svg?raw'
import { generateRemoteUrl } from '@nextcloud/router'
import { getCurrentUser } from '@nextcloud/auth'
+import { emit } from '@nextcloud/event-bus'
registerFileAction(new FileAction({
id: 'restore',
@@ -32,7 +33,7 @@ registerFileAction(new FileAction({
return t('files_trashbin', 'Restore')
},
iconSvgInline: () => History,
- enabled(nodes, view) {
+ enabled(nodes: Node[], view) {
// Only available in the trashbin view
if (view.id !== 'trashbin') {
return false
@@ -43,15 +44,20 @@ registerFileAction(new FileAction({
.map(node => node.permissions)
.every(permission => (permission & Permission.READ) !== 0)
},
- async exec(node) {
+ async exec(node: Node) {
// No try...catch here, let the files app handle the error
+ const destination = generateRemoteUrl(`dav/trashbin/${getCurrentUser()?.uid}/restore/${node.basename}`)
await axios({
method: 'MOVE',
url: node.source,
headers: {
- destination: generateRemoteUrl(`dav/trashbin/${getCurrentUser()?.uid}/restore/${node.basename}`),
+ destination,
},
})
+
+ // Let's pretend the file is deleted since
+ // we don't know the restored location
+ emit('files:file:deleted', node)
return true
},
order: 1,