[tauri] KeepHerSafeApps: App words for Keep her safe, and Android's own save screen through a narrow bridge
This commit is contained in:
@@ -83,7 +83,11 @@ export const en = {
|
||||
ask: 'Ask the browser to keep her',
|
||||
refused: 'The browser did not promise. A saved file keeps her for sure.',
|
||||
install: 'On an iPhone or iPad, add the garden to your Home Screen to keep her.',
|
||||
/** In the Android, iOS and desktop apps (keep-her-safe-apps.md A1): no browser, and nothing clears her for being left alone. */
|
||||
app: 'She lives in this app, on this device, until the app is removed. A saved file keeps her anywhere.',
|
||||
save: 'Save her to a file',
|
||||
/** Said only when the app knows the file was written (A4); a cancelled save is not commented on. */
|
||||
saved: 'She is in that file now.',
|
||||
fileNote: 'The file holds her care and when it was given. It never holds your town.',
|
||||
bringBack: 'Bring her back from a file',
|
||||
broughtBack: (n: number): string =>
|
||||
|
||||
@@ -14,7 +14,11 @@
|
||||
let refused = $state(false);
|
||||
let said = $state('');
|
||||
|
||||
const inApp = $derived(wiring.keeping.where === 'app');
|
||||
|
||||
$effect(() => {
|
||||
// In an app there is no browser to ask, and the answer would always be no (A1).
|
||||
if (inApp) return;
|
||||
wiring.keeping.persisted().then(
|
||||
(p) => (persisted = p),
|
||||
(error: unknown) => {
|
||||
@@ -38,7 +42,9 @@
|
||||
async function save(): Promise<void> {
|
||||
try {
|
||||
const file = await wiring.exportRose(currentKey);
|
||||
wiring.saveFile(`rose-${today}.json`, JSON.stringify(file, null, 1));
|
||||
said = '';
|
||||
const written = await wiring.saveFile(`rose-${today}.json`, JSON.stringify(file, null, 1));
|
||||
if (written === true) said = en.rose.safe.saved;
|
||||
} catch (error) {
|
||||
console.error('keep: the rose could not be saved to a file', error);
|
||||
}
|
||||
@@ -64,13 +70,15 @@
|
||||
|
||||
<section class="safe" aria-labelledby="{uid}-title">
|
||||
<h3 id="{uid}-title">{en.rose.safe.title}</h3>
|
||||
{#if persisted !== undefined}
|
||||
{#if inApp}
|
||||
<p>{en.rose.safe.app}</p>
|
||||
{:else if persisted !== undefined}
|
||||
<p>{refused ? en.rose.safe.refused : persisted === true ? en.rose.safe.kept : persisted === false ? en.rose.safe.mayClear : en.rose.safe.unknown}</p>
|
||||
{/if}
|
||||
{#if persisted === false && !refused}
|
||||
{#if !inApp && persisted === false && !refused}
|
||||
<button type="button" class="quiet" onclick={ask}>{en.rose.safe.ask}</button>
|
||||
{/if}
|
||||
{#if wiring.installHint}
|
||||
{#if !inApp && wiring.installHint}
|
||||
<p>{en.rose.safe.install}</p>
|
||||
{/if}
|
||||
|
||||
|
||||
@@ -30,10 +30,20 @@ export interface RoseWiring {
|
||||
};
|
||||
/** Hears care, a petal or a rose brought back in another tab (two-tabs.md); returns the way to stop. */
|
||||
readonly changes?: (listener: () => void) => () => void;
|
||||
/** Hands the player a file to keep. */
|
||||
readonly saveFile: (name: string, text: string) => void;
|
||||
/**
|
||||
* Hands the player a file to keep. Where the app learns the outcome (Android's save screen,
|
||||
* keep-her-safe-apps.md A4) it answers true when written and false when the player stepped back;
|
||||
* where it cannot know (a browser download) it answers nothing.
|
||||
*/
|
||||
readonly saveFile: (name: string, text: string) => void | Promise<boolean>;
|
||||
/** The browser's promise to keep the garden: true, false, or null when it cannot say. */
|
||||
readonly keeping: {
|
||||
/**
|
||||
* Where she lives (keep-her-safe-apps.md A1): `'browser'` (the default) or `'app'`, the
|
||||
* Android, iOS and desktop apps, where there is no browser to ask and nothing clears her
|
||||
* for being left alone.
|
||||
*/
|
||||
readonly where?: 'browser' | 'app';
|
||||
readonly persisted: () => Promise<boolean | null>;
|
||||
readonly persist: () => Promise<boolean | null>;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user