feat: Pin to home (#2880)
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user