mirror of
https://github.com/flarum/core.git
synced 2025-08-08 17:36:38 +02:00
update IndexPage to clear discussions & refresh params using custom route solution
This commit is contained in:
committed by
Franz Liedke
parent
b1d948becc
commit
b0cbe277c2
@@ -29,14 +29,6 @@ export default class IndexPage extends Page {
|
||||
this.lastDiscussion = app.previous.get('discussion');
|
||||
}
|
||||
|
||||
// If the user is coming from the discussion list, then they have either
|
||||
// just switched one of the parameters (filter, sort, search) or they
|
||||
// probably want to refresh the results. We will clear the discussion list
|
||||
// cache so that results are reloaded.
|
||||
if (app.previous.matches(IndexPage)) {
|
||||
app.discussions.clear();
|
||||
}
|
||||
|
||||
app.discussions.refreshParams(app.search.params());
|
||||
|
||||
app.history.push('index', app.translator.trans('core.forum.header.back_to_index_tooltip'));
|
||||
@@ -44,6 +36,18 @@ export default class IndexPage extends Page {
|
||||
this.bodyClass = 'App--index';
|
||||
}
|
||||
|
||||
static onroutematch() {
|
||||
// If the user is coming from the discussion list, then they have either
|
||||
// just switched one of the parameters (filter, sort, search) or they
|
||||
// probably want to refresh the results. We will clear the discussion list
|
||||
// cache so that results are reloaded.
|
||||
if (app.current.matches(IndexPage)) {
|
||||
app.discussions.clear();
|
||||
|
||||
app.discussions.refreshParams(app.search.params());
|
||||
}
|
||||
}
|
||||
|
||||
view() {
|
||||
return (
|
||||
<div className="IndexPage">
|
||||
|
@@ -5,6 +5,15 @@ import DiscussionsUserPage from './components/DiscussionsUserPage';
|
||||
import SettingsPage from './components/SettingsPage';
|
||||
import NotificationsPage from './components/NotificationsPage';
|
||||
|
||||
const match = (component) => ({
|
||||
onmatch: () => {
|
||||
component.onroutematch();
|
||||
|
||||
return component;
|
||||
},
|
||||
render: (vnode) => vnode,
|
||||
});
|
||||
|
||||
/**
|
||||
* The `routes` initializer defines the forum app's routes.
|
||||
*
|
||||
@@ -12,7 +21,7 @@ import NotificationsPage from './components/NotificationsPage';
|
||||
*/
|
||||
export default function (app) {
|
||||
app.routes = {
|
||||
index: { path: '/all', component: IndexPage },
|
||||
index: { path: '/all', component: match(IndexPage) },
|
||||
|
||||
discussion: { path: '/d/:id', component: DiscussionPage },
|
||||
'discussion.near': { path: '/d/:id/:near', component: DiscussionPage },
|
||||
@@ -24,7 +33,7 @@ export default function (app) {
|
||||
settings: { path: '/settings', component: SettingsPage },
|
||||
notifications: { path: '/notifications', component: NotificationsPage },
|
||||
|
||||
'index.filter': { path: '/:filter', component: IndexPage },
|
||||
'index.filter': { path: '/:filter', component: match(IndexPage) },
|
||||
};
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user