]> source.dussan.org Git - nextcloud-server.git/commitdiff
reload filelist when adding or removing shares
authorRobin Appelman <robin@icewind.nl>
Mon, 15 May 2023 11:03:13 +0000 (13:03 +0200)
committerRobin Appelman <robin@icewind.nl>
Fri, 9 Jun 2023 15:44:46 +0000 (17:44 +0200)
Signed-off-by: Robin Appelman <robin@icewind.nl>
Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
apps/files/js/filelist.js
apps/files_sharing/src/mixins/ShareRequests.js

index 2d93ced71006c20c4c287a2fa425a3031813d994..ae5eac7eb360badf69defe82cfef3a6f3f805540 100644 (file)
                                }
                        });
 
+                       window._nc_event_bus.subscribe('files_sharing:share:created', () => { self.reload(true) });
+                       window._nc_event_bus.subscribe('files_sharing:share:deleted', () => { self.reload(true) });
+
                        this.$fileList.on('click','td.filename>a.name, td.filesize, td.date', _.bind(this._onClickFile, this));
 
                        this.$fileList.on("droppedOnFavorites", function (event, file) {
                 *
                 * @return ajax call object
                 */
-               reload: function() {
+               reload: function(keepOpen) {
                        this._selectedFiles = {};
                        this._selectionSummary.clear();
                        if (this._currentFileModel) {
                                        properties: this._getWebdavProperties()
                                }
                        );
-                       if (this._detailsView) {
+                       if (this._detailsView && !keepOpen) {
                                // close sidebar
                                this._updateDetailsView(null);
                        }
index 9eaad8c4161e4bd83b226dbdf9ef66b9aa9a1d92..634e6caf4313b670be367e01810110aadece5870 100644 (file)
@@ -29,6 +29,7 @@ import 'url-search-params-polyfill'
 import { generateOcsUrl } from '@nextcloud/router'
 import axios from '@nextcloud/axios'
 import Share from '../models/Share'
+import { emit } from '@nextcloud/event-bus'
 
 const shareUrl = generateOcsUrl('apps/files_sharing/api/v1/shares')
 
@@ -57,7 +58,9 @@ export default {
                                if (!request?.data?.ocs) {
                                        throw request
                                }
-                               return new Share(request.data.ocs.data)
+                               const share = new Share(request.data.ocs.data)
+                               emit('files_sharing:share:created', { share })
+                               return share
                        } catch (error) {
                                console.error('Error while creating share', error)
                                const errorMessage = error?.response?.data?.ocs?.meta?.message
@@ -81,6 +84,7 @@ export default {
                                if (!request?.data?.ocs) {
                                        throw request
                                }
+                               emit('files_sharing:share:deleted', { id })
                                return true
                        } catch (error) {
                                console.error('Error while deleting share', error)
@@ -102,6 +106,7 @@ export default {
                async updateShare(id, properties) {
                        try {
                                const request = await axios.put(shareUrl + `/${id}`, properties)
+                               emit('files_sharing:share:updated', { id })
                                if (!request?.data?.ocs) {
                                        throw request
                                } else {