aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrr-2017-04-24 23:02:25 +0200
committerrr-2017-04-24 23:02:25 +0200
commitfea9a949453482f7ede7957dbeeddb3c2ff427cc (patch)
tree3b6358f4026f41a4d87f6ae89f5f8b4f699088e7
parent467b4a76308b2fc4478dd3586e6339c88cc499b2 (diff)
client/routing: fix certain history bug
The bug could be reproduced as follows: 1. Navigate to /posts 2. Search for "test" 3. Navigate to /posts again 4. Refresh the page The user should see plain post list, but instead they were seeing the "test" search results again as if step 3 never happened.
-rw-r--r--client/js/controllers/post_list_controller.js5
-rw-r--r--client/js/controllers/tag_list_controller.js5
-rw-r--r--client/js/controllers/user_list_controller.js5
-rw-r--r--client/js/router.js7
4 files changed, 13 insertions, 9 deletions
diff --git a/client/js/controllers/post_list_controller.js b/client/js/controllers/post_list_controller.js
index c857742..4fce8ea 100644
--- a/client/js/controllers/post_list_controller.js
+++ b/client/js/controllers/post_list_controller.js
@@ -1,6 +1,7 @@
'use strict';
const config = require('../config.js');
+const router = require('../router.js');
const api = require('../api.js');
const settings = require('../models/settings.js');
const uri = require('../util/uri.js');
@@ -54,9 +55,7 @@ class PostListController {
}
_evtNavigate(e) {
- history.pushState(
- null,
- window.title,
+ router.showNoDispatch(
uri.formatClientLink('posts', e.detail.parameters));
Object.assign(this._ctx.parameters, e.detail.parameters);
this._syncPageController();
diff --git a/client/js/controllers/tag_list_controller.js b/client/js/controllers/tag_list_controller.js
index 2598143..3b4bd3e 100644
--- a/client/js/controllers/tag_list_controller.js
+++ b/client/js/controllers/tag_list_controller.js
@@ -1,5 +1,6 @@
'use strict';
+const router = require('../router.js');
const api = require('../api.js');
const uri = require('../util/uri.js');
const TagList = require('../models/tag_list.js');
@@ -46,9 +47,7 @@ class TagListController {
}
_evtNavigate(e) {
- history.pushState(
- null,
- window.title,
+ router.showNoDispatch(
uri.formatClientLink('tags', e.detail.parameters));
Object.assign(this._ctx.parameters, e.detail.parameters);
this._syncPageController();
diff --git a/client/js/controllers/user_list_controller.js b/client/js/controllers/user_list_controller.js
index 16f3b9b..fa878d8 100644
--- a/client/js/controllers/user_list_controller.js
+++ b/client/js/controllers/user_list_controller.js
@@ -1,6 +1,7 @@
'use strict';
const api = require('../api.js');
+const router = require('../router.js');
const uri = require('../util/uri.js');
const UserList = require('../models/user_list.js');
const topNavigation = require('../models/top_navigation.js');
@@ -38,9 +39,7 @@ class UserListController {
}
_evtNavigate(e) {
- history.pushState(
- null,
- window.title,
+ router.showNoDispatch(
uri.formatClientLink('users', e.detail.parameters));
Object.assign(this._ctx.parameters, e.detail.parameters);
this._syncPageController();
diff --git a/client/js/router.js b/client/js/router.js
index 64f467e..a8bd4c3 100644
--- a/client/js/router.js
+++ b/client/js/router.js
@@ -158,6 +158,13 @@ class Router {
window.removeEventListener('popstate', this._onPopState, false);
}
+ showNoDispatch(path, state) {
+ const ctx = new Context(path, state);
+ ctx.pushState();
+ this.ctx = ctx;
+ return ctx;
+ }
+
show(path, state, push) {
const ctx = new Context(path, state);
const oldPath = this.ctx ? this.ctx.path : ctx.path;

© 2015 - 2026 Jakob L. Kreuze