mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-28 00:29:21 +00:00
Add filtering for conferences
This commit is contained in:
parent
89367bb7cd
commit
ffe8c0fd45
2 changed files with 39 additions and 11 deletions
|
|
@ -355,7 +355,7 @@ struct ContentView: View {
|
|||
}
|
||||
}
|
||||
} label: {
|
||||
Image(index == 0 ? "funnel" : "dots-three-vertical")
|
||||
Image(index == 0 ? "funnel" : (index == 3 ? "calendar" : "dots-three-vertical"))
|
||||
.renderingMode(.template)
|
||||
.resizable()
|
||||
.foregroundStyle(.white)
|
||||
|
|
@ -390,8 +390,11 @@ struct ContentView: View {
|
|||
sourceFlags: MagicSearch.Source.Friends.rawValue | MagicSearch.Source.LdapServers.rawValue)
|
||||
} else if index == 1 {
|
||||
historyListViewModel.resetFilterCallLogs()
|
||||
} else {
|
||||
} else if index == 2 {
|
||||
//TODO Conversations List reset
|
||||
} else if index == 3 {
|
||||
meetingsListViewModel.currentFilter = ""
|
||||
meetingsListViewModel.computeMeetingsList()
|
||||
}
|
||||
} label: {
|
||||
Image("caret-left")
|
||||
|
|
@ -431,8 +434,11 @@ struct ContentView: View {
|
|||
sourceFlags: MagicSearch.Source.Friends.rawValue | MagicSearch.Source.LdapServers.rawValue)
|
||||
} else if index == 1 {
|
||||
historyListViewModel.filterCallLogs(filter: text)
|
||||
} else {
|
||||
//TODO Conversations List Filter
|
||||
} else if index == 2 {
|
||||
//TODO Conversations List reset
|
||||
} else if index == 3 {
|
||||
meetingsListViewModel.currentFilter = text
|
||||
meetingsListViewModel.computeMeetingsList()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
@ -461,8 +467,11 @@ struct ContentView: View {
|
|||
sourceFlags: MagicSearch.Source.Friends.rawValue | MagicSearch.Source.LdapServers.rawValue)
|
||||
} else if index == 1 {
|
||||
historyListViewModel.filterCallLogs(filter: text)
|
||||
} else {
|
||||
//TODO Conversations List Filter
|
||||
} else if index == 2 {
|
||||
//TODO Conversations List reset
|
||||
} else if index == 3 {
|
||||
meetingsListViewModel.currentFilter = text
|
||||
meetingsListViewModel.computeMeetingsList()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ class MeetingsListViewModel: ObservableObject {
|
|||
|
||||
@Published var meetingsList: [MeetingsListItemModel] = []
|
||||
@Published var currentFilter = ""
|
||||
@Published var todayIdx = 0
|
||||
|
||||
init() {
|
||||
coreContext.doOnCoreQueue { core in
|
||||
|
|
@ -42,7 +43,8 @@ class MeetingsListViewModel: ObservableObject {
|
|||
}
|
||||
|
||||
func computeMeetingsList() {
|
||||
let filter = self.currentFilter
|
||||
let filter = self.currentFilter.uppercased()
|
||||
let isFiltering = !filter.isEmpty
|
||||
|
||||
coreContext.doOnCoreQueue { core in
|
||||
var confInfoList: [ConferenceInfo] = []
|
||||
|
|
@ -55,8 +57,9 @@ class MeetingsListViewModel: ObservableObject {
|
|||
}
|
||||
|
||||
var meetingsListTmp: [MeetingsListItemModel] = []
|
||||
var previousModel: MeetingModel?
|
||||
var meetingForTodayFound = false
|
||||
var currentIdx = 0
|
||||
var todayIdx = 0
|
||||
for confInfo in confInfoList {
|
||||
if confInfo.duration == 0 { continue }// This isn't a scheduled conference, don't display it
|
||||
var add = true
|
||||
|
|
@ -72,24 +75,40 @@ class MeetingsListViewModel: ObservableObject {
|
|||
if add {
|
||||
let model = MeetingModel(conferenceInfo: confInfo)
|
||||
|
||||
if !meetingForTodayFound {
|
||||
if !meetingForTodayFound && !isFiltering {
|
||||
if model.isToday {
|
||||
meetingForTodayFound = true
|
||||
todayIdx = currentIdx
|
||||
} else if model.isAfterToday {
|
||||
// If no meeting was found for today, insert "Today" fake model before the next meeting to come
|
||||
meetingsListTmp.append(MeetingsListItemModel(meetingModel: nil))
|
||||
meetingForTodayFound = true
|
||||
todayIdx = currentIdx
|
||||
}
|
||||
}
|
||||
|
||||
meetingsListTmp.append(MeetingsListItemModel(meetingModel: model))
|
||||
previousModel = model
|
||||
var matchFilter = !isFiltering
|
||||
if isFiltering {
|
||||
matchFilter = matchFilter || confInfo.subject?.uppercased().contains(filter) ?? false
|
||||
matchFilter = matchFilter || confInfo.description?.uppercased().contains(filter) ?? false
|
||||
matchFilter = matchFilter || confInfo.organizer?.asStringUriOnly().uppercased().contains(filter) ?? false
|
||||
for pInfo in confInfo.participantInfos {
|
||||
matchFilter = matchFilter || pInfo.address?.asStringUriOnly().uppercased().contains(filter) ?? false
|
||||
}
|
||||
}
|
||||
|
||||
if matchFilter {
|
||||
meetingsListTmp.append(MeetingsListItemModel(meetingModel: model))
|
||||
currentIdx += 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DispatchQueue.main.sync {
|
||||
self.todayIdx = todayIdx
|
||||
self.meetingsList = meetingsListTmp
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue