forked from akai/readest
refactor: rename ConfirmSyncDialog to KOSyncResolver (#1937)
This commit is contained in:
@@ -46,7 +46,7 @@ import { useTextTranslation } from '../hooks/useTextTranslation';
|
||||
import { manageSyntaxHighlighting } from '@/utils/highlightjs';
|
||||
import { getViewInsets } from '@/utils/insets';
|
||||
import Spinner from '@/components/Spinner';
|
||||
import ConfirmSyncDialog from './ConfirmSyncDialog';
|
||||
import KOSyncConflictResolver from './KOSyncResolver';
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
@@ -86,8 +86,7 @@ const FoliateViewer: React.FC<{
|
||||
useUICSS(bookKey);
|
||||
useProgressSync(bookKey);
|
||||
useProgressAutoSave(bookKey);
|
||||
const { syncState, conflictDetails, resolveConflictWithLocal, resolveConflictWithRemote } =
|
||||
useKOSync(bookKey);
|
||||
const { syncState, conflictDetails, resolveWithLocal, resolveWithRemote } = useKOSync(bookKey);
|
||||
useTextTranslation(bookKey, viewRef.current);
|
||||
|
||||
const progressRelocateHandler = (event: Event) => {
|
||||
@@ -392,11 +391,11 @@ const FoliateViewer: React.FC<{
|
||||
/>
|
||||
{!docLoaded.current && loading && <Spinner loading={true} />}
|
||||
{syncState === 'conflict' && conflictDetails && (
|
||||
<ConfirmSyncDialog
|
||||
<KOSyncConflictResolver
|
||||
details={conflictDetails}
|
||||
onConfirmLocal={resolveConflictWithLocal}
|
||||
onConfirmRemote={resolveConflictWithRemote}
|
||||
onClose={resolveConflictWithLocal}
|
||||
onResolveWithLocal={resolveWithLocal}
|
||||
onResolveWithRemote={resolveWithRemote}
|
||||
onClose={resolveWithLocal}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
|
||||
+12
-9
@@ -3,17 +3,17 @@ import Dialog from '@/components/Dialog';
|
||||
import { useTranslation } from '@/hooks/useTranslation';
|
||||
import { SyncDetails } from '../hooks/useKOSync';
|
||||
|
||||
interface ConfirmSyncDialogProps {
|
||||
interface KOSyncConflictResolverProps {
|
||||
details: SyncDetails | null;
|
||||
onConfirmLocal: () => void;
|
||||
onConfirmRemote: () => void;
|
||||
onResolveWithLocal: () => void;
|
||||
onResolveWithRemote: () => void;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
const ConfirmSyncDialog: React.FC<ConfirmSyncDialogProps> = ({
|
||||
const KOSyncConflictResolver: React.FC<KOSyncConflictResolverProps> = ({
|
||||
details,
|
||||
onConfirmLocal,
|
||||
onConfirmRemote,
|
||||
onResolveWithLocal,
|
||||
onResolveWithRemote,
|
||||
onClose,
|
||||
}) => {
|
||||
const _ = useTranslation();
|
||||
@@ -28,7 +28,10 @@ const ConfirmSyncDialog: React.FC<ConfirmSyncDialogProps> = ({
|
||||
})}
|
||||
</p>
|
||||
<div className='mt-4 space-y-4'>
|
||||
<button className='btn h-auto w-full flex-col items-start py-2' onClick={onConfirmLocal}>
|
||||
<button
|
||||
className='btn h-auto w-full flex-col items-start py-2'
|
||||
onClick={onResolveWithLocal}
|
||||
>
|
||||
<span>{_('Local Progress')}</span>
|
||||
<span className='text-xs font-normal normal-case text-gray-500'>
|
||||
{details.local.preview}
|
||||
@@ -36,7 +39,7 @@ const ConfirmSyncDialog: React.FC<ConfirmSyncDialogProps> = ({
|
||||
</button>
|
||||
<button
|
||||
className='btn btn-primary h-auto w-full flex-col items-start py-2'
|
||||
onClick={onConfirmRemote}
|
||||
onClick={onResolveWithRemote}
|
||||
>
|
||||
<span>{_('Remote Progress')}</span>
|
||||
<span className='text-xs font-normal normal-case'>{details.remote.preview}</span>
|
||||
@@ -46,4 +49,4 @@ const ConfirmSyncDialog: React.FC<ConfirmSyncDialogProps> = ({
|
||||
);
|
||||
};
|
||||
|
||||
export default ConfirmSyncDialog;
|
||||
export default KOSyncConflictResolver;
|
||||
@@ -285,14 +285,14 @@ export const useKOSync = (bookKey: string) => {
|
||||
}
|
||||
}, [progress, syncState, settings.kosync, pushProgress]);
|
||||
|
||||
const resolveConflictWithLocal = () => {
|
||||
const resolveWithLocal = () => {
|
||||
pushProgress();
|
||||
pushProgress.flush();
|
||||
setSyncState('synced');
|
||||
setConflictDetails(null);
|
||||
};
|
||||
|
||||
const resolveConflictWithRemote = async () => {
|
||||
const resolveWithRemote = async () => {
|
||||
const view = getView(bookKey);
|
||||
const remote = conflictDetails?.remote;
|
||||
const book = conflictDetails?.book;
|
||||
@@ -311,7 +311,7 @@ export const useKOSync = (bookKey: string) => {
|
||||
errorMessage,
|
||||
pushProgress,
|
||||
pullProgress,
|
||||
resolveConflictWithLocal,
|
||||
resolveConflictWithRemote,
|
||||
resolveWithLocal,
|
||||
resolveWithRemote,
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user