mobile: minor bug fixes

This commit is contained in:
Ammar Ahmed
2024-03-26 08:57:04 +05:00
parent e007f2592c
commit 9e7c302693
25 changed files with 470 additions and 250 deletions

View File

@@ -154,9 +154,7 @@ export function useEditorController({
if (typeof timers.current.wordCounter === "number")
clearTimeout(timers.current.wordCounter);
timers.current.wordCounter = setTimeout(() => {
console.time("wordCounter");
statusBars[tab.id]?.current?.updateWords();
console.timeEnd("wordCounter");
}, ms);
},
[tab.id]
@@ -168,6 +166,7 @@ export function useEditorController({
const contentChange = useCallback(
(editor: Editor, ignoreEdit?: boolean) => {
if (editorControllers[tab.id]?.loading) return;
const currentSessionId = globalThis.sessionId;
post(EventTypes.contentchange, undefined, tab.id, tab.noteId);
if (!editor) return;
@@ -195,20 +194,31 @@ export function useEditorController({
const scroll = useCallback(
(_event: React.UIEvent<HTMLDivElement, UIEvent>) => {
if (!tab) return;
if (tab.noteId) {
useTabStore.getState().setNoteState(tab.noteId, {
const noteId = useTabStore
.getState()
.getNoteIdForTab(useTabStore.getState().currentTab);
if (noteId) {
useTabStore.getState().setNoteState(noteId, {
top: _event.currentTarget.scrollTop
});
}
},
[tab]
[]
);
const onUpdate = useCallback(() => {
update();
logger("info", "Updating content...");
}, [update]);
useEffect(() => {
if (tab.locked) {
htmlContentRef.current = "";
setLoading(true);
onUpdate();
}
}, [tab.locked, onUpdate]);
const onMessage = useCallback(
(event: Event & { data?: string }) => {
if (event?.data?.[0] !== "{") return;