mirror of
https://github.com/flarum/framework.git
synced 2024-11-25 09:41:49 +08:00
Minor typefixes, fomat
This commit is contained in:
parent
4759395186
commit
f26ad3e32d
|
@ -203,14 +203,12 @@ export default abstract class Model {
|
|||
};
|
||||
|
||||
return app
|
||||
.request<ApiPayloadSingle>(
|
||||
{
|
||||
method: this.exists ? 'PATCH' : 'POST',
|
||||
url: app.forum.attribute('apiUrl') + this.apiEndpoint(),
|
||||
body: request,
|
||||
...options,
|
||||
},
|
||||
)
|
||||
.request<ApiPayloadSingle>({
|
||||
method: this.exists ? 'PATCH' : 'POST',
|
||||
url: app.forum.attribute('apiUrl') + this.apiEndpoint(),
|
||||
body: request,
|
||||
...options,
|
||||
})
|
||||
.then(
|
||||
// If everything went well, we'll make sure the store knows that this
|
||||
// model exists now (if it didn't already), and we'll push the data that
|
||||
|
@ -238,14 +236,12 @@ export default abstract class Model {
|
|||
if (!this.exists) return Promise.resolve();
|
||||
|
||||
return app
|
||||
.request(
|
||||
{
|
||||
method: 'DELETE',
|
||||
url: app.forum.attribute('apiUrl') + this.apiEndpoint(),
|
||||
body,
|
||||
...options,
|
||||
},
|
||||
)
|
||||
.request({
|
||||
method: 'DELETE',
|
||||
url: app.forum.attribute('apiUrl') + this.apiEndpoint(),
|
||||
body,
|
||||
...options,
|
||||
})
|
||||
.then(() => {
|
||||
this.exists = false;
|
||||
|
||||
|
|
|
@ -174,14 +174,12 @@ export default class Store {
|
|||
}
|
||||
|
||||
return app
|
||||
.request<M extends Array<infer _T> ? ApiPayloadPlural : ApiPayloadSingle>(
|
||||
{
|
||||
method: 'GET',
|
||||
url,
|
||||
params,
|
||||
...options,
|
||||
}
|
||||
)
|
||||
.request<M extends Array<infer _T> ? ApiPayloadPlural : ApiPayloadSingle>({
|
||||
method: 'GET',
|
||||
url,
|
||||
params,
|
||||
...options,
|
||||
})
|
||||
.then((payload) => {
|
||||
if (payloadIsPlural(payload)) {
|
||||
return this.pushPayload<FlatArray<M, 1>[]>(payload);
|
||||
|
|
|
@ -61,7 +61,7 @@ export default class Discussion extends Model {
|
|||
return computed<boolean, this>('unreadCount', (unreadCount) => !!unreadCount).call(this);
|
||||
}
|
||||
isRead() {
|
||||
return computed<boolean, this>('unreadCount', (unreadCount) => app.session.user && !unreadCount).call(this);
|
||||
return computed<boolean, this>('unreadCount', (unreadCount) => !!(app.session.user && !unreadCount)).call(this);
|
||||
}
|
||||
|
||||
hiddenAt() {
|
||||
|
@ -112,7 +112,7 @@ export default class Discussion extends Model {
|
|||
* user.
|
||||
*/
|
||||
unreadCount(): number {
|
||||
const user: User = app.session.user;
|
||||
const user = app.session.user;
|
||||
|
||||
if (user && (user.markedAllAsReadAt()?.getTime() ?? 0) < this.lastPostedAt()?.getTime()!) {
|
||||
const unreadCount = Math.max(0, (this.lastPostNumber() ?? 0) - (this.lastReadPostNumber() || 0));
|
||||
|
|
|
@ -38,7 +38,7 @@ export default class DiscussionsSearchSource implements SearchSource {
|
|||
|
||||
return (
|
||||
<li className="DiscussionSearchResult" data-index={'discussions' + discussion.id()}>
|
||||
<Link href={app.route.discussion(discussion, mostRelevantPost && mostRelevantPost.number())}>
|
||||
<Link href={app.route.discussion(discussion, (mostRelevantPost && mostRelevantPost.number()) || 0)}>
|
||||
<div className="DiscussionSearchResult-title">{highlight(discussion.title(), query)}</div>
|
||||
{mostRelevantPost ? (
|
||||
<div className="DiscussionSearchResult-excerpt">{highlight(mostRelevantPost.contentPlain() ?? '', query, 100)}</div>
|
||||
|
|
Loading…
Reference in New Issue
Block a user