mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2024-12-17 17:20:21 +01:00
iOS: accept images in NSE if enabled, reorder chats when coming from background (#800)
* ios: automatically accept images in NSE, if enabled in settings * remove unnecessary TODOs * reorder chat when coming from background
This commit is contained in:
committed by
GitHub
parent
4408495cfb
commit
f16d8842b2
@@ -58,9 +58,9 @@ final class ChatModel: ObservableObject {
|
||||
chats.firstIndex(where: { $0.id == id })
|
||||
}
|
||||
|
||||
func addChat(_ chat: Chat) {
|
||||
func addChat(_ chat: Chat, at position: Int = 0) {
|
||||
withAnimation {
|
||||
chats.insert(chat, at: 0)
|
||||
chats.insert(chat, at: position)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,13 +104,22 @@ final class ChatModel: ObservableObject {
|
||||
}
|
||||
|
||||
func updateChats(with newChats: [ChatData]) {
|
||||
for c in newChats {
|
||||
if let chat = getChat(c.id) {
|
||||
for i in 0..<newChats.count {
|
||||
let c = newChats[i]
|
||||
if let j = getChatIndex(c.id) {
|
||||
let chat = chats[j]
|
||||
chat.chatInfo = c.chatInfo
|
||||
chat.chatItems = c.chatItems
|
||||
chat.chatStats = c.chatStats
|
||||
if i != j {
|
||||
if chatId != c.chatInfo.id {
|
||||
popChat_(j, to: i)
|
||||
} else if i == 0 {
|
||||
chatToTop = c.chatInfo.id
|
||||
}
|
||||
}
|
||||
} else {
|
||||
addChat(Chat(c))
|
||||
addChat(Chat(c), at: i)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -247,9 +256,9 @@ final class ChatModel: ObservableObject {
|
||||
}
|
||||
}
|
||||
|
||||
private func popChat_(_ i: Int) {
|
||||
private func popChat_(_ i: Int, to position: Int = 0) {
|
||||
let chat = chats.remove(at: i)
|
||||
chats.insert(chat, at: 0)
|
||||
chats.insert(chat, at: position)
|
||||
}
|
||||
|
||||
func removeChat(_ id: String) {
|
||||
|
||||
Reference in New Issue
Block a user