fix: Flash of empty state on paginated lists (#3351)
* fix: Flash of empty state on paginated lists fix: Typing of PaginatedList to generic * test * test
This commit is contained in:
@@ -2,13 +2,17 @@ import { pick } from "lodash";
|
||||
import { set, computed, observable } from "mobx";
|
||||
import { getFieldsForModel } from "./decorators/Field";
|
||||
|
||||
export default class BaseModel {
|
||||
export default abstract class BaseModel {
|
||||
@observable
|
||||
id: string;
|
||||
|
||||
@observable
|
||||
isSaving: boolean;
|
||||
|
||||
createdAt: string;
|
||||
|
||||
updatedAt: string;
|
||||
|
||||
store: any;
|
||||
|
||||
constructor(fields: Record<string, any>, store: any) {
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { trim } from "lodash";
|
||||
import { action, computed, observable } from "mobx";
|
||||
import CollectionsStore from "~/stores/CollectionsStore";
|
||||
import BaseModel from "~/models/BaseModel";
|
||||
import Document from "~/models/Document";
|
||||
import ParanoidModel from "~/models/ParanoidModel";
|
||||
import { NavigationNode } from "~/types";
|
||||
import { client } from "~/utils/ApiClient";
|
||||
import Field from "./decorators/Field";
|
||||
|
||||
export default class Collection extends BaseModel {
|
||||
export default class Collection extends ParanoidModel {
|
||||
store: CollectionsStore;
|
||||
|
||||
@observable
|
||||
@@ -57,12 +57,6 @@ export default class Collection extends BaseModel {
|
||||
|
||||
documents: NavigationNode[];
|
||||
|
||||
createdAt: string;
|
||||
|
||||
updatedAt: string;
|
||||
|
||||
deletedAt: string | null | undefined;
|
||||
|
||||
url: string;
|
||||
|
||||
urlId: string;
|
||||
|
||||
@@ -4,9 +4,9 @@ import { action, computed, observable } from "mobx";
|
||||
import parseTitle from "@shared/utils/parseTitle";
|
||||
import unescape from "@shared/utils/unescape";
|
||||
import DocumentsStore from "~/stores/DocumentsStore";
|
||||
import BaseModel from "~/models/BaseModel";
|
||||
import User from "~/models/User";
|
||||
import { NavigationNode } from "~/types";
|
||||
import ParanoidModel from "./ParanoidModel";
|
||||
import View from "./View";
|
||||
import Field from "./decorators/Field";
|
||||
|
||||
@@ -17,7 +17,7 @@ type SaveOptions = {
|
||||
lastRevision?: number;
|
||||
};
|
||||
|
||||
export default class Document extends BaseModel {
|
||||
export default class Document extends ParanoidModel {
|
||||
@observable
|
||||
isSaving = false;
|
||||
|
||||
@@ -63,20 +63,14 @@ export default class Document extends BaseModel {
|
||||
|
||||
collaboratorIds: string[];
|
||||
|
||||
createdAt: string;
|
||||
|
||||
createdBy: User;
|
||||
|
||||
updatedAt: string;
|
||||
|
||||
updatedBy: User;
|
||||
|
||||
publishedAt: string | undefined;
|
||||
|
||||
archivedAt: string;
|
||||
|
||||
deletedAt: string | undefined;
|
||||
|
||||
url: string;
|
||||
|
||||
urlId: string;
|
||||
|
||||
5
app/models/ParanoidModel.ts
Normal file
5
app/models/ParanoidModel.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import BaseModel from "./BaseModel";
|
||||
|
||||
export default abstract class ParanoidModel extends BaseModel {
|
||||
deletedAt: string | undefined;
|
||||
}
|
||||
@@ -10,9 +10,6 @@ class Pin extends BaseModel {
|
||||
@observable
|
||||
@Field
|
||||
index: string;
|
||||
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export default Pin;
|
||||
|
||||
@@ -29,10 +29,6 @@ class Share extends BaseModel {
|
||||
url: string;
|
||||
|
||||
createdBy: User;
|
||||
|
||||
createdAt: string;
|
||||
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export default Share;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { computed, observable } from "mobx";
|
||||
import { Role } from "@shared/types";
|
||||
import BaseModel from "./BaseModel";
|
||||
import ParanoidModel from "./ParanoidModel";
|
||||
import Field from "./decorators/Field";
|
||||
|
||||
class User extends BaseModel {
|
||||
class User extends ParanoidModel {
|
||||
@Field
|
||||
@observable
|
||||
id: string;
|
||||
@@ -34,8 +34,6 @@ class User extends BaseModel {
|
||||
|
||||
isSuspended: boolean;
|
||||
|
||||
createdAt: string;
|
||||
|
||||
@computed
|
||||
get isInvited(): boolean {
|
||||
return !this.lastActiveAt;
|
||||
|
||||
Reference in New Issue
Block a user