Skip to content

Commit 1f16cf3

Browse files
committed
feat: add first-run detection and WelcomeState rendering in BookmarkList
1 parent 5991f43 commit 1f16cf3

File tree

1 file changed

+35
-12
lines changed

1 file changed

+35
-12
lines changed

src/components/bookmarks/BookmarkList.jsx

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { InboxView } from './InboxView'
1212
import { TagSidebar } from './TagSidebar'
1313
import { FilterBar } from './FilterBar'
1414
import { SelectionActionBar } from './SelectionActionBar'
15+
import { WelcomeState } from './WelcomeState'
1516
import { SettingsView } from '../ui/SettingsView'
1617
import { HelpModal } from '../ui/HelpModal'
1718
import { QuickTagModal } from '../ui/QuickTagModal'
@@ -23,12 +24,26 @@ import {
2324
bulkDeleteBookmarks,
2425
toggleReadLater,
2526
} from '../../services/bookmarks'
27+
import { checkDeviceInitialization } from '../../services/key-storage'
2628

2729
export function BookmarkList() {
2830
const { bookmarks: bookmarksMap, synced } = useYjs()
2931
const [bookmarks, setBookmarks] = useState([])
3032
const { toasts, addToast, removeToast } = useToast()
3133
const [currentView, setCurrentView] = useState('bookmarks')
34+
const [isFirstRun, setIsFirstRun] = useState(false)
35+
36+
useEffect(() => {
37+
checkDeviceInitialization().then(({ hasLEK }) => {
38+
setIsFirstRun(!hasLEK)
39+
})
40+
}, [])
41+
42+
useEffect(() => {
43+
if (bookmarks.length > 0) {
44+
setIsFirstRun(false)
45+
}
46+
}, [bookmarks.length])
3247

3348
useEffect(() => {
3449
const loadBookmarks = () => {
@@ -434,18 +449,26 @@ export function BookmarkList() {
434449
)}
435450

436451
{filteredBookmarks.length === 0 && !isAddingNew ? (
437-
<div className="flex flex-col items-center justify-center py-20 opacity-50">
438-
<PackageOpen className="w-12 h-12 mb-4 stroke-1" />
439-
<p className="text-sm font-medium">No bookmarks found</p>
440-
{filterView !== 'all' && (
441-
<button
442-
onClick={() => handleFilterChange('all')}
443-
className="mt-2 text-sm text-primary hover:underline"
444-
>
445-
Clear filters
446-
</button>
447-
)}
448-
</div>
452+
isFirstRun && filterView === 'all' ? (
453+
<WelcomeState
454+
onAddBookmark={openNewBookmarkForm}
455+
onImport={() => setCurrentView('settings')}
456+
onPairDevice={() => setCurrentView('settings')}
457+
/>
458+
) : (
459+
<div className="flex flex-col items-center justify-center py-20 opacity-50">
460+
<PackageOpen className="w-12 h-12 mb-4 stroke-1" />
461+
<p className="text-sm font-medium">No bookmarks found</p>
462+
{filterView !== 'all' && (
463+
<button
464+
onClick={() => handleFilterChange('all')}
465+
className="mt-2 text-sm text-primary hover:underline"
466+
>
467+
Clear filters
468+
</button>
469+
)}
470+
</div>
471+
)
449472
) : (
450473
filteredBookmarks.map((bookmark, index) => (
451474
editingBookmarkId === bookmark._id ? (

0 commit comments

Comments
 (0)