mirror of
https://github.com/flarum/framework.git
synced 2024-12-01 14:20:47 +08:00
format
This commit is contained in:
parent
3a8d640dab
commit
09a55258a0
|
@ -42,7 +42,7 @@ export default class Discussion extends Model {
|
|||
return Model.attribute<number | undefined>('commentCount').call(this);
|
||||
}
|
||||
replyCount() {
|
||||
return computed<Number, this>('commentCount', (commentCount) => Math.max(0, (commentCount as number ?? 0) - 1)).call(this);
|
||||
return computed<Number, this>('commentCount', (commentCount) => Math.max(0, ((commentCount as number) ?? 0) - 1)).call(this);
|
||||
}
|
||||
posts() {
|
||||
return Model.hasMany<Post>('posts').call(this);
|
||||
|
@ -112,9 +112,9 @@ export default class Discussion extends Model {
|
|||
* user.
|
||||
*/
|
||||
unreadCount(): number {
|
||||
const user = app.session.user;
|
||||
const user: User = app.session.user;
|
||||
|
||||
if (user && user.markedAllAsReadAt().getTime() < this.lastPostedAt()?.getTime()!) {
|
||||
if (user && (user.markedAllAsReadAt()?.getTime() ?? 0) < this.lastPostedAt()?.getTime()!) {
|
||||
const unreadCount = Math.max(0, (this.lastPostNumber() ?? 0) - (this.lastReadPostNumber() || 0));
|
||||
// If posts have been deleted, it's possible that the unread count could exceed the
|
||||
// actual post count. As such, we take the min of the two to ensure this isn't an issue.
|
||||
|
|
|
@ -37,7 +37,7 @@ export default class Post extends Model {
|
|||
return getPlainContent(content);
|
||||
}
|
||||
|
||||
return content as (null | undefined);
|
||||
return content as null | undefined;
|
||||
}).call(this);
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,11 @@ export default class DiscussionsSearchSource implements SearchSource {
|
|||
<li className="DiscussionSearchResult" data-index={'discussions' + discussion.id()}>
|
||||
<Link href={app.route.discussion(discussion, mostRelevantPost && mostRelevantPost.number())}>
|
||||
<div className="DiscussionSearchResult-title">{highlight(discussion.title(), query)}</div>
|
||||
{mostRelevantPost ? <div className="DiscussionSearchResult-excerpt">{highlight(mostRelevantPost.contentPlain() ?? '', query, 100)}</div> : ''}
|
||||
{mostRelevantPost ? (
|
||||
<div className="DiscussionSearchResult-excerpt">{highlight(mostRelevantPost.contentPlain() ?? '', query, 100)}</div>
|
||||
) : (
|
||||
''
|
||||
)}
|
||||
</Link>
|
||||
</li>
|
||||
);
|
||||
|
|
|
@ -163,7 +163,7 @@ export default class Search<T extends SearchAttrs = SearchAttrs> extends Compone
|
|||
const maxHeight =
|
||||
window.innerHeight - this.element.querySelector('.Search-input>.FormControl')!.getBoundingClientRect().bottom - resultsElementMargin;
|
||||
|
||||
(this.element.querySelector('.Search-results') as HTMLElement).style?.setProperty('max-height', `${maxHeight}px`);
|
||||
this.element.querySelector<HTMLElement>('.Search-results')?.style?.setProperty('max-height', `${maxHeight}px`);
|
||||
}
|
||||
|
||||
onupdate(vnode: Mithril.VnodeDOM<T, this>) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user