forked from akai/readest
981579c255
* refactor(sync): kind-agnostic replica primitives Extract dict-only sync into shared primitives (registry, pull/apply orchestrator, persist env, schema allowlist) so other kinds can plug in. Companion changes: per-replica Storage Manager grouping, useReplicaPull boot-race recovery, manifest=null reconciliation on every boot pull, copyFile takes explicit srcBase + dstBase, settled- event helpers, lenient webDownload Content-Length (R2/S3 signed URLs commonly omit it), and generic "File" transfer toast copy any replica kind can share. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * feat(sync): cross-device custom font sync Plug the font replica adapter into the kind-agnostic primitives: font store gains replica wiring, custom font import publishes the replica row + queues a binary upload, and bootstrap registers the font adapter and download-complete handler. Includes legacy flat-path migration so pre-existing fonts sync without re-import, full @font-face activation on auto-download (load + mount the rule, mirroring manual import), and a fix to createCustomFont so contentId / bundleDir / byteSize survive the trip through addFont — otherwise import-time publish silently no-oped on missing contentId. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
50 lines
1.7 KiB
TypeScript
50 lines
1.7 KiB
TypeScript
import type { TransferItem } from '@/store/transferStore';
|
|
import type { TranslationFunc } from '@/hooks/useTranslation';
|
|
|
|
export interface TransferMessages {
|
|
success: { upload: string; download: string; delete: string };
|
|
failure: { upload: string; download: string; delete: string };
|
|
}
|
|
|
|
/**
|
|
* Build per-kind toast copy for a TransferItem. Books keep their own
|
|
* copy ("Book uploaded"); everything else — replica kinds (dictionary,
|
|
* font, textures, OPDS catalogs, …) and any future transfer kind —
|
|
* falls through to the generic "File uploaded" string so we don't have
|
|
* to add a per-kind branch each time.
|
|
*/
|
|
export const getTransferMessages = (
|
|
transfer: TransferItem,
|
|
_: TranslationFunc,
|
|
): TransferMessages => {
|
|
const title = transfer.bookTitle;
|
|
|
|
if (transfer.kind === 'book') {
|
|
return {
|
|
success: {
|
|
upload: _('Book uploaded: {{title}}', { title }),
|
|
download: _('Book downloaded: {{title}}', { title }),
|
|
delete: _('Deleted cloud backup of the book: {{title}}', { title }),
|
|
},
|
|
failure: {
|
|
upload: _('Failed to upload book: {{title}}', { title }),
|
|
download: _('Failed to download book: {{title}}', { title }),
|
|
delete: _('Failed to delete cloud backup of the book: {{title}}', { title }),
|
|
},
|
|
};
|
|
}
|
|
|
|
return {
|
|
success: {
|
|
upload: _('File uploaded: {{title}}', { title }),
|
|
download: _('File downloaded: {{title}}', { title }),
|
|
delete: _('Deleted cloud copy of the file: {{title}}', { title }),
|
|
},
|
|
failure: {
|
|
upload: _('Failed to upload file: {{title}}', { title }),
|
|
download: _('Failed to download file: {{title}}', { title }),
|
|
delete: _('Failed to delete cloud copy of the file: {{title}}', { title }),
|
|
},
|
|
};
|
|
};
|