From be0730195d8090337ca5cd007b69615ede354ca8 Mon Sep 17 00:00:00 2001 From: bobzel Date: Thu, 15 Jun 2023 09:38:17 -0400 Subject: fixed adding links to update cache so that they dont' disappear if you quit right away. fixed highlighting text (with bold) to not update the text box size if it's autoHeight --- src/client/util/LinkManager.ts | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/client/util') diff --git a/src/client/util/LinkManager.ts b/src/client/util/LinkManager.ts index dbb05917e..3aa72f501 100644 --- a/src/client/util/LinkManager.ts +++ b/src/client/util/LinkManager.ts @@ -5,6 +5,7 @@ import { DirectLinks } from '../../fields/DocSymbols'; import { List } from '../../fields/List'; import { ProxyField } from '../../fields/Proxy'; import { Cast, DocCast, PromiseValue, StrCast } from '../../fields/Types'; +import { DocServer } from '../DocServer'; import { ScriptingGlobals } from './ScriptingGlobals'; /* * link doc: @@ -141,6 +142,7 @@ export class LinkManager { public addLink(linkDoc: Doc, checkExists = false) { if (!checkExists || !DocListCast(Doc.LinkDBDoc().data).includes(linkDoc)) { Doc.AddDocToList(Doc.LinkDBDoc(), 'data', linkDoc); + setTimeout(DocServer.UPDATE_SERVER_CACHE, 100); } } public deleteLink(linkDoc: Doc) { -- cgit v1.2.3-70-g09d2 From a6181a5695c7355b7996ac6c6c1e7aad886e6302 Mon Sep 17 00:00:00 2001 From: bobzel Date: Thu, 15 Jun 2023 09:57:46 -0400 Subject: fixed updating server cache when window/tab closes. --- src/client/DocServer.ts | 3 +++ src/client/util/CurrentUserUtils.ts | 1 + src/client/views/MainView.tsx | 1 + 3 files changed, 5 insertions(+) (limited to 'src/client/util') diff --git a/src/client/DocServer.ts b/src/client/DocServer.ts index 02b047a95..2a7f5a09b 100644 --- a/src/client/DocServer.ts +++ b/src/client/DocServer.ts @@ -37,6 +37,7 @@ export namespace DocServer { return foundDocId ? (_cache[foundDocId] as Doc) : undefined; } + let lastCacheUpdate = 0; export function UPDATE_SERVER_CACHE(print: boolean = false) { if (print) { const strings: string[] = []; @@ -51,6 +52,8 @@ export namespace DocServer { if (!(StrCast(doc.author).includes('.edu') || StrCast(doc.author).includes('.com')) || doc.author == Doc.CurrentUserEmail) return true; return false; }); + if (filtered.length === lastCacheUpdate) return; + lastCacheUpdate = filtered.length; rp.post(Utils.prepend('/setCacheDocumentIds'), { body: { diff --git a/src/client/util/CurrentUserUtils.ts b/src/client/util/CurrentUserUtils.ts index 59041862f..592f6d836 100644 --- a/src/client/util/CurrentUserUtils.ts +++ b/src/client/util/CurrentUserUtils.ts @@ -875,6 +875,7 @@ export class CurrentUserUtils { new LinkManager(); setTimeout(DocServer.UPDATE_SERVER_CACHE, 2500); + setInterval(DocServer.UPDATE_SERVER_CACHE, 120000); return doc; } static setupFieldInfos(doc:Doc, field="fieldInfos") { diff --git a/src/client/views/MainView.tsx b/src/client/views/MainView.tsx index b0e992cb6..c0c473cfc 100644 --- a/src/client/views/MainView.tsx +++ b/src/client/views/MainView.tsx @@ -529,6 +529,7 @@ export class MainView extends React.Component { }); initEventListeners = () => { + window.addEventListener('beforeunload', () => DocServer.UPDATE_SERVER_CACHE()); window.addEventListener('drop', e => e.preventDefault(), false); // prevent default behavior of navigating to a new web page window.addEventListener('dragover', e => e.preventDefault(), false); // document.addEventListener("pointermove", action(e => SearchBox.Instance._undoBackground = UndoManager.batchCounter ? "#000000a8" : undefined)); -- cgit v1.2.3-70-g09d2