-
-
Notifications
You must be signed in to change notification settings - Fork 835
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into tk/post-reply-test
- Loading branch information
Showing
145 changed files
with
3,434 additions
and
825 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import Post from 'flarum/common/models/Post'; | ||
import User from 'flarum/common/models/User'; | ||
|
||
declare module 'flarum/common/models/Post' { | ||
export default interface Post { | ||
likes(): User[]; | ||
likesCount(): number; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 0 additions & 31 deletions
31
extensions/likes/js/src/forum/components/PostLikesModal.js
This file was deleted.
Oops, something went wrong.
72 changes: 72 additions & 0 deletions
72
extensions/likes/js/src/forum/components/PostLikesModal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import app from 'flarum/forum/app'; | ||
import Modal from 'flarum/common/components/Modal'; | ||
import Link from 'flarum/common/components/Link'; | ||
import avatar from 'flarum/common/helpers/avatar'; | ||
import username from 'flarum/common/helpers/username'; | ||
import type { IInternalModalAttrs } from 'flarum/common/components/Modal'; | ||
import type Post from 'flarum/common/models/Post'; | ||
import type Mithril from 'mithril'; | ||
import PostLikesModalState from '../states/PostLikesModalState'; | ||
import Button from '@flarum/core/src/common/components/Button'; | ||
import LoadingIndicator from '@flarum/core/src/common/components/LoadingIndicator'; | ||
|
||
export interface IPostLikesModalAttrs extends IInternalModalAttrs { | ||
post: Post; | ||
} | ||
|
||
export default class PostLikesModal<CustomAttrs extends IPostLikesModalAttrs = IPostLikesModalAttrs> extends Modal<CustomAttrs, PostLikesModalState> { | ||
oninit(vnode: Mithril.VnodeDOM<CustomAttrs, this>) { | ||
super.oninit(vnode); | ||
|
||
this.state = new PostLikesModalState({ | ||
filter: { | ||
liked: this.attrs.post.id()!, | ||
}, | ||
}); | ||
|
||
this.state.refresh(); | ||
} | ||
|
||
className() { | ||
return 'PostLikesModal Modal--small'; | ||
} | ||
|
||
title() { | ||
return app.translator.trans('flarum-likes.forum.post_likes.title'); | ||
} | ||
|
||
content() { | ||
return ( | ||
<> | ||
<div className="Modal-body"> | ||
{this.state.isInitialLoading() ? ( | ||
<LoadingIndicator /> | ||
) : ( | ||
<ul className="PostLikesModal-list"> | ||
{this.state.getPages().map((page) => | ||
page.items.map((user) => ( | ||
<li> | ||
<Link href={app.route.user(user)}> | ||
{avatar(user)} {username(user)} | ||
</Link> | ||
</li> | ||
)) | ||
)} | ||
</ul> | ||
)} | ||
</div> | ||
{this.state.hasNext() ? ( | ||
<div className="Modal-footer"> | ||
<div className="Form Form--centered"> | ||
<div className="Form-group"> | ||
<Button className="Button Button--block" onclick={() => this.state.loadNext()} loading={this.state.isLoadingNext()}> | ||
{app.translator.trans('flarum-likes.forum.post_likes.load_more_button')} | ||
</Button> | ||
</div> | ||
</div> | ||
</div> | ||
) : null} | ||
</> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
extensions/likes/js/src/forum/states/PostLikesModalState.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import PaginatedListState, { PaginatedListParams } from '@flarum/core/src/common/states/PaginatedListState'; | ||
import User from 'flarum/common/models/User'; | ||
|
||
export interface PostLikesModalListParams extends PaginatedListParams { | ||
filter: { | ||
liked: string; | ||
}; | ||
page?: { | ||
offset?: number; | ||
limit: number; | ||
}; | ||
} | ||
|
||
export default class PostLikesModalState<P extends PostLikesModalListParams = PostLikesModalListParams> extends PaginatedListState<User, P> { | ||
constructor(params: P, page: number = 1) { | ||
const limit = 10; | ||
|
||
params.page = { ...(params.page || {}), limit }; | ||
|
||
super(params, page, limit); | ||
} | ||
|
||
get type(): string { | ||
return 'users'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.