Files
ERitors-Scribe-Desktop/components/offline/OfflineToggle.tsx
natreex 7f34421212 Add error handling, enhance syncing, and refactor deletion logic
- Introduce new error messages for syncing and book deletion in `en.json`.
- Update `DeleteBook` to support local-only deletion and synced book management.
- Refine offline/online behavior with `deleteLocalToo` checkbox and update related state handling.
- Extend repository and IPC methods to handle optional IDs for updates.
- Add `SyncQueueContext` for queueing offline changes and improving synchronization workflows.
- Enhance refined text generation logic in `DraftCompanion` and `GhostWriter` components.
- Replace PUT with PATCH for world updates to align with API expectations.
- Streamline `AlertBox` by integrating dynamic translation keys for deletion prompts.
2026-01-10 15:50:03 -05:00

41 lines
1.5 KiB
TypeScript

'use client';
import { useContext } from 'react';
import OfflineContext from '@/context/OfflineContext';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faWifi, faCircle } from '@fortawesome/free-solid-svg-icons';
export default function OfflineToggle() {
const { offlineMode, toggleOfflineMode } = useContext(OfflineContext);
if (!window.electron || !offlineMode.isDatabaseInitialized) {
return null;
}
const handleToggle = () => {
toggleOfflineMode();
};
return (
<button
onClick={handleToggle}
className={`
flex items-center gap-2 px-3 py-1.5 rounded-lg border transition-all
${offlineMode.isOffline
? 'bg-orange-500/20 border-orange-500/40 hover:bg-orange-500/30'
: 'bg-green-500/20 border-green-500/40 hover:bg-green-500/30'
}
`}
title={offlineMode.isOffline ? 'Passer en mode en ligne' : 'Passer en mode hors ligne'}
>
<FontAwesomeIcon
icon={offlineMode.isOffline ? faCircle : faWifi}
className={`w-3 h-3 ${offlineMode.isOffline ? 'text-orange-300' : 'text-green-300'}`}
/>
<span className={`text-xs font-medium ${offlineMode.isOffline ? 'text-orange-200' : 'text-green-200'}`}>
{offlineMode.isOffline ? 'Hors ligne' : 'En ligne'}
</span>
</button>
);
}