feat: Pin to home (#2880)

This commit is contained in:
Tom Moor
2021-12-30 16:54:02 -08:00
committed by GitHub
parent 5be2eb75f3
commit eb0c324da8
57 changed files with 1884 additions and 819 deletions

View File

@@ -18,9 +18,10 @@ import {
} from "~/types";
import { client } from "~/utils/ApiClient";
type FetchParams = PaginationParams & { collectionId: string };
type FetchPageParams = PaginationParams & { template?: boolean };
type FetchPageParams = PaginationParams & {
template?: boolean;
collectionId?: string;
};
export type SearchParams = {
offset?: number;
@@ -127,13 +128,6 @@ export default class DocumentsStore extends BaseStore<Document> {
);
}
pinnedInCollection(collectionId: string): Document[] {
return filter(
this.recentlyUpdatedInCollection(collectionId),
(document) => document.pinned
);
}
publishedInCollection(collectionId: string): Document[] {
return filter(
this.all,
@@ -296,7 +290,7 @@ export default class DocumentsStore extends BaseStore<Document> {
fetchNamedPage = async (
request = "list",
options: FetchPageParams | undefined
): Promise<Document[] | undefined> => {
): Promise<Document[]> => {
this.isFetching = true;
try {
@@ -377,11 +371,6 @@ export default class DocumentsStore extends BaseStore<Document> {
return this.fetchNamedPage("drafts", options);
};
@action
fetchPinned = (options?: FetchParams): Promise<any> => {
return this.fetchNamedPage("pinned", options);
};
@action
fetchOwned = (options?: PaginationParams): Promise<any> => {
return this.fetchNamedPage("list", options);
@@ -732,18 +721,6 @@ export default class DocumentsStore extends BaseStore<Document> {
if (collection) collection.refresh();
};
pin = (document: Document) => {
return client.post("/documents.pin", {
id: document.id,
});
};
unpin = (document: Document) => {
return client.post("/documents.unpin", {
id: document.id,
});
};
star = async (document: Document) => {
this.starredIds.set(document.id, true);