feat: implement offline support for labels and projects, enhance advanced settings with offline feature toggle, and add sync status indicator

- Added offline support for fetching and caching labels and projects using `offlineDB`.
- Enhanced `AdvancedSettings` to include an offline feature toggle with confirmation modal for disabling offline support.
- Introduced `SyncStatusIndicator` component to display sync status, pending commands, and failed commands.
- Created `PendingBadge` component to manage and display pending actions for synchronization.
- Removed deprecated offline mode toggle from `StorageSettings`.
- Improved error handling and user notifications for offline actions and sync processes.
This commit is contained in:
Mo Tarbin
2026-05-11 17:27:29 -04:00
parent 3d170d88fb
commit 2c353628a3
33 changed files with 3077 additions and 1067 deletions

View File

@@ -1,5 +1,6 @@
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
import { GetProjects, CreateProject, UpdateProject, DeleteProject } from '../../utils/Fetcher'
import { offlineDB } from '../../utils/OfflineDB'
// Query hook for fetching all projects
export const useProjects = () => {
@@ -10,22 +11,15 @@ export const useProjects = () => {
const response = await GetProjects()
if (response.ok) {
const data = await response.json()
return data.res || data
const projects = data.res || data
offlineDB.saveKV('projects', projects)
return projects
}
throw new Error('Failed to fetch projects')
} catch (error) {
console.error('Error fetching projects:', error)
// Return default project if API fails
return [
{
id: 'default',
name: 'Default Project',
description: 'Your default project workspace',
color: '#1976d2',
created_by: 'system',
created_at: new Date().toISOString(),
}
]
} catch {
const cached = await offlineDB.getKV('projects')
if (cached) return cached
return []
}
},
staleTime: 5 * 60 * 1000, // 5 minutes