diff options
author | Vincent Petry <vincent@nextcloud.com> | 2022-01-11 12:17:23 +0100 |
---|---|---|
committer | Vincent Petry <vincent@nextcloud.com> | 2022-01-11 17:48:03 +0100 |
commit | 809e3054448d952124811877c1a944f0446c79c1 (patch) | |
tree | 8d96813370838fcf144465b0ab2bc3d473223665 /apps/files/js/app.js | |
parent | 796764aafd318cfeedf6d19af4551e846a40ac94 (diff) | |
download | nextcloud-server-809e3054448d952124811877c1a944f0446c79c1.tar.gz nextcloud-server-809e3054448d952124811877c1a944f0446c79c1.zip |
Trigger "changeDirectory" even on URL change
When using the browser back button or clicking on sections on the left
sidebar (like favorites), the "changeDirectory" jQuery event did not get
called, so apps like recommendations would not notice the directory
change.
This fixes the issue by also setting changeUrl to true when the file
list's directory got changed as a result from a URL change.
Added optional changedThroughUrl argument to make sure the event
recipient knows if the change was done through a URL change and make it
possible prevent a loop in the onDirectoryChange handler that actually
changes the URL when the origin was already from a URL change.
Signed-off-by: Vincent Petry <vincent@nextcloud.com>
Diffstat (limited to 'apps/files/js/app.js')
-rw-r--r-- | apps/files/js/app.js | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/apps/files/js/app.js b/apps/files/js/app.js index 5efa20887e6..d6b7a79b362 100644 --- a/apps/files/js/app.js +++ b/apps/files/js/app.js @@ -316,7 +316,7 @@ * Event handler for when an app notified that its directory changed */ _onDirectoryChanged: function(e) { - if (e.dir) { + if (e.dir && !e.changedThroughUrl) { this._changeUrl(this.navigation.getActiveItem(), e.dir, e.fileId); } }, @@ -386,9 +386,11 @@ params.fileid = fileId; } var currentParams = OC.Util.History.parseUrlQuery(); - if (currentParams.dir === params.dir && currentParams.view === params.view && currentParams.fileid !== params.fileid) { - // if only fileid changed or was added, replace instead of push - OC.Util.History.replaceState(this._makeUrlParams(params)); + if (currentParams.dir === params.dir && currentParams.view === params.view) { + if (currentParams.fileid !== params.fileid) { + // if only fileid changed or was added, replace instead of push + OC.Util.History.replaceState(this._makeUrlParams(params)); + } } else { OC.Util.History.pushState(this._makeUrlParams(params)); } |