Накатил человеческий дизайн

This commit is contained in:
mi
2026-07-21 16:01:24 +03:00
parent 9cfc157124
commit 627371b221
35 changed files with 2415 additions and 293 deletions
@@ -0,0 +1,50 @@
export type PendingTextIntent = {
text: string;
dialogKey: string;
messageKey: string;
};
const STORAGE_KEY = "han.pending-message";
export function createPendingTextIntent(text: string): PendingTextIntent {
return {
text,
dialogKey: crypto.randomUUID(),
messageKey: crypto.randomUUID(),
};
}
export function savePendingTextIntent(intent: PendingTextIntent) {
if (typeof window !== "undefined") {
window.sessionStorage.setItem(STORAGE_KEY, JSON.stringify(intent));
}
}
export function loadPendingTextIntent(): PendingTextIntent | null {
if (typeof window === "undefined") return null;
const raw = window.sessionStorage.getItem(STORAGE_KEY);
if (!raw) return null;
try {
const value = JSON.parse(raw) as Partial<PendingTextIntent>;
if (
typeof value.text !== "string"
|| typeof value.dialogKey !== "string"
|| typeof value.messageKey !== "string"
) {
return null;
}
return {
text: value.text,
dialogKey: value.dialogKey,
messageKey: value.messageKey,
};
} catch {
return null;
}
}
export function clearPendingTextIntent() {
if (typeof window !== "undefined") {
window.sessionStorage.removeItem(STORAGE_KEY);
}
}