mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-02-24 04:00:59 +01:00
web: update tab/window title for locked & conflicted notes
This commit is contained in:
committed by
Abdullah Atta
parent
e6f1320b1d
commit
c85d623e1c
@@ -35,7 +35,7 @@ function DiffViewer(props) {
|
||||
|
||||
const setIsEditorOpen = useAppStore((store) => store.setIsEditorOpen);
|
||||
const sync = useAppStore((store) => store.sync);
|
||||
const clearSession = useEditorStore((store) => store.clearSession);
|
||||
const openSession = useEditorStore((store) => store.openSession);
|
||||
const [conflictedNote, setConflictedNote] = useState();
|
||||
const [remoteContent, setRemoteContent] = useState();
|
||||
const [localContent, setLocalContent] = useState();
|
||||
@@ -98,7 +98,10 @@ function DiffViewer(props) {
|
||||
hashNavigate(`/notes/create`, { replace: true });
|
||||
return;
|
||||
}
|
||||
notesStore.setSelectedNote(noteId);
|
||||
|
||||
await openSession(noteId);
|
||||
setIsEditorOpen(true);
|
||||
|
||||
note = note.data;
|
||||
|
||||
const content = await db.content.raw(note.contentId);
|
||||
@@ -114,12 +117,7 @@ function DiffViewer(props) {
|
||||
|
||||
setHtmlDiff({ before: content.data, after: content.conflicted.data });
|
||||
})();
|
||||
}, [noteId, resolveConflict]);
|
||||
|
||||
useEffect(() => {
|
||||
clearSession(false);
|
||||
setIsEditorOpen(true);
|
||||
}, [setIsEditorOpen, clearSession]);
|
||||
}, [noteId, openSession, setIsEditorOpen, resolveConflict]);
|
||||
|
||||
if (!conflictedNote || !localContent || !remoteContent) return null;
|
||||
return (
|
||||
|
||||
@@ -23,20 +23,25 @@ import * as Icon from "../icons";
|
||||
import { db } from "../../common/db";
|
||||
import { useStore as useEditorStore } from "../../stores/editor-store";
|
||||
import { useStore as useAppStore } from "../../stores/app-store";
|
||||
import { useStore as useNoteStore } from "../../stores/note-store";
|
||||
import Field from "../field";
|
||||
import { showToast } from "../../utils/toast";
|
||||
|
||||
function Unlock(props) {
|
||||
const { noteId } = props;
|
||||
const note = useMemo(() => db.notes.note(noteId)?.data, [noteId]);
|
||||
const passwordRef = useRef();
|
||||
|
||||
const [isWrong, setIsWrong] = useState(false);
|
||||
const [isUnlocking, setIsUnlocking] = useState(false);
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
|
||||
const passwordRef = useRef();
|
||||
|
||||
const note = useMemo(
|
||||
() => !isLoading && db.notes.note(noteId)?.data,
|
||||
[noteId, isLoading]
|
||||
);
|
||||
const openLockedSession = useEditorStore((store) => store.openLockedSession);
|
||||
const clearSession = useEditorStore((store) => store.clearSession);
|
||||
const openSession = useEditorStore((store) => store.openSession);
|
||||
const setIsEditorOpen = useAppStore((store) => store.setIsEditorOpen);
|
||||
const setSelectedNote = useNoteStore((store) => store.setSelectedNote);
|
||||
|
||||
const submit = useCallback(async () => {
|
||||
setIsUnlocking(true);
|
||||
@@ -58,10 +63,15 @@ function Unlock(props) {
|
||||
}, [setIsWrong, noteId, openLockedSession]);
|
||||
|
||||
useEffect(() => {
|
||||
clearSession(false);
|
||||
setIsEditorOpen(true);
|
||||
setTimeout(() => setSelectedNote(noteId));
|
||||
}, [clearSession, setIsEditorOpen, setSelectedNote, noteId]);
|
||||
(async () => {
|
||||
setIsLoading(true);
|
||||
|
||||
await openSession(noteId);
|
||||
setIsEditorOpen(true);
|
||||
|
||||
setIsLoading(false);
|
||||
})();
|
||||
}, [openSession, setIsEditorOpen, noteId]);
|
||||
|
||||
return (
|
||||
<Flex
|
||||
|
||||
Reference in New Issue
Block a user