diff --git a/web/src/components/MemoEditor/Toolbar/EditorToolbar.tsx b/web/src/components/MemoEditor/Toolbar/EditorToolbar.tsx index 8e0bd0a1..5281977c 100644 --- a/web/src/components/MemoEditor/Toolbar/EditorToolbar.tsx +++ b/web/src/components/MemoEditor/Toolbar/EditorToolbar.tsx @@ -1,18 +1,40 @@ +import { CheckIcon, CornerDownLeftIcon, LoaderIcon } from "lucide-react"; import type { FC } from "react"; import { Button } from "@/components/ui/button"; import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip"; +import { cn } from "@/lib/utils"; import type { Location, Visibility } from "@/types/proto/api/v1/memo_service_pb"; import { useTranslate } from "@/utils/i18n"; +import { primaryModifierGlyph } from "@/utils/platform"; import { validationService } from "../services"; import { useEditorContext, useEditorSelector } from "../state"; import type { EditorToolbarProps } from "../types"; import InsertMenu from "./InsertMenu"; import VisibilitySelector from "./VisibilitySelector"; +/** + * Shortcut chip inside the commit button. While saving, a spinner takes the + * chip's place; both layers share one grid cell so the button keeps its width + * across the swap. Hidden on coarse pointers, where there is no keyboard to hint. + */ +const ShortcutChip: FC<{ busy: boolean }> = ({ busy }) => ( + + + {primaryModifierGlyph()} + + + + +); + export const EditorToolbar: FC = ({ onSave, onCancel, memoName, + parentMemoName, space, onAudioRecorderClick, viewToggles, @@ -27,14 +49,23 @@ export const EditorToolbar: FC = ({ const blockedReason = useEditorSelector((s) => validationService.canSave(s).reason); const blockedReasonDetail = useEditorSelector((s) => validationService.canSave(s).detail); const isSaving = useEditorSelector((s) => s.ui.isLoading.saving); + const justSaved = useEditorSelector((s) => s.ui.justSaved); const isUploading = useEditorSelector((s) => s.ui.isLoading.uploading); const location = useEditorSelector((s) => s.metadata.location); const visibility = useEditorSelector((s) => s.metadata.visibility); - const blockedMessage = valid - ? undefined - : blockedReason - ? t(blockedReason, blockedReasonDetail ? { url: blockedReasonDetail } : undefined) - : t("editor.validation.cannot-save"); + // The save transaction is in flight or its confirmation is holding the + // editor open; either way the toolbar is frozen. + const committing = isSaving || justSaved; + const blockedMessage = + valid || committing + ? undefined + : blockedReason + ? t(blockedReason, blockedReasonDetail ? { url: blockedReasonDetail } : undefined) + : t("editor.validation.cannot-save"); + // The verb names what the host does with the memo: an existing memo is + // updated, a reply becomes a comment, and a new memo is simply saved. A memo + // is stored with a visibility, not posted, so messaging verbs stay out. + const commitLabel = memoName ? t("common.update") : parentMemoName ? t("editor.comment") : t("editor.save"); const handleLocationChange = (next?: Location) => { dispatch(actions.setMetadata({ location: next })); @@ -44,12 +75,24 @@ export const EditorToolbar: FC = ({ dispatch(actions.setMetadata({ visibility: next })); }; + const commitButton = justSaved ? ( + + ) : ( + + ); + return (
= ({
{onCancel && ( - )} - {!valid && !isSaving && blockedMessage ? ( + {blockedMessage ? ( }> - + {commitButton} {blockedMessage} ) : ( - + commitButton )}
diff --git a/web/src/components/MemoEditor/hooks/useMemoSave.ts b/web/src/components/MemoEditor/hooks/useMemoSave.ts index 05b22a71..a88ea394 100644 --- a/web/src/components/MemoEditor/hooks/useMemoSave.ts +++ b/web/src/components/MemoEditor/hooks/useMemoSave.ts @@ -11,6 +11,9 @@ import { useTranslate } from "@/utils/i18n"; import { errorService, memoService, validationService } from "../services"; import { useEditorContext } from "../state"; +/** How long a closing host shows "Saved" before it unmounts the editor. */ +const SAVED_CONFIRMATION_MS = 900; + interface UseMemoSaveOptions { memoName?: string; parentMemoName?: string; @@ -44,6 +47,9 @@ export function useMemoSave({ return useCallback(async () => { const state = getState(); + // A repeated shortcut during the saved confirmation is not an error worth + // a toast; the save already landed and the host is closing. + if (state.ui.justSaved) return; const { valid, reason, detail } = validationService.canSave(state); if (!valid) { toast.error(reason ? t(reason, detail ? { url: detail } : undefined) : t("editor.validation.cannot-save")); @@ -64,7 +70,7 @@ export function useMemoSave({ // Prevent the autosave unmount flush from restoring the saved draft. discardDraft(); - const invalidationPromises = [ + const invalidationPromises: Promise[] = [ queryClient.invalidateQueries({ queryKey: memoKeys.lists() }), queryClient.invalidateQueries({ queryKey: userKeys.stats() }), queryClient.invalidateQueries({ queryKey: attachmentKeys.lists() }), @@ -76,6 +82,14 @@ export function useMemoSave({ invalidationPromises.push(queryClient.invalidateQueries({ queryKey: memoKeys.comments(parentMemoName) })); invalidationPromises.push(queryClient.invalidateQueries({ queryKey: memoKeys.detail(parentMemoName) })); } + // Hosts that close after saving (edit, comment) hold a brief "Saved" + // confirmation on the toolbar while the caches refresh underneath. The + // in-place composer clears immediately, so it shows nothing. + if (memoName || parentMemoName) { + dispatch(actions.setLoading("saving", false)); + dispatch(actions.setJustSaved(true)); + invalidationPromises.push(new Promise((resolve) => setTimeout(resolve, SAVED_CONFIRMATION_MS))); + } await Promise.all(invalidationPromises); dispatch(actions.reset()); @@ -99,6 +113,7 @@ export function useMemoSave({ }); } finally { dispatch(actions.setLoading("saving", false)); + dispatch(actions.setJustSaved(false)); } }, [ actions, diff --git a/web/src/components/MemoEditor/index.tsx b/web/src/components/MemoEditor/index.tsx index e0a1bfe6..afba0154 100644 --- a/web/src/components/MemoEditor/index.tsx +++ b/web/src/components/MemoEditor/index.tsx @@ -365,6 +365,7 @@ const MemoEditorImpl: React.FC = ({ onSave={handleSave} onCancel={onCancel ? handleCancel : undefined} memoName={memoName} + parentMemoName={parentMemoName} space={editorSpace} onAudioRecorderClick={handleAudioRecorderClick} viewToggles={viewToggles} diff --git a/web/src/components/MemoEditor/services/validationService.ts b/web/src/components/MemoEditor/services/validationService.ts index 852da0d9..776c57e1 100644 --- a/web/src/components/MemoEditor/services/validationService.ts +++ b/web/src/components/MemoEditor/services/validationService.ts @@ -41,8 +41,9 @@ export const validationService = { return { valid: false, reason: "editor.validation.finish-audio-recording" }; } - // Cannot save while already saving - if (state.ui.isLoading.saving) { + // Cannot save while already saving, or while the saved confirmation holds + // the editor open for its closing host. + if (state.ui.isLoading.saving || state.ui.justSaved) { return { valid: false, reason: "editor.validation.save-in-progress" }; } diff --git a/web/src/components/MemoEditor/state/actions.ts b/web/src/components/MemoEditor/state/actions.ts index 63868ca3..a941eed8 100644 --- a/web/src/components/MemoEditor/state/actions.ts +++ b/web/src/components/MemoEditor/state/actions.ts @@ -56,6 +56,11 @@ export const editorActions = { payload: timestamps, }), + setJustSaved: (value: boolean): EditorAction => ({ + type: "SET_JUST_SAVED", + payload: value, + }), + setRecorderBusy: (value: boolean): EditorAction => ({ type: "SET_RECORDER_BUSY", payload: value, diff --git a/web/src/components/MemoEditor/state/reducer.ts b/web/src/components/MemoEditor/state/reducer.ts index 1c9cbfe3..2536370d 100644 --- a/web/src/components/MemoEditor/state/reducer.ts +++ b/web/src/components/MemoEditor/state/reducer.ts @@ -95,6 +95,15 @@ export function editorReducer(state: EditorState, action: EditorAction): EditorS recorderBusy: action.payload, }; + case "SET_JUST_SAVED": + return { + ...state, + ui: { + ...state.ui, + justSaved: action.payload, + }, + }; + case "RESET": return createInitialState(); diff --git a/web/src/components/MemoEditor/state/types.ts b/web/src/components/MemoEditor/state/types.ts index 8e956694..7d8aae7d 100644 --- a/web/src/components/MemoEditor/state/types.ts +++ b/web/src/components/MemoEditor/state/types.ts @@ -23,6 +23,10 @@ export interface EditorState { uploading: boolean; loading: boolean; }; + /** Save landed and the editor is about to close; the toolbar shows a brief + * confirmation instead of the commit verb. Only hosts that unmount after + * saving set it; the in-place composer resets immediately. */ + justSaved: boolean; }; timestamps: { createTime?: Date; @@ -46,6 +50,7 @@ export type EditorAction = | { type: "SET_PENDING_INLINE_IMAGE_INSERTIONS"; payload: number } | { type: "SET_TIMESTAMPS"; payload: Partial } | { type: "SET_RECORDER_BUSY"; payload: boolean } + | { type: "SET_JUST_SAVED"; payload: boolean } | { type: "RESET" }; // Module-private template for createInitialState. @@ -66,6 +71,7 @@ const defaultState: EditorState = { uploading: false, loading: false, }, + justSaved: false, }, timestamps: { createTime: undefined, diff --git a/web/src/components/MemoEditor/types/components.ts b/web/src/components/MemoEditor/types/components.ts index 48d56b2b..d3bcd879 100644 --- a/web/src/components/MemoEditor/types/components.ts +++ b/web/src/components/MemoEditor/types/components.ts @@ -58,6 +58,8 @@ export interface EditorToolbarProps { onSave: () => void; onCancel?: () => void; memoName?: string; + /** Set when the editor composes a comment on this memo; picks the commit verb. */ + parentMemoName?: string; /** The Space that owns the memo being created or edited, if any. */ space?: string; onAudioRecorderClick: () => void; diff --git a/web/src/locales/ar.json b/web/src/locales/ar.json index 5914ebf9..a51bdb33 100644 --- a/web/src/locales/ar.json +++ b/web/src/locales/ar.json @@ -125,7 +125,6 @@ "focus-mode": "وضع التركيز", "no-changes-detected": "لم يتم الكشف عن تغييرات", "save": "حفظ", - "saving": "جارِ الحفظ...", "insert-menu": { "add-location": "أضف الموقع", "link-memo": "مذكرة الارتباط", diff --git a/web/src/locales/bg.json b/web/src/locales/bg.json index 3be0daa7..4cc37f38 100644 --- a/web/src/locales/bg.json +++ b/web/src/locales/bg.json @@ -170,7 +170,6 @@ }, "no-changes-detected": "Не са открити промени", "save": "Запазване", - "saving": "Запазва се...", "audio-recorder": { "attachment-label": "Аудио запис", "attachment-label-with-time": "Аудио запис {{time}}", diff --git a/web/src/locales/ca.json b/web/src/locales/ca.json index 6b79967e..2f0c3bb9 100644 --- a/web/src/locales/ca.json +++ b/web/src/locales/ca.json @@ -133,7 +133,6 @@ }, "no-changes-detected": "No s'han detectat canvis", "save": "Guarda", - "saving": "Guardant...", "audio-recorder": { "attachment-label": "Gravació d'àudio", "attachment-label-with-time": "Gravació d'àudio {{time}}", diff --git a/web/src/locales/cs.json b/web/src/locales/cs.json index 304535bb..0b1a7a05 100644 --- a/web/src/locales/cs.json +++ b/web/src/locales/cs.json @@ -133,7 +133,6 @@ }, "no-changes-detected": "Nebyly zjištěny žádné změny", "save": "Uložit", - "saving": "Ukládání...", "audio-recorder": { "attachment-label": "Záznam zvuku", "attachment-label-with-time": "Záznam zvuku {{time}}", diff --git a/web/src/locales/da.json b/web/src/locales/da.json index 62e0cead..effc9d19 100644 --- a/web/src/locales/da.json +++ b/web/src/locales/da.json @@ -170,7 +170,6 @@ }, "no-changes-detected": "Ingen ændringer registreret", "save": "Spare", - "saving": "Gemmer...", "audio-recorder": { "attachment-label": "Lydoptagelse", "attachment-label-with-time": "Lydoptagelse {{time}}", diff --git a/web/src/locales/de.json b/web/src/locales/de.json index 26fa2da8..a0d26c0a 100644 --- a/web/src/locales/de.json +++ b/web/src/locales/de.json @@ -133,7 +133,6 @@ }, "no-changes-detected": "Keine Änderungen erkannt", "save": "Speichern", - "saving": "Speichern...", "audio-recorder": { "attachment-label": "Audioaufnahme", "attachment-label-with-time": "Audioaufnahme {{time}}", diff --git a/web/src/locales/el.json b/web/src/locales/el.json index c853cd97..4c3256d2 100644 --- a/web/src/locales/el.json +++ b/web/src/locales/el.json @@ -170,7 +170,6 @@ }, "no-changes-detected": "Δεν εντοπίστηκαν αλλαγές", "save": "Εκτός", - "saving": "Οικονομία...", "audio-recorder": { "attachment-label": "Ηχογράφηση", "attachment-label-with-time": "Εγγραφή ήχου {{time}}", diff --git a/web/src/locales/en-GB.json b/web/src/locales/en-GB.json index 7d443bea..45f31c1f 100644 --- a/web/src/locales/en-GB.json +++ b/web/src/locales/en-GB.json @@ -133,7 +133,6 @@ }, "no-changes-detected": "No changes detected", "save": "Save", - "saving": "Saving...", "audio-recorder": { "attachment-label": "Audio recording", "attachment-label-with-time": "Audio recording {{time}}", diff --git a/web/src/locales/en.json b/web/src/locales/en.json index 12df83bd..be2c43d0 100644 --- a/web/src/locales/en.json +++ b/web/src/locales/en.json @@ -237,6 +237,7 @@ "any-thoughts": "Any thoughts...", "exit-focus-mode": "Exit Focus Mode", "focus-mode": "Focus Mode", + "comment": "Comment", "formatting-toolbar": "Formatting toolbar", "format": { "heading": "Heading", @@ -272,7 +273,7 @@ "new-memo": "New memo", "no-changes-detected": "No changes detected", "save": "Save", - "saving": "Saving...", + "saved": "Saved", "validation": { "cannot-save": "Cannot save", "content-required": "Content, attachment, or file required", diff --git a/web/src/locales/es.json b/web/src/locales/es.json index 1fb81f2e..c3b9bed1 100644 --- a/web/src/locales/es.json +++ b/web/src/locales/es.json @@ -133,7 +133,6 @@ }, "no-changes-detected": "No se detectaron cambios", "save": "Guardar", - "saving": "Guardando...", "audio-recorder": { "attachment-label": "Grabación de audio", "attachment-label-with-time": "Grabación de audio {{time}}", diff --git a/web/src/locales/et.json b/web/src/locales/et.json index 2574272d..9c95f09d 100644 --- a/web/src/locales/et.json +++ b/web/src/locales/et.json @@ -170,7 +170,6 @@ }, "no-changes-detected": "Muudatusi ei tuvastatud", "save": "Salvesta", - "saving": "Salvestamine...", "audio-recorder": { "attachment-label": "Helisalvestus", "attachment-label-with-time": "Helisalvestus {{time}}", diff --git a/web/src/locales/fa.json b/web/src/locales/fa.json index 37d92b76..9415cbd3 100644 --- a/web/src/locales/fa.json +++ b/web/src/locales/fa.json @@ -125,7 +125,6 @@ "focus-mode": "حالت تمرکز", "no-changes-detected": "تغییری شناسایی نشد", "save": "ذخیره", - "saving": "در حال ذخیره...", "insert-menu": { "add-location": "اضافه کردن مکان", "link-memo": "پیوند یادداشت", diff --git a/web/src/locales/fi.json b/web/src/locales/fi.json index dcf7f908..550b4db3 100644 --- a/web/src/locales/fi.json +++ b/web/src/locales/fi.json @@ -170,7 +170,6 @@ }, "no-changes-detected": "Muutoksia ei havaittu", "save": "Tallentaa", - "saving": "Tallennetaan...", "audio-recorder": { "attachment-label": "Äänen tallennus", "attachment-label-with-time": "Äänen tallennus {{time}}", diff --git a/web/src/locales/fr.json b/web/src/locales/fr.json index 7bb36580..d5fbcbaa 100644 --- a/web/src/locales/fr.json +++ b/web/src/locales/fr.json @@ -133,7 +133,6 @@ }, "no-changes-detected": "Aucun changement détecté", "save": "Enregistrer", - "saving": "Enregistrement...", "audio-recorder": { "attachment-label": "Enregistrement audio", "attachment-label-with-time": "Enregistrement audio {{time}}", diff --git a/web/src/locales/gl.json b/web/src/locales/gl.json index 13a38689..6c40b026 100644 --- a/web/src/locales/gl.json +++ b/web/src/locales/gl.json @@ -133,7 +133,6 @@ }, "no-changes-detected": "Non se detectaron cambios", "save": "Gardar", - "saving": "Gardando...", "audio-recorder": { "attachment-label": "Gravación de audio", "attachment-label-with-time": "Gravación de audio {{time}}", diff --git a/web/src/locales/he.json b/web/src/locales/he.json index 4913c7f7..b50d846b 100644 --- a/web/src/locales/he.json +++ b/web/src/locales/he.json @@ -271,7 +271,6 @@ }, "no-changes-detected": "לא זוהו שינויים", "save": "שמור", - "saving": "שומר...", "validation": { "cannot-save": "לא ניתן לשמור", "content-required": "נדרש תוכן, קובץ מצורף או קובץ", diff --git a/web/src/locales/hi.json b/web/src/locales/hi.json index 7ebde120..fc076736 100644 --- a/web/src/locales/hi.json +++ b/web/src/locales/hi.json @@ -125,7 +125,6 @@ "focus-mode": "फोकस मोड", "no-changes-detected": "कोई बदलाव नहीं पाया गया", "save": "सहेजें", - "saving": "सहेज रहा है...", "insert-menu": { "add-location": "स्थान जोड़ें", "link-memo": "लिंक मेमो", diff --git a/web/src/locales/hr.json b/web/src/locales/hr.json index 16f8a8c5..54380c7e 100644 --- a/web/src/locales/hr.json +++ b/web/src/locales/hr.json @@ -133,7 +133,6 @@ }, "no-changes-detected": "Nema promjena", "save": "Sačuvaj", - "saving": "Spremanje...", "audio-recorder": { "attachment-label": "Audio snimanje", "attachment-label-with-time": "Audio snimak {{time}}", diff --git a/web/src/locales/hu.json b/web/src/locales/hu.json index fa0a7be5..ecfe84f8 100644 --- a/web/src/locales/hu.json +++ b/web/src/locales/hu.json @@ -133,7 +133,6 @@ }, "no-changes-detected": "Nincs változás", "save": "Mentés", - "saving": "Mentés...", "audio-recorder": { "attachment-label": "Hangfelvétel", "attachment-label-with-time": "Hangfelvétel {{time}}", diff --git a/web/src/locales/id.json b/web/src/locales/id.json index ed427df7..573a525d 100644 --- a/web/src/locales/id.json +++ b/web/src/locales/id.json @@ -125,7 +125,6 @@ "focus-mode": "Mode Fokus", "no-changes-detected": "Tidak ada perubahan yang terdeteksi", "save": "Simpan", - "saving": "Menyimpan...", "insert-menu": { "add-location": "Tambahkan lokasi", "link-memo": "Tautan memo", diff --git a/web/src/locales/it.json b/web/src/locales/it.json index 2d08cf8f..fd955e8b 100644 --- a/web/src/locales/it.json +++ b/web/src/locales/it.json @@ -133,7 +133,6 @@ }, "no-changes-detected": "Nessuna modifica rilevata", "save": "Salva", - "saving": "Salvataggio...", "audio-recorder": { "attachment-label": "Registrazione audio", "attachment-label-with-time": "Registrazione audio {{time}}", diff --git a/web/src/locales/ja.json b/web/src/locales/ja.json index 7af68316..cf9a0cf6 100644 --- a/web/src/locales/ja.json +++ b/web/src/locales/ja.json @@ -169,7 +169,6 @@ "formatting-toolbar": "書式ツールバー", "no-changes-detected": "変更はありません", "save": "保存", - "saving": "保存中...", "insert-menu": { "add-location": "場所を追加", "link-memo": "リンクメモ", diff --git a/web/src/locales/ka-GE.json b/web/src/locales/ka-GE.json index 5bfb0b00..34c9d344 100644 --- a/web/src/locales/ka-GE.json +++ b/web/src/locales/ka-GE.json @@ -133,7 +133,6 @@ }, "no-changes-detected": "ცვლილებები არ აღმოჩენილა", "save": "შენახვა", - "saving": "შენახვა...", "audio-recorder": { "attachment-label": "აუდიო ჩანაწერი", "attachment-label-with-time": "აუდიო ჩანაწერი {{time}}", diff --git a/web/src/locales/ko.json b/web/src/locales/ko.json index 668c8303..2efdbc80 100644 --- a/web/src/locales/ko.json +++ b/web/src/locales/ko.json @@ -125,7 +125,6 @@ "focus-mode": "집중 모드", "no-changes-detected": "변경사항이 없습니다", "save": "저장", - "saving": "저장 중...", "insert-menu": { "add-location": "위치 추가", "link-memo": "링크 메모", diff --git a/web/src/locales/lt.json b/web/src/locales/lt.json index 384241cc..8319a460 100644 --- a/web/src/locales/lt.json +++ b/web/src/locales/lt.json @@ -170,7 +170,6 @@ }, "no-changes-detected": "Pakeitimų neaptikta", "save": "Išsaugoti", - "saving": "Išsaugoma...", "audio-recorder": { "attachment-label": "Garso įrašymas", "attachment-label-with-time": "Garso įrašymas {{time}}", diff --git a/web/src/locales/lv.json b/web/src/locales/lv.json index 2c140cf8..e90cc56f 100644 --- a/web/src/locales/lv.json +++ b/web/src/locales/lv.json @@ -170,7 +170,6 @@ }, "no-changes-detected": "Izmaiņas nav konstatētas", "save": "Saglabāt", - "saving": "Notiek saglabāšana...", "audio-recorder": { "attachment-label": "Audio ieraksts", "attachment-label-with-time": "Audio ieraksts {{time}}", diff --git a/web/src/locales/mr.json b/web/src/locales/mr.json index 4fa83fef..d7066b29 100644 --- a/web/src/locales/mr.json +++ b/web/src/locales/mr.json @@ -125,7 +125,6 @@ "focus-mode": "फोकस मोड", "no-changes-detected": "कोणतेही बदल आढळले नाहीत", "save": "जतन", - "saving": "जतन होत आहे...", "insert-menu": { "add-location": "स्थान जोडा", "link-memo": "लिंक मेमो", diff --git a/web/src/locales/nb.json b/web/src/locales/nb.json index f04bcdfc..c07779ff 100644 --- a/web/src/locales/nb.json +++ b/web/src/locales/nb.json @@ -133,7 +133,6 @@ }, "no-changes-detected": "Ingen endringer oppdaget", "save": "Lagre", - "saving": "Lagrer...", "audio-recorder": { "attachment-label": "Lydopptak", "attachment-label-with-time": "Lydopptak {{time}}", diff --git a/web/src/locales/nl.json b/web/src/locales/nl.json index a0917ce6..c1c41670 100644 --- a/web/src/locales/nl.json +++ b/web/src/locales/nl.json @@ -133,7 +133,6 @@ }, "no-changes-detected": "Geen wijzigingen gedetecteerd", "save": "Opslaan", - "saving": "Opslaan...", "audio-recorder": { "attachment-label": "Audio-opname", "attachment-label-with-time": "Audio-opname {{time}}", diff --git a/web/src/locales/pl.json b/web/src/locales/pl.json index 3d95193d..cea28582 100644 --- a/web/src/locales/pl.json +++ b/web/src/locales/pl.json @@ -149,7 +149,6 @@ }, "no-changes-detected": "Brak wykrytych zmian", "save": "Zapisz", - "saving": "Zapisywanie...", "unsupported-syntax-raw-mode": "Ta notatka zawiera składnię, której edytor WYSIWYG nie może bezpiecznie edytować, więc otwarto go w trybie surowego Markdowna.", "wysiwyg-editor": "Edytor WYSIWYG", "audio-recorder": { diff --git a/web/src/locales/pt-BR.json b/web/src/locales/pt-BR.json index c24cd900..222b20f2 100644 --- a/web/src/locales/pt-BR.json +++ b/web/src/locales/pt-BR.json @@ -125,7 +125,6 @@ "focus-mode": "Modo Foco", "no-changes-detected": "Nenhuma alteração detectada", "save": "Salvar", - "saving": "Salvando…", "insert-menu": { "add-location": "Adicionar local", "link-memo": "Vincular memorando", diff --git a/web/src/locales/pt-PT.json b/web/src/locales/pt-PT.json index ee933782..8c01b92a 100644 --- a/web/src/locales/pt-PT.json +++ b/web/src/locales/pt-PT.json @@ -133,7 +133,6 @@ }, "no-changes-detected": "Nenhuma alteração detetada", "save": "Guardar", - "saving": "A guardar...", "audio-recorder": { "attachment-label": "Gravação de áudio", "attachment-label-with-time": "Gravação de áudio {{time}}", diff --git a/web/src/locales/ro.json b/web/src/locales/ro.json index ae0aab88..80b8d10b 100644 --- a/web/src/locales/ro.json +++ b/web/src/locales/ro.json @@ -170,7 +170,6 @@ }, "no-changes-detected": "Nu au fost detectate modificări", "save": "Salva", - "saving": "Economisire...", "audio-recorder": { "attachment-label": "Înregistrare audio", "attachment-label-with-time": "Înregistrare audio {{time}}", diff --git a/web/src/locales/ru.json b/web/src/locales/ru.json index e50b82c6..98e13394 100644 --- a/web/src/locales/ru.json +++ b/web/src/locales/ru.json @@ -183,7 +183,6 @@ }, "no-changes-detected": "Изменений не обнаружено", "save": "Сохранить", - "saving": "Сохранение...", "audio-recorder": { "attachment-label": "Аудиозапись", "attachment-label-with-time": "Аудиозапись {{time}}", diff --git a/web/src/locales/sk.json b/web/src/locales/sk.json index 3b921eb6..d67691e7 100644 --- a/web/src/locales/sk.json +++ b/web/src/locales/sk.json @@ -170,7 +170,6 @@ }, "no-changes-detected": "Nezistili sa žiadne zmeny", "save": "Uložiť", - "saving": "Ukladá sa...", "audio-recorder": { "attachment-label": "Zvukový záznam", "attachment-label-with-time": "Záznam zvuku {{time}}", diff --git a/web/src/locales/sl.json b/web/src/locales/sl.json index e1c3678f..26add484 100644 --- a/web/src/locales/sl.json +++ b/web/src/locales/sl.json @@ -133,7 +133,6 @@ }, "no-changes-detected": "Ni zaznanih sprememb", "save": "Shrani", - "saving": "Shranjujem...", "audio-recorder": { "attachment-label": "Zvočni posnetek", "attachment-label-with-time": "Zvočni posnetek {{time}}", diff --git a/web/src/locales/sr.json b/web/src/locales/sr.json index 57e27992..7dd14544 100644 --- a/web/src/locales/sr.json +++ b/web/src/locales/sr.json @@ -170,7 +170,6 @@ }, "no-changes-detected": "Нису откривене промене", "save": "Сачувај", - "saving": "Чување...", "audio-recorder": { "attachment-label": "Аудио снимак", "attachment-label-with-time": "Аудио запис {{time}}", diff --git a/web/src/locales/sv.json b/web/src/locales/sv.json index e40f24ef..a8b6fe48 100644 --- a/web/src/locales/sv.json +++ b/web/src/locales/sv.json @@ -133,7 +133,6 @@ }, "no-changes-detected": "Inga ändringar upptäckta", "save": "Spara", - "saving": "Sparar...", "audio-recorder": { "attachment-label": "Ljudinspelning", "attachment-label-with-time": "Ljudinspelning {{time}}", diff --git a/web/src/locales/th.json b/web/src/locales/th.json index d40e2a82..3af400d3 100644 --- a/web/src/locales/th.json +++ b/web/src/locales/th.json @@ -125,7 +125,6 @@ "focus-mode": "โหมดโฟกัส", "no-changes-detected": "ไม่มีการเปลี่ยนแปลง", "save": "บันทึก", - "saving": "กำลังบันทึก...", "insert-menu": { "add-location": "เพิ่มสถานที่", "link-memo": "บันทึกการเชื่อมโยง", diff --git a/web/src/locales/tr.json b/web/src/locales/tr.json index b12dab9e..cfb699e6 100644 --- a/web/src/locales/tr.json +++ b/web/src/locales/tr.json @@ -133,7 +133,6 @@ }, "no-changes-detected": "Değişiklik yok", "save": "Kaydet", - "saving": "Kaydediliyor...", "audio-recorder": { "attachment-label": "Ses kaydı", "attachment-label-with-time": "Ses kaydı {{time}}", diff --git a/web/src/locales/uk.json b/web/src/locales/uk.json index e46766a5..04361faf 100644 --- a/web/src/locales/uk.json +++ b/web/src/locales/uk.json @@ -133,7 +133,6 @@ }, "no-changes-detected": "Змін не виявлено", "save": "Зберегти", - "saving": "Збереження...", "audio-recorder": { "attachment-label": "Аудіозапис", "attachment-label-with-time": "Аудіозапис {{time}}", diff --git a/web/src/locales/vi.json b/web/src/locales/vi.json index bfdda122..0e24be29 100644 --- a/web/src/locales/vi.json +++ b/web/src/locales/vi.json @@ -125,7 +125,6 @@ "focus-mode": "Chế độ tập trung", "no-changes-detected": "Không phát hiện thay đổi", "save": "Lưu", - "saving": "Đang lưu...", "insert-menu": { "add-location": "Thêm vị trí", "link-memo": "Liên kết bản ghi nhớ", diff --git a/web/src/locales/zh-Hans.json b/web/src/locales/zh-Hans.json index 54df922c..bfdafcc5 100644 --- a/web/src/locales/zh-Hans.json +++ b/web/src/locales/zh-Hans.json @@ -190,7 +190,6 @@ "new-memo": "新建备忘录", "no-changes-detected": "未检测到更改", "save": "保存", - "saving": "保存中...", "validation": { "cannot-save": "无法保存", "content-required": "需要填写正文或添加附件", diff --git a/web/src/locales/zh-Hant.json b/web/src/locales/zh-Hant.json index d71dfd89..b09ef40f 100644 --- a/web/src/locales/zh-Hant.json +++ b/web/src/locales/zh-Hant.json @@ -274,7 +274,6 @@ "new-memo": "新增備忘錄", "no-changes-detected": "未發現變更", "save": "儲存", - "saving": "儲存中...", "validation": { "cannot-save": "無法儲存", "content-required": "需要填寫正文或新增附件", diff --git a/web/src/utils/platform.ts b/web/src/utils/platform.ts new file mode 100644 index 00000000..2319920b --- /dev/null +++ b/web/src/utils/platform.ts @@ -0,0 +1,19 @@ +interface NavigatorWithUAData extends Navigator { + userAgentData?: { platform?: string }; +} + +/** + * Whether the primary modifier key is ⌘ (Apple platforms) rather than Ctrl. + * Used only to render shortcut hints; key handling itself is platform-agnostic. + */ +export function isApplePlatform(): boolean { + if (typeof navigator === "undefined") return false; + const nav = navigator as NavigatorWithUAData; + const platform = nav.userAgentData?.platform ?? nav.platform ?? ""; + return /mac|iphone|ipad|ipod/i.test(platform); +} + +/** Display glyph for the primary modifier: ⌘ on Apple platforms, Ctrl elsewhere. */ +export function primaryModifierGlyph(): string { + return isApplePlatform() ? "⌘" : "Ctrl"; +} diff --git a/web/tests/use-memo-save.test.tsx b/web/tests/use-memo-save.test.tsx index 283aa269..8bd148ee 100644 --- a/web/tests/use-memo-save.test.tsx +++ b/web/tests/use-memo-save.test.tsx @@ -21,11 +21,12 @@ vi.mock("@/components/MemoEditor/state", () => ({ actions: { reset: () => ({ type: "reset" }), setLoading: (key: string, value: boolean) => ({ type: "set-loading", key, value }), + setJustSaved: (value: boolean) => ({ type: "set-just-saved", value }), setMetadata: () => ({ type: "set-metadata" }), setTimestamps: () => ({ type: "set-timestamps" }), }, dispatch: mocks.dispatch, - getState: () => ({}), + getState: () => ({ ui: { justSaved: false } }), }), })); @@ -71,4 +72,33 @@ describe("useMemoSave", () => { expect(invalidateQueries).toHaveBeenCalledWith({ queryKey: ["memos", "comments", "memos/parent"] }); expect(invalidateQueries).toHaveBeenCalledWith({ queryKey: ["memos", "detail", "memos/parent"] }); }); + + it("holds a saved confirmation before a closing host resets", async () => { + mocks.memoSave.mockResolvedValue({ hasChanges: true, memoName: "memos/existing" }); + const queryClient = new QueryClient({ defaultOptions: { queries: { retry: false } } }); + const wrapper = ({ children }: PropsWithChildren) => {children}; + const onConfirm = vi.fn(); + const { result } = renderHook(() => useMemoSave({ memoName: "memos/existing", discardDraft: vi.fn(), onConfirm }), { wrapper }); + + await act(async () => result.current()); + + const types = mocks.dispatch.mock.calls.map(([action]) => action); + const savedOn = types.findIndex((a) => a.type === "set-just-saved" && a.value === true); + const reset = types.findIndex((a) => a.type === "reset"); + expect(savedOn).toBeGreaterThan(-1); + expect(reset).toBeGreaterThan(savedOn); + expect(onConfirm).toHaveBeenCalledWith("memos/existing"); + }); + + it("does not hold the in-place composer after saving a new memo", async () => { + mocks.memoSave.mockResolvedValue({ hasChanges: true, memoName: "memos/new" }); + const queryClient = new QueryClient({ defaultOptions: { queries: { retry: false } } }); + const wrapper = ({ children }: PropsWithChildren) => {children}; + const { result } = renderHook(() => useMemoSave({ discardDraft: vi.fn() }), { wrapper }); + + await act(async () => result.current()); + + const savedOn = mocks.dispatch.mock.calls.some(([action]) => action.type === "set-just-saved" && action.value === true); + expect(savedOn).toBe(false); + }); });