fix(sync): show last push time as the last sync time (#3760)

This commit is contained in:
Huang Xin
2026-04-05 23:55:41 +08:00
committed by GitHub
parent 8b10e7fb17
commit 09d1e0c040
3 changed files with 19 additions and 4 deletions
@@ -157,7 +157,12 @@ const ViewMenu: React.FC<ViewMenuProps> = ({ bookKey, setIsDropdownOpen }) => {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [keepCoverSpread]);
const lastSyncTime = Math.max(config?.lastSyncedAtConfig || 0, config?.lastSyncedAtNotes || 0);
const lastSyncTime = Math.max(
config?.lastSyncedAtConfig || 0,
config?.lastSyncedAtNotes || 0,
config?.lastPushedAtConfig || 0,
config?.lastPushedAtNotes || 0,
);
return (
<Menu
+11 -3
View File
@@ -160,13 +160,14 @@ export function useSync(bookKey?: string) {
}
};
const pushChanges = async (payload: SyncData) => {
const pushChanges = async (payload: SyncData): Promise<boolean> => {
setSyncing(true);
setSyncError(null);
try {
const result = await syncClient.pushChanges(payload);
setSyncResult(result);
return true;
} catch (err: unknown) {
console.error(err);
if (err instanceof Error) {
@@ -174,6 +175,7 @@ export function useSync(bookKey?: string) {
} else {
setSyncError('Error pushing changes');
}
return false;
} finally {
setSyncing(false);
}
@@ -203,7 +205,10 @@ export function useSync(bookKey?: string) {
async (bookConfigs?: BookConfig[], bookId?: string, metaHash?: string, op: SyncOp = 'both') => {
if (!bookId && !lastSyncedAtInited) return;
if ((op === 'push' || op === 'both') && bookConfigs?.length) {
await pushChanges({ configs: bookConfigs });
const pushed = await pushChanges({ configs: bookConfigs });
if (pushed && bookId && bookKey) {
setConfig(bookKey, { lastPushedAtConfig: Date.now() });
}
}
if (op === 'pull' || op === 'both') {
await pullChanges(
@@ -224,7 +229,10 @@ export function useSync(bookKey?: string) {
async (bookNotes?: BookNote[], bookId?: string, metaHash?: string, op: SyncOp = 'both') => {
if (!lastSyncedAtInited) return;
if ((op === 'push' || op === 'both') && bookNotes?.length) {
await pushChanges({ notes: bookNotes });
const pushed = await pushChanges({ notes: bookNotes });
if (pushed && bookId && bookKey) {
setConfig(bookKey, { lastPushedAtNotes: Date.now() });
}
}
if (op === 'pull' || op === 'both') {
await pullChanges(
+2
View File
@@ -372,6 +372,8 @@ export interface BookConfig {
lastSyncedAtConfig?: number;
lastSyncedAtNotes?: number;
lastPushedAtConfig?: number;
lastPushedAtNotes?: number;
foliateImportedAt?: number;
// Per-book switch for hardcover exports in reader menu.