aboutsummaryrefslogtreecommitdiff
path: root/src/client/DocServer.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/DocServer.ts')
-rw-r--r--src/client/DocServer.ts16
1 files changed, 5 insertions, 11 deletions
diff --git a/src/client/DocServer.ts b/src/client/DocServer.ts
index cf7a61d24..ac865382d 100644
--- a/src/client/DocServer.ts
+++ b/src/client/DocServer.ts
@@ -26,7 +26,10 @@ import { SerializationHelper } from './util/SerializationHelper';
*/
export namespace DocServer {
// eslint-disable-next-line import/no-mutable-exports
- export let _cache: { [id: string]: RefField | Promise<Opt<RefField>> } = {};
+ let _cache: { [id: string]: RefField | Promise<Opt<RefField>> } = {};
+ export function Cache() {
+ return _cache;
+ }
function errorFunc(): never {
throw new Error("Can't use DocServer without calling init first");
@@ -54,15 +57,6 @@ export namespace DocServer {
}
}
- export function FindDocByTitle(title: string) {
- const foundDocId =
- title &&
- Array.from(Object.keys(_cache))
- .filter(key => _cache[key] instanceof Doc)
- .find(key => (_cache[key] as Doc).title === title);
-
- return foundDocId ? (_cache[foundDocId] as Doc) : undefined;
- }
let _socket: Socket;
// this client's distinct GUID created at initialization
let USER_ID: string;
@@ -228,7 +222,7 @@ export namespace DocServer {
const deserializeField = getSerializedField.then(async fieldJson => {
// deserialize
const field = await SerializationHelper.Deserialize(fieldJson);
- if (force && field instanceof Doc && cached instanceof Doc) {
+ if (force && field && cached instanceof Doc) {
cached[UpdatingFromServer] = true;
Array.from(Object.keys(field)).forEach(key => {
const fieldval = field[key];