mirror of
https://github.com/flarum/framework.git
synced 2024-11-25 17:57:04 +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
|
return app
|
||||||
.request<ApiPayloadSingle>(
|
.request<ApiPayloadSingle>({
|
||||||
{
|
method: this.exists ? 'PATCH' : 'POST',
|
||||||
method: this.exists ? 'PATCH' : 'POST',
|
url: app.forum.attribute('apiUrl') + this.apiEndpoint(),
|
||||||
url: app.forum.attribute('apiUrl') + this.apiEndpoint(),
|
body: request,
|
||||||
body: request,
|
...options,
|
||||||
...options,
|
})
|
||||||
},
|
|
||||||
)
|
|
||||||
.then(
|
.then(
|
||||||
// If everything went well, we'll make sure the store knows that this
|
// 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
|
// 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();
|
if (!this.exists) return Promise.resolve();
|
||||||
|
|
||||||
return app
|
return app
|
||||||
.request(
|
.request({
|
||||||
{
|
method: 'DELETE',
|
||||||
method: 'DELETE',
|
url: app.forum.attribute('apiUrl') + this.apiEndpoint(),
|
||||||
url: app.forum.attribute('apiUrl') + this.apiEndpoint(),
|
body,
|
||||||
body,
|
...options,
|
||||||
...options,
|
})
|
||||||
},
|
|
||||||
)
|
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.exists = false;
|
this.exists = false;
|
||||||
|
|
||||||
|
|
|
@ -174,14 +174,12 @@ export default class Store {
|
||||||
}
|
}
|
||||||
|
|
||||||
return app
|
return app
|
||||||
.request<M extends Array<infer _T> ? ApiPayloadPlural : ApiPayloadSingle>(
|
.request<M extends Array<infer _T> ? ApiPayloadPlural : ApiPayloadSingle>({
|
||||||
{
|
method: 'GET',
|
||||||
method: 'GET',
|
url,
|
||||||
url,
|
params,
|
||||||
params,
|
...options,
|
||||||
...options,
|
})
|
||||||
}
|
|
||||||
)
|
|
||||||
.then((payload) => {
|
.then((payload) => {
|
||||||
if (payloadIsPlural(payload)) {
|
if (payloadIsPlural(payload)) {
|
||||||
return this.pushPayload<FlatArray<M, 1>[]>(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);
|
return computed<boolean, this>('unreadCount', (unreadCount) => !!unreadCount).call(this);
|
||||||
}
|
}
|
||||||
isRead() {
|
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() {
|
hiddenAt() {
|
||||||
|
@ -112,7 +112,7 @@ export default class Discussion extends Model {
|
||||||
* user.
|
* user.
|
||||||
*/
|
*/
|
||||||
unreadCount(): number {
|
unreadCount(): number {
|
||||||
const user: User = app.session.user;
|
const user = app.session.user;
|
||||||
|
|
||||||
if (user && (user.markedAllAsReadAt()?.getTime() ?? 0) < this.lastPostedAt()?.getTime()!) {
|
if (user && (user.markedAllAsReadAt()?.getTime() ?? 0) < this.lastPostedAt()?.getTime()!) {
|
||||||
const unreadCount = Math.max(0, (this.lastPostNumber() ?? 0) - (this.lastReadPostNumber() || 0));
|
const unreadCount = Math.max(0, (this.lastPostNumber() ?? 0) - (this.lastReadPostNumber() || 0));
|
||||||
|
|
|
@ -38,7 +38,7 @@ export default class DiscussionsSearchSource implements SearchSource {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<li className="DiscussionSearchResult" data-index={'discussions' + discussion.id()}>
|
<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>
|
<div className="DiscussionSearchResult-title">{highlight(discussion.title(), query)}</div>
|
||||||
{mostRelevantPost ? (
|
{mostRelevantPost ? (
|
||||||
<div className="DiscussionSearchResult-excerpt">{highlight(mostRelevantPost.contentPlain() ?? '', query, 100)}</div>
|
<div className="DiscussionSearchResult-excerpt">{highlight(mostRelevantPost.contentPlain() ?? '', query, 100)}</div>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user