Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable27] reload filelist when adding or removing shares #38420

Merged
merged 1 commit into from
Jun 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions apps/files/js/filelist.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,9 @@
}
});

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) {
Expand Down Expand Up @@ -2201,7 +2204,7 @@
*
* @return ajax call object
*/
reload: function() {
reload: function(keepOpen) {
this._selectedFiles = {};
this._selectionSummary.clear();
if (this._currentFileModel) {
Expand All @@ -2216,7 +2219,7 @@
properties: this._getWebdavProperties()
}
);
if (this._detailsView) {
if (this._detailsView && !keepOpen) {
// close sidebar
this._updateDetailsView(null);
}
Expand Down
7 changes: 6 additions & 1 deletion apps/files_sharing/src/mixins/ShareRequests.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import 'url-search-params-polyfill'
import { generateOcsUrl } from '@nextcloud/router'
import axios from '@nextcloud/axios'
import Share from '../models/Share.js'
import { emit } from '@nextcloud/event-bus'

const shareUrl = generateOcsUrl('apps/files_sharing/api/v1/shares')

Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions dist/files_sharing-files_sharing_tab.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files_sharing-files_sharing_tab.js.map

Large diffs are not rendered by default.