mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2024-12-17 17:20:21 +01:00
default selected tag (all)
This commit is contained in:
@@ -103,8 +103,10 @@ class ItemsModel: ObservableObject {
|
||||
class ChatTagsModel: ObservableObject {
|
||||
static let shared = ChatTagsModel()
|
||||
|
||||
static let defaultTag: ChatTagFilter = .presetTag(icon: "list.bullet", activeIcon: "list.bullet", text: NSLocalizedString("All", comment: "preset chat list"), enabled: true, filter: { c in true })
|
||||
|
||||
let presetTags: [ChatTagFilter] = [
|
||||
.presetTag(icon: "list.bullet", activeIcon: "list.bullet", text: NSLocalizedString("All", comment: "preset chat list"), enabled: true, filter: { c in true }),
|
||||
defaultTag,
|
||||
.presetTag(icon: "star", activeIcon: "star.fill", text: NSLocalizedString("Favorite", comment: "preset chat list"), enabled: false, filter: { c in c.chatSettings?.favorite ?? false }),
|
||||
.presetTag(icon: "person", activeIcon: "person.fill", text: NSLocalizedString("Contacts", comment: "preset chat list"), enabled: false, filter: { if case .direct = $0 { true } else { false }}),
|
||||
.presetTag(icon: "person.2", activeIcon: "person.2.fill", text: NSLocalizedString("Groups", comment: "preset chat list"), enabled: false, filter: { filterGroupChat($0) }),
|
||||
@@ -112,7 +114,7 @@ class ChatTagsModel: ObservableObject {
|
||||
]
|
||||
|
||||
@Published var tags: [ChatTagFilter] = []
|
||||
@Published var selectedTag: ChatTagFilter?
|
||||
@Published var selectedTag: ChatTagFilter = defaultTag
|
||||
}
|
||||
|
||||
private func filterBusinessChat(_ cInfo: ChatInfo) -> Bool {
|
||||
|
||||
@@ -656,7 +656,7 @@ struct ChatListTag: View {
|
||||
}
|
||||
if case let .chatTag(_, _, tagId) = chatTagsModel.selectedTag,
|
||||
!userTags.contains(where: { $0.chatTagId == tagId }) {
|
||||
chatTagsModel.selectedTag = nil
|
||||
chatTagsModel.selectedTag = ChatTagsModel.defaultTag
|
||||
}
|
||||
updateChatTags(chat: chat, chatTags: chatTags)
|
||||
dismiss()
|
||||
|
||||
@@ -448,11 +448,7 @@ struct ChatListView: View {
|
||||
}
|
||||
|
||||
func filterByTag(_ chat: Chat) -> Bool {
|
||||
if let tag = chatTagsModel.selectedTag {
|
||||
return tag.filter(chat.chatInfo)
|
||||
} else {
|
||||
return true
|
||||
}
|
||||
chatTagsModel.selectedTag.filter(chat.chatInfo)
|
||||
}
|
||||
|
||||
func viewNameContains(_ cInfo: ChatInfo, _ s: String) -> Bool {
|
||||
@@ -802,7 +798,7 @@ struct ChatTagsView: View {
|
||||
|
||||
private func setSelectedTag(_ tag: ChatTagFilter) {
|
||||
if (chatTagsModel.selectedTag == tag) {
|
||||
chatTagsModel.selectedTag = nil
|
||||
chatTagsModel.selectedTag = ChatTagsModel.defaultTag
|
||||
} else {
|
||||
chatTagsModel.selectedTag = tag
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user