Skip to content

Commit

Permalink
address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
scytacki committed Sep 19, 2024
1 parent b248042 commit 9f00059
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
7 changes: 4 additions & 3 deletions src/models/stores/document-group.test.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { observable } from "mobx";
import { mock } from "ts-jest-mocker";
import { DeepPartial } from "utility-types";
import { SnapshotIn } from "mobx-state-tree";

import { createDocumentModel, DocumentModelSnapshotType, DocumentModelType } from "../document/document";
import { DocumentContentSnapshotType } from "../document/document-content";
import { ProblemDocument } from '../document/document-types';
import { ClassModel, ClassModelType, ClassUserModel } from "./class";
import { GroupModel, GroupsModel, GroupsModelType, GroupUserModel } from "./groups";
import { DeepPartial } from "utility-types";
import { ISortedDocumentsStores, MetadataDocMapModel, SortedDocuments } from "./sorted-documents";
import { DB } from "../../lib/db";
import { mock } from "ts-jest-mocker";
import { Bookmark, Bookmarks } from "./bookmarks";
import { SnapshotIn } from "mobx-state-tree";


//****************************************** Documents Mock ***************************************
Expand Down
21 changes: 12 additions & 9 deletions src/models/stores/sorted-documents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,23 +340,26 @@ export class SortedDocuments {
const metadataDoc = this.firestoreMetadataDocs.find(doc => doc.key === docKey);
if (!metadataDoc) return;

const unit = metadataDoc?.unit ?? undefined;
const visibility = metadataDoc?.visibility === "public" || metadataDoc?.visibility === "private"
? metadataDoc?.visibility as "public" | "private"
: undefined;
const props = {
documentKey: metadataDoc?.key,
type: metadataDoc?.type as any,
title: metadataDoc?.title || undefined,
properties: metadataDoc?.properties.toJSON(),
userId: metadataDoc?.uid,
documentKey: metadataDoc.key,
type: metadataDoc.type as any,
properties: metadataDoc.properties.toJSON(),
userId: metadataDoc.uid,
groupId: undefined,
visibility,
originDoc: undefined,
pubVersion: undefined,
problem: metadataDoc?.problem || undefined,
investigation: metadataDoc?.investigation || undefined,
unit,

// The following props are sometimes null in Firestore on the metadata docs.
// For consistency we make them undefined which is what openDocument
// expects.
title: metadataDoc.title ?? undefined,
problem: metadataDoc.problem ?? undefined,
investigation: metadataDoc.investigation ?? undefined,
unit: metadataDoc.unit ?? undefined,
};

return this.db.openDocument(props);
Expand Down

0 comments on commit 9f00059

Please sign in to comment.