From 98433b90ac2b6927ffeaa7b31e6d55401726fce0 Mon Sep 17 00:00:00 2001 From: Birdup <34012548+birdup000@users.noreply.github.com> Date: Tue, 17 Dec 2024 01:00:07 -0600 Subject: [PATCH] add remote storage checkpoint --- app/components/TaskPanel.tsx | 82 +++++- app/hooks/useTasks.ts | 105 +++++--- app/types/remote-storage.d.ts | 13 + app/types/storage.ts | 27 ++ app/utils/remoteStorage.ts | 110 ++++++++ app/utils/storage.ts | 248 +++++++++++++----- package-lock.json | 468 ++++++++++++++++++++++++++++++++++ package.json | 1 + 8 files changed, 950 insertions(+), 104 deletions(-) create mode 100644 app/types/remote-storage.d.ts create mode 100644 app/types/storage.ts create mode 100644 app/utils/remoteStorage.ts diff --git a/app/components/TaskPanel.tsx b/app/components/TaskPanel.tsx index e2622aa..e97b83b 100644 --- a/app/components/TaskPanel.tsx +++ b/app/components/TaskPanel.tsx @@ -20,6 +20,7 @@ import LoginForm from './LoginForm'; import AIAssistant from './AIAssistant'; import ShortcutsDialog from './ShortcutsDialog'; import { Task, TaskList } from '../types/task'; +import { StorageConfig } from '../types/storage'; import { Comment } from './CommentSection'; import { colors } from '../../tailwind.config'; import TaskStats from './TaskStats'; @@ -61,7 +62,32 @@ const TaskPanel: React.FC = () => { const [showCompletedRecurring, setShowCompletedRecurring] = React.useState(true); const [showIntegrations, setShowIntegrations] = React.useState(false); const [isEditorOpen, setIsEditorOpen] = React.useState(false); - const { tasks, addTask, updateTask, deleteTask, reorderTasks, importTasks, lists, addList, updateList, deleteList } = useTasks(); + const [storageConfig, setStorageConfig] = React.useState(() => { + const email = localStorage.getItem('email'); + const userId = email || 'anonymous'; + return { + remoteEnabled: localStorage.getItem('remoteStorageEnabled') === 'true', + apiKey: localStorage.getItem('remoteStorageApiKey') || undefined, + userId + }; + }); + + const { + tasks, + addTask, + updateTask, + deleteTask, + reorderTasks, + importTasks, + lists, + addList, + updateList, + deleteList, + sync, + isLoading + } = useTasks(storageConfig); + + const [isSyncing, setIsSyncing] = React.useState(false); const { searchTerm, setSearchTerm, @@ -436,6 +462,32 @@ const TaskPanel: React.FC = () => { > 🔌 + {storageConfig.remoteEnabled && ( +
+ + + {isSyncing ? 'Syncing...' : 'Sync Tasks'} + +
+ )}