small fixes

This commit is contained in:
Ilyas Hallak 2025-07-02 22:15:05 +02:00
parent a5ccc75036
commit ec22c379d1
3 changed files with 49 additions and 41 deletions

View File

@ -121,7 +121,6 @@ struct BookmarksView: View {
} }
} }
} }
.navigationTitle(state.displayName)
.navigationDestination( .navigationDestination(
item: Binding<String?>( item: Binding<String?>(
get: { selectedBookmarkId }, get: { selectedBookmarkId },
@ -148,14 +147,14 @@ struct BookmarksView: View {
}*/ }*/
.onAppear { .onAppear {
Task { Task {
await viewModel.loadBookmarks(state: state) await viewModel.loadBookmarks(state: state, type: type)
} }
} }
.onChange(of: showingAddBookmark) { oldValue, newValue in .onChange(of: showingAddBookmark) { oldValue, newValue in
// Refresh bookmarks when sheet is dismissed // Refresh bookmarks when sheet is dismissed
if oldValue && !newValue { if oldValue && !newValue {
Task { Task {
await viewModel.loadBookmarks(state: state) await viewModel.loadBookmarks(state: state, type: type)
} }
} }
} }

View File

@ -12,7 +12,7 @@ class BookmarksViewModel {
var isLoading = false var isLoading = false
var errorMessage: String? var errorMessage: String?
var currentState: BookmarkState = .unread var currentState: BookmarkState = .unread
var type = [BookmarkType.article] var currentType = [BookmarkType.article]
var showingAddBookmarkFromShare = false var showingAddBookmarkFromShare = false
var shareURL = "" var shareURL = ""
@ -74,10 +74,12 @@ class BookmarksViewModel {
} }
@MainActor @MainActor
func loadBookmarks(state: BookmarkState = .unread) async { func loadBookmarks(state: BookmarkState = .unread, type: [BookmarkType] = [.article]) async {
isLoading = true isLoading = true
errorMessage = nil errorMessage = nil
currentState = state currentState = state
currentType = type
offset = 0 // Offset zurücksetzen offset = 0 // Offset zurücksetzen
hasMoreData = true // Pagination zurücksetzen hasMoreData = true // Pagination zurücksetzen
@ -108,7 +110,11 @@ class BookmarksViewModel {
do { do {
offset += limit // Offset erhöhen offset += limit // Offset erhöhen
let newBookmarks = try await getBooksmarksUseCase.execute(state: currentState, limit: limit, offset: offset) let newBookmarks = try await getBooksmarksUseCase.execute(
state: currentState,
limit: limit,
offset: offset,
type: currentType)
bookmarks?.bookmarks.append(contentsOf: newBookmarks.bookmarks) // Neue Bookmarks hinzufügen bookmarks?.bookmarks.append(contentsOf: newBookmarks.bookmarks) // Neue Bookmarks hinzufügen
hasMoreData = newBookmarks.bookmarks.count == limit // Prüfen, hasMoreData = newBookmarks.bookmarks.count == limit // Prüfen,
} catch { } catch {

View File

@ -22,6 +22,8 @@ struct PadSidebarView: View {
.foregroundColor(selectedTab == tab ? .accentColor : .primary) .foregroundColor(selectedTab == tab ? .accentColor : .primary)
.frame(maxWidth: .infinity, alignment: .leading) .frame(maxWidth: .infinity, alignment: .leading)
.contentShape(Rectangle()) .contentShape(Rectangle())
}
.listRowBackground(selectedTab == tab ? Color.accentColor.opacity(0.15) : Color.clear)
if tab == .archived { if tab == .archived {
Spacer(minLength: 20) Spacer(minLength: 20)
@ -33,8 +35,6 @@ struct PadSidebarView: View {
Spacer() Spacer()
} }
} }
.listRowBackground(selectedTab == tab ? Color.accentColor.opacity(0.15) : Color.clear)
}
} }
.listStyle(.sidebar) .listStyle(.sidebar)
.safeAreaInset(edge: .bottom, alignment: .center) { .safeAreaInset(edge: .bottom, alignment: .center) {
@ -55,6 +55,7 @@ struct PadSidebarView: View {
.background(Color(.systemGroupedBackground)) .background(Color(.systemGroupedBackground))
} }
} content: { } content: {
Group {
switch selectedTab { switch selectedTab {
case .all: case .all:
BookmarksView(state: .all, type: [.article, .video, .photo], selectedBookmark: $selectedBookmark) BookmarksView(state: .all, type: [.article, .video, .photo], selectedBookmark: $selectedBookmark)
@ -75,6 +76,8 @@ struct PadSidebarView: View {
case .tags: case .tags:
Text("Tags") Text("Tags")
} }
}
.navigationTitle(selectedTab.label)
} detail: { } detail: {
if let bookmark = selectedBookmark, selectedTab != .settings { if let bookmark = selectedBookmark, selectedTab != .settings {
BookmarkDetailView(bookmarkId: bookmark.id) BookmarkDetailView(bookmarkId: bookmark.id)