diff --git a/packages/app-client/src/modules/config/config.constants.ts b/packages/app-client/src/modules/config/config.constants.ts index 00867a77..6e26e949 100644 --- a/packages/app-client/src/modules/config/config.constants.ts +++ b/packages/app-client/src/modules/config/config.constants.ts @@ -5,4 +5,5 @@ export const buildTimeConfig: Config = { documentationBaseUrl: import.meta.env.VITE_DOCUMENTATION_BASE_URL ?? 'https://docs.enclosed.cc', enclosedVersion: import.meta.env.VITE_ENCLOSED_VERSION ?? '0.0.0', isAuthenticationRequired: import.meta.env.VITE_IS_AUTHENTICATION_REQUIRED === 'true', + defaultDeleteNoteAfterReading: import.meta.env.VITE_DEFAULT_DELETE_NOTE_AFTER_READING === 'true', }; diff --git a/packages/app-client/src/modules/config/config.types.ts b/packages/app-client/src/modules/config/config.types.ts index 243dacd6..05826faf 100644 --- a/packages/app-client/src/modules/config/config.types.ts +++ b/packages/app-client/src/modules/config/config.types.ts @@ -3,4 +3,5 @@ export type Config = { documentationBaseUrl: string; isAuthenticationRequired: boolean; enclosedVersion: string; + defaultDeleteNoteAfterReading: boolean; }; diff --git a/packages/app-client/src/modules/notes/pages/create-note.page.tsx b/packages/app-client/src/modules/notes/pages/create-note.page.tsx index a703ad07..a28a0389 100644 --- a/packages/app-client/src/modules/notes/pages/create-note.page.tsx +++ b/packages/app-client/src/modules/notes/pages/create-note.page.tsx @@ -20,6 +20,11 @@ import { useNoteContext } from '../notes.context'; import { encryptAndCreateNote } from '../notes.usecases'; export const CreateNotePage: Component = () => { + const config = getConfig(); + const { t } = useI18n(); + const navigate = useNavigate(); + const { onResetNoteForm, removeResetNoteFormHandler } = useNoteContext(); + const [getContent, setContent] = createSignal(''); const [getPassword, setPassword] = createSignal(''); const [getNoteUrl, setNoteUrl] = createSignal(''); @@ -27,17 +32,10 @@ export const CreateNotePage: Component = () => { const [getIsNoteCreated, setIsNoteCreated] = createSignal(false); const [getIsPublic, setIsPublic] = createSignal(true); const [getTtlInSeconds, setTtlInSeconds] = createSignal(3600); - const [getDeleteAfterReading, setDeleteAfterReading] = createSignal(false); + const [getDeleteAfterReading, setDeleteAfterReading] = createSignal(config.defaultDeleteNoteAfterReading); const [getUploadedFiles, setUploadedFiles] = createSignal([]); const [getIsNoteCreating, setIsNoteCreating] = createSignal(false); - const { t } = useI18n(); - - const config = getConfig(); - const navigate = useNavigate(); - - const { onResetNoteForm, removeResetNoteFormHandler } = useNoteContext(); - function resetNoteForm() { setContent(''); setPassword(''); diff --git a/packages/app-server/src/modules/app/config/config.ts b/packages/app-server/src/modules/app/config/config.ts index 549a0c81..673c81ac 100644 --- a/packages/app-server/src/modules/app/config/config.ts +++ b/packages/app-server/src/modules/app/config/config.ts @@ -110,6 +110,17 @@ export const configDefinition = { default: 'false', env: 'PUBLIC_IS_AUTHENTICATION_REQUIRED', }, + defaultDeleteNoteAfterReading: { + doc: 'The default value for the `Delete note after reading` checkbox in the note creation form', + schema: z + .string() + .trim() + .toLowerCase() + .transform(x => x === 'true') + .pipe(z.boolean()), + default: 'false', + env: 'PUBLIC_DEFAULT_DELETE_NOTE_AFTER_READING', + }, }, authentication: { jwtSecret: {