diff --git a/js/src/forum/addProfilePane.ts b/js/src/forum/addProfilePane.ts index 5488b2c..9d98c86 100644 --- a/js/src/forum/addProfilePane.ts +++ b/js/src/forum/addProfilePane.ts @@ -3,23 +3,11 @@ import app from 'flarum/forum/app'; import { extend } from 'flarum/common/extend'; import LinkButton from 'flarum/common/components/LinkButton'; import UserPage from 'flarum/forum/components/UserPage'; -import RootMasqueradePane from './panes/RootMasqueradePane'; import type ItemList from 'flarum/common/utils/ItemList'; import type Mithril from 'mithril'; export default function addProfilePane() { - app.routes['fof-masquerade'] = { - path: '/u/:username/masquerade', - resolver: { - onmatch() { - if (!app.forum.attribute('canViewMasquerade')) throw new Error(); - - return RootMasqueradePane; - }, - }, - }; - extend(UserPage.prototype, 'navItems', function (items: ItemList) { if (app.forum.attribute('canViewMasquerade') || this.user?.canEditMasqueradeProfile()) { const edit = this.user?.canEditMasqueradeProfile(); diff --git a/js/src/forum/extend.ts b/js/src/forum/extend.ts index 29d893e..2490029 100644 --- a/js/src/forum/extend.ts +++ b/js/src/forum/extend.ts @@ -2,12 +2,16 @@ import Extend from 'flarum/common/extenders'; import User from 'flarum/common/models/User'; import Field from '../lib/models/Field'; import Answer from '../lib/models/Answer'; +import RootMasqueradePane from './panes/RootMasqueradePane'; import { default as commonExtend } from '../common/extend'; export default [ ...commonExtend, + new Extend.Routes() // + .add('fof-masquerade', '/u/:username/masquerade', RootMasqueradePane), + new Extend.Store() // .add('masquerade-answer', Answer), diff --git a/js/src/forum/panes/RootMasqueradePane.tsx b/js/src/forum/panes/RootMasqueradePane.tsx index 5a74c3b..55c3a77 100644 --- a/js/src/forum/panes/RootMasqueradePane.tsx +++ b/js/src/forum/panes/RootMasqueradePane.tsx @@ -1,3 +1,4 @@ +import app from 'flarum/forum/app'; import UserPage from 'flarum/forum/components/UserPage'; import LoadingIndicator from 'flarum/common/components/LoadingIndicator'; import ProfilePane from './ProfilePane'; @@ -12,6 +13,10 @@ export default class RootMasqueradePane extends UserPage { oninit(vnode: Mithril.Vnode) { super.oninit(vnode); + if (!app.forum.attribute('canViewMasquerade')) { + m.route.set(app.route('index')); + } + this.loadUser(m.route.param('username')); }