mirror of
https://codeberg.org/shroff/phylum.git
synced 2026-01-06 03:31:02 -06:00
[client] show bookmarks in sidebar
This commit is contained in:
@@ -9,13 +9,11 @@ const keyLastBookmarkFetch = "lastBookmarksFetch";
|
||||
|
||||
class BookmarkRepository {
|
||||
final PhylumAccount account;
|
||||
List<Bookmark> _bookmarks = const [];
|
||||
List<Bookmark> get bookmarks => _bookmarks;
|
||||
|
||||
BookmarkRepository({required this.account}) {
|
||||
account.db.bookmarks.select().get().then(
|
||||
(bookmarks) => _bookmarks = List.unmodifiable(bookmarks),
|
||||
);
|
||||
BookmarkRepository({required this.account});
|
||||
|
||||
Stream<List<Bookmark>> watch() {
|
||||
return account.db.bookmarks.select().watch();
|
||||
}
|
||||
|
||||
Future<ApiResult> refresh() async {
|
||||
@@ -36,7 +34,6 @@ class BookmarkRepository {
|
||||
batch.insertAllOnConflictUpdate(db.bookmarks, bookmarks);
|
||||
});
|
||||
account.persist(keyLastBookmarkFetch, data["until"]);
|
||||
_bookmarks = List.unmodifiable(bookmarks);
|
||||
}
|
||||
|
||||
Bookmark parseBookmarkObject(Map<String, dynamic> data) {
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:phylum/app.dart';
|
||||
import 'package:phylum/app_shortcuts.dart';
|
||||
import 'package:phylum/libphylum/db/db.dart';
|
||||
import 'package:phylum/libphylum/phylum_account.dart';
|
||||
import 'package:phylum/ui/app/button_downloads.dart';
|
||||
import 'package:phylum/ui/app/button_server_status.dart';
|
||||
import 'package:phylum/ui/app/fab_action.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class NavList extends StatelessWidget {
|
||||
final bool showFab;
|
||||
@@ -35,6 +40,26 @@ class NavList extends StatelessWidget {
|
||||
title: const Text('Home'),
|
||||
onTap: () => Actions.maybeInvoke(context, const NavHomeIntent()),
|
||||
),
|
||||
StreamBuilder<List<Bookmark>>(
|
||||
stream: context.read<PhylumAccount>().bookmarkRepository.watch(),
|
||||
initialData: const [],
|
||||
builder: (context, snapshot) {
|
||||
return Theme(
|
||||
data: Theme.of(context).copyWith(dividerColor: Colors.transparent),
|
||||
child: ExpansionTile(
|
||||
title: Text('Bookmarks'),
|
||||
leading: Icon(Icons.bookmark),
|
||||
children: snapshot.data!
|
||||
.map((b) => ListTile(
|
||||
title: Text(b.name),
|
||||
leading: Icon(null),
|
||||
onTap: () => context.goNamed('folder', pathParameters: {'id': b.resourceId}),
|
||||
))
|
||||
.toList(growable: false),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
const Divider(),
|
||||
const DownloadButton(),
|
||||
const ServerStatusButton(),
|
||||
|
||||
Reference in New Issue
Block a user