Skip to content

Commit

Permalink
chore: resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
DavideIadeluca committed Oct 27, 2024
1 parent 2e1b0b0 commit 5d7f83c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
1 change: 0 additions & 1 deletion js/src/forum/panes/ProfileConfigurePane.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
25 changes: 20 additions & 5 deletions js/src/forum/panes/ProfilePane.tsx
Original file line number Diff line number Diff line change
@@ -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<ProfilePaneAttrs> {
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() {
Expand Down Expand Up @@ -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();
});
Expand Down
7 changes: 5 additions & 2 deletions js/src/forum/panes/RootMasqueradePane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand All @@ -19,7 +22,7 @@ export default class RootMasqueradePane extends UserPage {
else return <ProfilePane user={this.user} />;
}

show(user) {
show(user: User) {
super.show(user);

this.loading = false;
Expand Down

0 comments on commit 5d7f83c

Please sign in to comment.