fix: Race condition updating document breadcrumb

This commit is contained in:
Tom Moor
2023-12-15 23:30:14 -05:00
parent 1d0d4e4048
commit ab7515b0e1
2 changed files with 15 additions and 6 deletions

View File

@@ -11,9 +11,11 @@ import DocumentsStore from "~/stores/DocumentsStore";
import User from "~/models/User";
import { client } from "~/utils/ApiClient";
import { settingsPath } from "~/utils/routeHelpers";
import Collection from "./Collection";
import View from "./View";
import ParanoidModel from "./base/ParanoidModel";
import Field from "./decorators/Field";
import Relation from "./decorators/Relation";
type SaveOptions = {
publish?: boolean;
@@ -59,6 +61,12 @@ export default class Document extends ParanoidModel {
@observable
collectionId?: string | null;
/**
* The comment that this comment is a reply to.
*/
@Relation(() => Collection, { onDelete: "cascade" })
collection?: Collection;
/**
* The text content of the document as Markdown.
*/
@@ -276,6 +284,11 @@ export default class Document extends ParanoidModel {
return floor((this.tasks.completed / this.tasks.total) * 100);
}
@computed
get pathTo() {
return this.collection?.pathToDocument(this.id) ?? [];
}
get titleWithDefault(): string {
return this.title || i18n.t("Untitled");
}