feat(album): add pull-to-refresh to album entry
This commit is contained in:
@@ -52,7 +52,10 @@ final class TravelAlbumEntryViewModel {
|
||||
}
|
||||
|
||||
/// 重新拉取相册列表。
|
||||
func loadAlbums(api: any TravelAlbumServing) async {
|
||||
func loadAlbums(
|
||||
api: any TravelAlbumServing,
|
||||
preservingContentOnFailure: Bool = false
|
||||
) async {
|
||||
isLoading = true
|
||||
notifyStateChange()
|
||||
defer {
|
||||
@@ -67,12 +70,20 @@ final class TravelAlbumEntryViewModel {
|
||||
} catch is CancellationError {
|
||||
return
|
||||
} catch {
|
||||
albums = []
|
||||
albumTotal = 0
|
||||
if !preservingContentOnFailure {
|
||||
albums = []
|
||||
albumTotal = 0
|
||||
}
|
||||
onShowMessage?(error.localizedDescription)
|
||||
}
|
||||
}
|
||||
|
||||
/// 用户下拉刷新相册列表;失败时保留当前内容,避免页面瞬间清空。
|
||||
func refreshAlbums(api: any TravelAlbumServing) async {
|
||||
guard !isLoading else { return }
|
||||
await loadAlbums(api: api, preservingContentOnFailure: true)
|
||||
}
|
||||
|
||||
/// 打开创建相册弹窗。
|
||||
func openCreateSheet(api: any TravelAlbumServing) async {
|
||||
guard !isCreating else { return }
|
||||
|
||||
Reference in New Issue
Block a user