From 09a55258a0a173e8314bc835299964a5d0169c38 Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov Date: Sun, 21 Nov 2021 19:30:57 -0500 Subject: [PATCH] format --- js/src/common/models/Discussion.ts | 6 +++--- js/src/common/models/Post.ts | 2 +- js/src/forum/components/DiscussionsSearchSource.tsx | 6 +++++- js/src/forum/components/Search.tsx | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/js/src/common/models/Discussion.ts b/js/src/common/models/Discussion.ts index e6a95e25b..277ab0df5 100644 --- a/js/src/common/models/Discussion.ts +++ b/js/src/common/models/Discussion.ts @@ -42,7 +42,7 @@ export default class Discussion extends Model { return Model.attribute('commentCount').call(this); } replyCount() { - return computed('commentCount', (commentCount) => Math.max(0, (commentCount as number ?? 0) - 1)).call(this); + return computed('commentCount', (commentCount) => Math.max(0, ((commentCount as number) ?? 0) - 1)).call(this); } posts() { return Model.hasMany('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. diff --git a/js/src/common/models/Post.ts b/js/src/common/models/Post.ts index a487a22db..074914181 100644 --- a/js/src/common/models/Post.ts +++ b/js/src/common/models/Post.ts @@ -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); } diff --git a/js/src/forum/components/DiscussionsSearchSource.tsx b/js/src/forum/components/DiscussionsSearchSource.tsx index 5807566a7..d362ce0d5 100644 --- a/js/src/forum/components/DiscussionsSearchSource.tsx +++ b/js/src/forum/components/DiscussionsSearchSource.tsx @@ -40,7 +40,11 @@ export default class DiscussionsSearchSource implements SearchSource {
  • {highlight(discussion.title(), query)}
    - {mostRelevantPost ?
    {highlight(mostRelevantPost.contentPlain() ?? '', query, 100)}
    : ''} + {mostRelevantPost ? ( +
    {highlight(mostRelevantPost.contentPlain() ?? '', query, 100)}
    + ) : ( + '' + )}
  • ); diff --git a/js/src/forum/components/Search.tsx b/js/src/forum/components/Search.tsx index 13c1d838c..65b833c41 100644 --- a/js/src/forum/components/Search.tsx +++ b/js/src/forum/components/Search.tsx @@ -163,7 +163,7 @@ export default class Search 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('.Search-results')?.style?.setProperty('max-height', `${maxHeight}px`); } onupdate(vnode: Mithril.VnodeDOM) {