Support save archives and copy transfers
This commit is contained in:
1 parent
d19baec90b
commit
c957cecee4
19 files changed
+660
-25
No files matched your search
@@ -10,7 +10,9 @@ export type SaveTask = Location & (
|
||||
| { readonly operation: 'list' }
|
||||
| { readonly operation: 'details'; readonly userId: string }
|
||||
| { readonly operation: 'edit'; readonly userId: string; readonly values: CurrencyEdits }
|
||||
| { readonly operation: 'remove'; readonly userId: string }
|
||||
| { readonly operation: 'filter'; readonly profile: Uint8Array; readonly filter: boolean }
|
||||
| { readonly operation: 'create'; readonly login: string; readonly password: string; readonly nick: string }
|
||||
);
|
||||
export type SaveResult = SaveList['saves'] | SaveDetails | { userId: string } | null;
|
||||
export type SaveResult = SaveList['saves'] | SaveDetails | { userId: string } | Uint8Array | null;
|
||||
export type SaveReply = { ok: true; result: SaveResult } | { ok: false; error: AppErrorCode };
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { MessageEvent } from 'electron';
|
||||
import { AccountStore, editSaveCurrencies, listSaveSummaries, readSaveDetails } from '@wto/server';
|
||||
import { AccountStore, editSaveCurrencies, listSaveSummaries, prepareTransferredProfile, readSaveDetails } from '@wto/server';
|
||||
import type { SaveTask, SaveReply } from './save-protocol.ts';
|
||||
|
||||
function execute(task: SaveTask): SaveReply {
|
||||
@@ -13,6 +13,11 @@ function execute(task: SaveTask): SaveReply {
|
||||
case 'edit':
|
||||
return editSaveCurrencies(task, task.userId, task.values)
|
||||
? { ok: true, result: null } : { ok: false, error: 'save_not_found' };
|
||||
case 'remove':
|
||||
return new AccountStore(task.dataFolder).remove(task.userId)
|
||||
? { ok: true, result: null } : { ok: false, error: 'save_not_found' };
|
||||
case 'filter':
|
||||
return { ok: true, result: prepareTransferredProfile(task, task.profile, task.filter) };
|
||||
case 'create': {
|
||||
const result = new AccountStore(task.dataFolder).register(task.login, task.password, task.nick);
|
||||
switch (result.kind) {
|
||||
|
||||
Reference in new issue
Block a user