forked from Ivasoft/mattermost-mobile
Fix crashes found in NotificationService (#6935)
This commit is contained in:
@@ -17,8 +17,8 @@ public struct ChannelMemberData: Codable {
|
||||
let container = try decoder.container(keyedBy: ChannelMemberKeys.self)
|
||||
channel_id = try container.decode(String.self, forKey: .channel_id)
|
||||
mention_count = try container.decode(Int.self, forKey: .mention_count)
|
||||
let mentions_root = try? container.decode(Int?.self, forKey: .mention_count_root) ?? 0
|
||||
mention_count_root = mentions_root!
|
||||
let mentions_root = try? container.decode(Int?.self, forKey: .mention_count_root)
|
||||
mention_count_root = mentions_root ?? 0
|
||||
user_id = try container.decode(String.self, forKey: .user_id)
|
||||
roles = try container.decode(String.self, forKey: .roles)
|
||||
last_update_at = try container.decode(Int64.self, forKey: .last_update_at)
|
||||
|
||||
@@ -182,10 +182,13 @@ extension Database {
|
||||
let sortedChainedPosts = chainAndSortPosts(postData)
|
||||
try insertOrUpdatePosts(db, sortedChainedPosts, channelId)
|
||||
let sortedAndNotDeletedPosts = sortedChainedPosts.filter({$0.delete_at == 0})
|
||||
let earliest = sortedAndNotDeletedPosts.first!.create_at
|
||||
let latest = sortedAndNotDeletedPosts.last!.create_at
|
||||
|
||||
if (!receivingThreads) {
|
||||
try handlePostsInChannel(db, channelId, earliest, latest, usedSince)
|
||||
if !sortedAndNotDeletedPosts.isEmpty {
|
||||
let earliest = sortedAndNotDeletedPosts.first!.create_at
|
||||
let latest = sortedAndNotDeletedPosts.last!.create_at
|
||||
try handlePostsInChannel(db, channelId, earliest, latest, usedSince)
|
||||
}
|
||||
|
||||
let lastFetchedAt = postData.posts.map({max($0.create_at, $0.update_at, $0.delete_at)}).max()
|
||||
try updateMyChannelLastFetchedAt(db, channelId, lastFetchedAt ?? 0)
|
||||
|
||||
Reference in New Issue
Block a user