Skip to content

Commit

Permalink
chore
Browse files Browse the repository at this point in the history
  • Loading branch information
DavideIadeluca committed Oct 27, 2024
1 parent 641e6b3 commit a432f5b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 2 additions & 0 deletions js/src/@types/shims.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'flarum/common/models/User';

import type Field from '../lib/models/Field';
import type Answer from '../lib/models/Answer';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,24 @@ import app from 'flarum/forum/app';
import UserCard from 'flarum/forum/components/UserCard';
import TypeFactory from './types/TypeFactory';

import type ItemList from 'flarum/common/utils/ItemList';
import type Mithril from 'mithril';
import type User from 'flarum/common/models/User';

export default function mutateUserHero() {
extend(UserCard.prototype, 'infoItems', function (items) {
const answers = app.forum.attribute('canViewMasquerade') ? this.attrs.user.bioFields() || [] : [];
extend(UserCard.prototype, 'infoItems', function (items: ItemList<Mithril.Children>) {
const user = (this.attrs as { user: User }).user;
const answers = app.forum.attribute('canViewMasquerade') ? user.bioFields() || [] : [];

items.add(
'masquerade-bio',
<div>
{answers.map((answer) => {
console.log('Answer: ', answer);
const field = answer.attribute('field');
const type = TypeFactory.typeForField({
field,
value: answer.content(),
value: answer.attribute('content'),
});

return type.answerField();
Expand Down

0 comments on commit a432f5b

Please sign in to comment.