From 5d7f83c82211852b2b62da82422185bcab0215ef Mon Sep 17 00:00:00 2001 From: Davide Iadeluca Date: Sun, 27 Oct 2024 11:59:02 +0100 Subject: [PATCH] chore: resolve --- js/src/forum/panes/ProfileConfigurePane.js | 1 - js/src/forum/panes/ProfilePane.tsx | 25 +++++++++++++++++----- js/src/forum/panes/RootMasqueradePane.tsx | 7 ++++-- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/js/src/forum/panes/ProfileConfigurePane.js b/js/src/forum/panes/ProfileConfigurePane.js index 20d57ff..a7caf87 100644 --- a/js/src/forum/panes/ProfileConfigurePane.js +++ b/js/src/forum/panes/ProfileConfigurePane.js @@ -128,7 +128,6 @@ export default class ProfileConfigurePane extends Component { } parseResponse(response) { - console.log(response); this.answers = app.store.pushPayload(response); this.loading = false; m.redraw(); diff --git a/js/src/forum/panes/ProfilePane.tsx b/js/src/forum/panes/ProfilePane.tsx index b933544..a5dd82f 100644 --- a/js/src/forum/panes/ProfilePane.tsx +++ b/js/src/forum/panes/ProfilePane.tsx @@ -1,23 +1,32 @@ import app from 'flarum/forum/app'; -import Component from 'flarum/common/Component'; +import Component, { ComponentAttrs } from 'flarum/common/Component'; import TypeFactory from '../types/TypeFactory'; + import type Answer from '../../lib/models/Answer'; import type Field from 'src/lib/models/Field'; import type User from 'flarum/common/models/User'; +import type Mithril from 'mithril'; + +export interface ProfilePaneAttrs extends ComponentAttrs { + answers: Answer[]; + user: User; + loading: boolean; +} -export default class ProfilePane extends Component { +export default class ProfilePane extends Component { answers!: Answer[]; user!: User; + loading!: boolean; - oninit(vnode) { + oninit(vnode: Mithril.Vnode) { super.oninit(vnode); this.loading = true; this.answers = []; this.user = this.attrs.user; - this.load(this.user); + this.load(); } view() { @@ -49,9 +58,15 @@ export default class ProfilePane extends Component { load() { this.answers = this.user.masqueradeAnswers(); + const userId = this.user.id(); + + console.log('test', userId); + if (!userId) return; + + console.log('THis answers: ', this.answers); if (this.answers === false) { this.answers = []; - app.store.find('users', this.user.id(), { include: 'masqueradeAnswers' }).then(() => { + app.store.find('users', userId, { include: 'masqueradeAnswers' }).then(() => { this.answers = this.user.masqueradeAnswers(); m.redraw(); }); diff --git a/js/src/forum/panes/RootMasqueradePane.tsx b/js/src/forum/panes/RootMasqueradePane.tsx index 1f8d0c6..5a74c3b 100644 --- a/js/src/forum/panes/RootMasqueradePane.tsx +++ b/js/src/forum/panes/RootMasqueradePane.tsx @@ -3,10 +3,13 @@ import LoadingIndicator from 'flarum/common/components/LoadingIndicator'; import ProfilePane from './ProfilePane'; import ProfileConfigurePane from './ProfileConfigurePane'; +import type User from 'flarum/common/models/User'; +import type Mithril from 'mithril'; + export default class RootMasqueradePane extends UserPage { loading = true; - oninit(vnode) { + oninit(vnode: Mithril.Vnode) { super.oninit(vnode); this.loadUser(m.route.param('username')); @@ -19,7 +22,7 @@ export default class RootMasqueradePane extends UserPage { else return ; } - show(user) { + show(user: User) { super.show(user); this.loading = false;