Skip to content

Commit c8d9d1d

Browse files
committed
Add folders hint + edit settings modal
1 parent 61049d6 commit c8d9d1d

File tree

3 files changed

+30
-8
lines changed

3 files changed

+30
-8
lines changed

src/components/DocumentList.tsx

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ const generateDefaultFolderName = (doc1: DocumentListDocument, doc2: DocumentLis
4242
// Use the first common word that's at least 3 characters long
4343
const significant = commonWords.find(word => word.length >= 3);
4444
if (significant) {
45+
if (significant === 'pdf') return 'PDFs';
46+
if (significant === 'epub') return 'EPUBs';
4547
return `${significant.charAt(0).toUpperCase()}${significant.slice(1)}`;
4648
}
4749
}
@@ -61,7 +63,7 @@ export function DocumentList() {
6163
isEPUBLoading,
6264
} = useDocuments();
6365

64-
const [sortBy, setSortBy] = useState<SortBy>('date');
66+
const [sortBy, setSortBy] = useState<SortBy>('name');
6567
const [sortDirection, setSortDirection] = useState<SortDirection>('desc');
6668
const [folders, setFolders] = useState<Folder[]>([]);
6769
const [documentToDelete, setDocumentToDelete] = useState<DocumentToDelete | null>(null);
@@ -71,6 +73,7 @@ export function DocumentList() {
7173
const [pendingFolderDocs, setPendingFolderDocs] = useState<{ source: DocumentListDocument, target: DocumentListDocument } | null>(null);
7274
const [collapsedFolders, setCollapsedFolders] = useState<Set<string>>(new Set());
7375
const [isInitialized, setIsInitialized] = useState(false);
76+
const [showHint, setShowHint] = useState(true);
7477

7578
useEffect(() => {
7679
// Load saved state
@@ -81,6 +84,7 @@ export function DocumentList() {
8184
setSortDirection(savedState.sortDirection);
8285
setFolders(savedState.folders);
8386
setCollapsedFolders(new Set(savedState.collapsedFolders));
87+
setShowHint(savedState.showHint ?? true); // Use saved hint state or default to true
8488
}
8589
setIsInitialized(true);
8690
};
@@ -94,15 +98,16 @@ export function DocumentList() {
9498
sortBy,
9599
sortDirection,
96100
folders,
97-
collapsedFolders: Array.from(collapsedFolders)
101+
collapsedFolders: Array.from(collapsedFolders),
102+
showHint
98103
};
99104
await saveDocumentListState(state);
100105
};
101106

102107
if (isInitialized) { // Prevents saving empty state on first render or back navigation
103108
saveState();
104109
}
105-
}, [sortBy, sortDirection, folders, collapsedFolders]);
110+
}, [sortBy, sortDirection, folders, collapsedFolders, showHint, isInitialized]);
106111

107112
const allDocuments: DocumentListDocument[] = [
108113
...pdfDocs.map(doc => ({
@@ -214,6 +219,7 @@ export function DocumentList() {
214219
setNewFolderName('');
215220
setDropTargetDoc(null);
216221
setDraggedDoc(null);
222+
setShowHint(false);
217223
}, [pendingFolderDocs, newFolderName]);
218224

219225
const handleFolderNameKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
@@ -443,6 +449,21 @@ export function DocumentList() {
443449
</div>
444450

445451
<div className="space-y-4">
452+
{showHint && allDocuments.length > 1 && (
453+
<div className="flex items-center justify-between bg-offbase rounded-lg px-3 py-2 text-sm">
454+
<p className="text-sm">Drag files on top of each other to make folders</p>
455+
<Button
456+
onClick={() => setShowHint(false)}
457+
className="p-1 hover:bg-accent rounded-lg transition-colors"
458+
aria-label="Dismiss hint"
459+
>
460+
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
461+
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M6 18L18 6M6 6l12 12" />
462+
</svg>
463+
</Button>
464+
</div>
465+
)}
466+
446467
{folders.map(renderFolder)}
447468

448469
<div className="space-y-2">

src/components/SettingsModal.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -198,32 +198,32 @@ export function SettingsModal({ isOpen, setIsOpen }: SettingsModalProps) {
198198
<label className="block text-sm font-medium text-foreground">Document Sync</label>
199199
<div className="flex gap-2">
200200
<Button
201-
onClick={handleSync}
201+
onClick={handleLoad}
202202
disabled={isSyncing || isLoading}
203203
className="justify-center rounded-lg bg-background px-3 py-1.5 text-sm
204204
font-medium text-foreground hover:bg-background/90 focus:outline-none
205205
focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2
206206
transform transition-transform duration-200 ease-in-out hover:scale-[1.04] hover:text-accent
207207
disabled:opacity-50"
208208
>
209-
{isSyncing ? 'Saving...' : 'Save to Server'}
209+
{isLoading ? 'Loading...' : 'Load docs from Server'}
210210
</Button>
211211
<Button
212-
onClick={handleLoad}
212+
onClick={handleSync}
213213
disabled={isSyncing || isLoading}
214214
className="justify-center rounded-lg bg-background px-3 py-1.5 text-sm
215215
font-medium text-foreground hover:bg-background/90 focus:outline-none
216216
focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2
217217
transform transition-transform duration-200 ease-in-out hover:scale-[1.04] hover:text-accent
218218
disabled:opacity-50"
219219
>
220-
{isLoading ? 'Loading...' : 'Load from Server'}
220+
{isSyncing ? 'Saving...' : 'Save local to Server'}
221221
</Button>
222222
</div>
223223
</div>}
224224

225225
<div className="space-y-2">
226-
<label className="block text-sm font-medium text-foreground">Delete Documents</label>
226+
<label className="block text-sm font-medium text-foreground">Bulk Delete</label>
227227
<div className="flex gap-2">
228228
<Button
229229
onClick={() => setShowClearLocalConfirm(true)}

src/types/documents.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,5 @@ export interface DocumentListState {
3737
sortDirection: SortDirection;
3838
folders: Folder[];
3939
collapsedFolders: string[];
40+
showHint: boolean;
4041
}

0 commit comments

Comments
 (0)