mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-18 23:48:29 +02:00
Add thread list empty view
This commit is contained in:
@@ -54,6 +54,7 @@ final class ThreadListViewModel: ThreadListViewModelProtocol {
|
||||
}
|
||||
|
||||
deinit {
|
||||
session.threadingService.removeDelegate(self)
|
||||
self.cancelOperations()
|
||||
}
|
||||
|
||||
@@ -113,6 +114,25 @@ final class ThreadListViewModel: ThreadListViewModelProtocol {
|
||||
roomDisplayName: room.displayName)
|
||||
}
|
||||
|
||||
private var emptyViewModel: ThreadListEmptyViewModel {
|
||||
switch selectedFilterType {
|
||||
case .all:
|
||||
return ThreadListEmptyViewModel(icon: Asset.Images.roomContextMenuReplyInThread.image,
|
||||
title: VectorL10n.threadsEmptyTitle,
|
||||
info: VectorL10n.threadsEmptyInfoAll,
|
||||
tip: VectorL10n.threadsEmptyTip,
|
||||
showAllThreadsButtonTitle: VectorL10n.threadsEmptyShowAllThreads,
|
||||
showAllThreadsButtonHidden: true)
|
||||
case .myThreads:
|
||||
return ThreadListEmptyViewModel(icon: Asset.Images.roomContextMenuReplyInThread.image,
|
||||
title: VectorL10n.threadsEmptyTitle,
|
||||
info: VectorL10n.threadsEmptyInfoMy,
|
||||
tip: VectorL10n.threadsEmptyTip,
|
||||
showAllThreadsButtonTitle: VectorL10n.threadsEmptyShowAllThreads,
|
||||
showAllThreadsButtonHidden: false)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
private func viewModel(forThread thread: MXThread) -> ThreadViewModel {
|
||||
@@ -195,9 +215,11 @@ final class ThreadListViewModel: ThreadListViewModelProtocol {
|
||||
)
|
||||
}
|
||||
|
||||
private func loadData() {
|
||||
private func loadData(showLoading: Bool = true) {
|
||||
|
||||
viewState = .loading
|
||||
if showLoading {
|
||||
viewState = .loading
|
||||
}
|
||||
|
||||
switch selectedFilterType {
|
||||
case .all:
|
||||
@@ -206,6 +228,11 @@ final class ThreadListViewModel: ThreadListViewModelProtocol {
|
||||
threads = session.threadingService.participatedThreads(inRoom: roomId)
|
||||
}
|
||||
|
||||
if threads.isEmpty {
|
||||
viewState = .empty(emptyViewModel)
|
||||
return
|
||||
}
|
||||
|
||||
threadsLoaded()
|
||||
}
|
||||
|
||||
@@ -244,8 +271,7 @@ final class ThreadListViewModel: ThreadListViewModelProtocol {
|
||||
extension ThreadListViewModel: MXThreadingServiceDelegate {
|
||||
|
||||
func threadingServiceDidUpdateThreads(_ service: MXThreadingService) {
|
||||
threads = service.threads(inRoom: roomId)
|
||||
viewState = .loaded
|
||||
loadData(showLoading: false)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user