1
This commit is contained in:
@@ -22,14 +22,22 @@ import {
|
||||
resumeRpgProfileSaveArchive,
|
||||
upsertRpgProfileBrowseHistory,
|
||||
} from '../../services/rpg-entry';
|
||||
import {
|
||||
RUNTIME_BACKGROUND_AUTH_OPTIONS,
|
||||
type RuntimeRequestOptions,
|
||||
} from '../../services/rpg-runtime/rpgRuntimeRequest';
|
||||
import type { CustomWorldProfile } from '../../types';
|
||||
import type { PlatformHomeTab } from './RpgEntryHomeView';
|
||||
import { resolveRpgEntryErrorMessage } from './rpgEntryShared';
|
||||
|
||||
const PLATFORM_BOOTSTRAP_AUTH_OPTIONS = RUNTIME_BACKGROUND_AUTH_OPTIONS;
|
||||
|
||||
type UseRpgEntryBootstrapParams = {
|
||||
user: AuthUser | null | undefined;
|
||||
canAccessProtectedData?: boolean | undefined;
|
||||
getProfileDashboard: () => Promise<ProfileDashboardSummary | null>;
|
||||
getProfileDashboard: (
|
||||
options?: RuntimeRequestOptions,
|
||||
) => Promise<ProfileDashboardSummary | null>;
|
||||
handleContinueGame: (
|
||||
snapshot?: HydratedSavedGameSnapshot | null,
|
||||
) => void;
|
||||
@@ -99,7 +107,9 @@ export function useRpgEntryBootstrap(
|
||||
setDashboardError(null);
|
||||
|
||||
try {
|
||||
setProfileDashboard(await getProfileDashboard());
|
||||
setProfileDashboard(
|
||||
await getProfileDashboard(PLATFORM_BOOTSTRAP_AUTH_OPTIONS),
|
||||
);
|
||||
} catch (error) {
|
||||
setDashboardError(
|
||||
resolveRpgEntryErrorMessage(error, '读取个人数据看板失败。'),
|
||||
@@ -115,7 +125,9 @@ export function useRpgEntryBootstrap(
|
||||
return [];
|
||||
}
|
||||
|
||||
const nextItems = await listRpgCreationWorks();
|
||||
const nextItems = await listRpgCreationWorks(
|
||||
PLATFORM_BOOTSTRAP_AUTH_OPTIONS,
|
||||
);
|
||||
setCustomWorldWorkEntries(nextItems);
|
||||
return nextItems;
|
||||
}, [canReadProtectedData, user]);
|
||||
@@ -132,7 +144,9 @@ export function useRpgEntryBootstrap(
|
||||
return [];
|
||||
}
|
||||
|
||||
const nextEntries = await listRpgEntryWorldLibrary();
|
||||
const nextEntries = await listRpgEntryWorldLibrary(
|
||||
PLATFORM_BOOTSTRAP_AUTH_OPTIONS,
|
||||
);
|
||||
setSavedCustomWorldEntries(nextEntries);
|
||||
return nextEntries;
|
||||
}, [canReadProtectedData, user]);
|
||||
@@ -147,7 +161,9 @@ export function useRpgEntryBootstrap(
|
||||
setSaveError(null);
|
||||
|
||||
try {
|
||||
const nextEntries = await listRpgProfileSaveArchives();
|
||||
const nextEntries = await listRpgProfileSaveArchives(
|
||||
PLATFORM_BOOTSTRAP_AUTH_OPTIONS,
|
||||
);
|
||||
setSaveEntries(nextEntries);
|
||||
return nextEntries;
|
||||
} catch (error) {
|
||||
@@ -161,7 +177,10 @@ export function useRpgEntryBootstrap(
|
||||
setHistoryError(null);
|
||||
|
||||
try {
|
||||
const syncedEntries = await upsertRpgProfileBrowseHistory(entry);
|
||||
const syncedEntries = await upsertRpgProfileBrowseHistory(
|
||||
entry,
|
||||
PLATFORM_BOOTSTRAP_AUTH_OPTIONS,
|
||||
);
|
||||
setHistoryEntries(syncedEntries);
|
||||
} catch (error) {
|
||||
setHistoryError(
|
||||
@@ -237,18 +256,20 @@ export function useRpgEntryBootstrap(
|
||||
saveArchivesResult,
|
||||
] = await Promise.allSettled([
|
||||
canReadProtectedData
|
||||
? listRpgEntryWorldLibrary()
|
||||
? listRpgEntryWorldLibrary(PLATFORM_BOOTSTRAP_AUTH_OPTIONS)
|
||||
: Promise.resolve([]),
|
||||
canReadProtectedData
|
||||
? listRpgCreationWorks()
|
||||
? listRpgCreationWorks(PLATFORM_BOOTSTRAP_AUTH_OPTIONS)
|
||||
: Promise.resolve([]),
|
||||
listRpgEntryWorldGallery(),
|
||||
canReadProtectedData ? getProfileDashboard() : Promise.resolve(null),
|
||||
canReadProtectedData
|
||||
? listRpgProfileBrowseHistory()
|
||||
? getProfileDashboard(PLATFORM_BOOTSTRAP_AUTH_OPTIONS)
|
||||
: Promise.resolve(null),
|
||||
canReadProtectedData
|
||||
? listRpgProfileBrowseHistory(PLATFORM_BOOTSTRAP_AUTH_OPTIONS)
|
||||
: Promise.resolve([]),
|
||||
canReadProtectedData
|
||||
? listRpgProfileSaveArchives()
|
||||
? listRpgProfileSaveArchives(PLATFORM_BOOTSTRAP_AUTH_OPTIONS)
|
||||
: Promise.resolve([]),
|
||||
]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user