summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Petry <vincent@nextcloud.com>2022-01-12 17:43:39 +0100
committerGitHub <noreply@github.com>2022-01-12 17:43:39 +0100
commit4b47030f17b460f1807d5e583085f2313b89033b (patch)
tree0ffb709fe9d0c5e7fef1d7240803559416e49cc0
parentb8957cd6f3b684a676047e90783db4921cd7ed93 (diff)
parent672669ca98b1299821fc52d5fd393016b8a3b87f (diff)
downloadnextcloud-server-4b47030f17b460f1807d5e583085f2313b89033b.tar.gz
nextcloud-server-4b47030f17b460f1807d5e583085f2313b89033b.zip
Merge pull request #30629 from nextcloud/backport/30593/stable21
[stable21] Trigger "changeDirectory" event on URL change
-rw-r--r--apps/files/js/app.js10
-rw-r--r--apps/files/js/filelist.js13
2 files changed, 14 insertions, 9 deletions
diff --git a/apps/files/js/app.js b/apps/files/js/app.js
index 8015f395b74..a0f030c4000 100644
--- a/apps/files/js/app.js
+++ b/apps/files/js/app.js
@@ -306,7 +306,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);
}
},
@@ -376,9 +376,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));
}
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js
index c14526fe686..488e956ad08 100644
--- a/apps/files/js/filelist.js
+++ b/apps/files/js/filelist.js
@@ -768,7 +768,7 @@
if( (this._currentDirectory || this.$el.find('#dir').val()) && currentDir === e.dir) {
return;
}
- this.changeDirectory(e.dir, false, true);
+ this.changeDirectory(e.dir, true, true, undefined, true);
}
},
@@ -1912,15 +1912,16 @@
* @param {boolean} [changeUrl=true] if the URL must not be changed (defaults to true)
* @param {boolean} [force=false] set to true to force changing directory
* @param {string} [fileId] optional file id, if known, to be appended in the URL
+ * @param {bool} [changedThroughUrl=false] true if the dir was set through a URL change
*/
- changeDirectory: function(targetDir, changeUrl, force, fileId) {
+ changeDirectory: function(targetDir, changeUrl, force, fileId, changedThroughUrl) {
var self = this;
var currentDir = this.getCurrentDirectory();
targetDir = targetDir || '/';
if (!force && currentDir === targetDir) {
return;
}
- this._setCurrentDir(targetDir, changeUrl, fileId);
+ this._setCurrentDir(targetDir, changeUrl, fileId, changedThroughUrl);
// discard finished uploads list, we'll get it through a regular reload
this._uploads = {};
@@ -1955,8 +1956,9 @@
* @param targetDir directory to display
* @param changeUrl true to also update the URL, false otherwise (default)
* @param {string} [fileId] file id
+ * @param {bool} changedThroughUrl true if the dir was set through a URL change
*/
- _setCurrentDir: function(targetDir, changeUrl, fileId) {
+ _setCurrentDir: function(targetDir, changeUrl, fileId, changedThroughUrl) {
targetDir = targetDir.replace(/\\/g, '/');
if (!this._isValidPath(targetDir)) {
targetDir = '/';
@@ -1988,6 +1990,7 @@
if (fileId) {
params.fileId = fileId;
}
+ params.changedThroughUrl = changedThroughUrl
this.$el.trigger(jQuery.Event('changeDirectory', params));
}
this.breadcrumb.setDirectory(this.getCurrentDirectory());
@@ -2089,7 +2092,7 @@
if (status === 401) {
// We are not authentificated, so reload the page so that we get
// redirected to the login page while saving the current url.
- location.reload();
+ location.reload();
}
// Firewall Blocked request?