Skip to content

Commit

Permalink
chore: resolve TS errors
Browse files Browse the repository at this point in the history
  • Loading branch information
DavideIadeluca committed Oct 27, 2024
1 parent 252c236 commit d93db65
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
3 changes: 1 addition & 2 deletions js/src/forum/components/RankingImage.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import app from 'flarum/forum/app';
import Component, { ComponentAttrs } from 'flarum/common/Component';
import type Mithril from 'mithril';
import icon from 'flarum/common/helpers/icon';

interface RankingImageAttrs extends ComponentAttrs {
export interface RankingImageAttrs extends ComponentAttrs {
place: number;
}

Expand Down
17 changes: 10 additions & 7 deletions js/src/forum/components/Voters.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import app from 'flarum/forum/app';

import Component from 'flarum/common/Component';
import Component, { ComponentAttrs } from 'flarum/common/Component';
import LoadingIndicator from 'flarum/common/components/LoadingIndicator';
import Link from 'flarum/common/components/Link';
import Tooltip from 'flarum/common/components/Tooltip';
Expand All @@ -9,8 +8,13 @@ import icon from 'flarum/common/helpers/icon';
import SubtreeRetainer from 'flarum/common/utils/SubtreeRetainer';

import type Mithril from 'mithril';
import type Post from 'flarum/common/models/Post';

export interface VotersAttrs extends ComponentAttrs {
post: Post;
}

export default class Voters extends Component {
export default class Voters extends Component<VotersAttrs> {
subtreeRetainer!: SubtreeRetainer;
lastRenderVotes: number = -1;
loading: boolean = false;
Expand All @@ -37,7 +41,7 @@ export default class Voters extends Component {
return this.subtreeRetainer.needsRebuild();
}

onupdate(vnode: Mithril.Vnode) {
onupdate() {
if (this.lastRenderVotes !== this.attrs.post.votes()) {
this.loading = true;
setTimeout(() => m.redraw(), 0);
Expand All @@ -47,8 +51,7 @@ export default class Voters extends Component {
}

view() {
// if (this.loading) {
if (this.attrs.post.votes() === false || this.attrs.post.upvotes() === false) {
if (this.attrs.post.votes() === 0 || this.attrs.post.upvotes().length === 0) {
return (
<div className="VotingContainer">
<div className="FoFGamification-voters">
Expand Down Expand Up @@ -106,7 +109,7 @@ export default class Voters extends Component {
}

async load() {
await app.store.find('posts', this.attrs.post.id(), {
await app.store.find<Post[]>('posts', this.attrs.post.id(), {
include: 'upvotes',
});

Expand Down

0 comments on commit d93db65

Please sign in to comment.