mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2024-12-17 17:20:21 +01:00
placeholders looking good and sync page sizes with android
This commit is contained in:
@@ -318,8 +318,8 @@ private func apiChatsResponse(_ r: ChatResponse) throws -> [ChatData] {
|
||||
throw r
|
||||
}
|
||||
|
||||
let loadItemsPerPage = 50
|
||||
let preloadItem = 8
|
||||
let loadItemsPerPage = 100
|
||||
let preloadItem = 25
|
||||
let idealChatListSize = 500
|
||||
|
||||
func apiGetChat(type: ChatType, id: Int64, search: String = "") async throws -> (Chat, Int?) {
|
||||
|
||||
@@ -62,8 +62,6 @@ struct ChatItemView: View {
|
||||
CIVoiceView(chat: chat, chatItem: ci, recordingFile: ci.file, duration: duration, allowMenu: $allowMenu)
|
||||
} else if ci.content.msgContent == nil {
|
||||
ChatItemContentView(chat: chat, chatItem: chatItem, msgContentView: { Text(ci.text) }) // msgContent is unreachable branch in this case
|
||||
} else if ci.isPlaceholder {
|
||||
EmptyView()
|
||||
} else {
|
||||
framedItemView()
|
||||
}
|
||||
|
||||
@@ -220,7 +220,11 @@ struct ReverseList<Content: View>: UIViewControllerRepresentable {
|
||||
var snapshot = NSDiffableDataSourceSnapshot<Section, ChatItem>()
|
||||
if let gap = gap {
|
||||
var itemsCopy = items
|
||||
let blanks = (0..<gap.size).map { index in ChatItem.placeholder(index + 1) }
|
||||
let blanks = (0..<gap.size).map { index in
|
||||
// Using existing text instead of random rumble or empty text does make long scroll look natural.
|
||||
let sourceItem = items[index % items.count]
|
||||
return ChatItem.placeholder(idx: index + 1, text: sourceItem.text, chatDir: sourceItem.chatDir)
|
||||
}
|
||||
itemsCopy.insert(contentsOf: blanks, at: gap.index)
|
||||
renderedItems = itemsCopy
|
||||
} else {
|
||||
|
||||
@@ -2665,13 +2665,13 @@ public struct ChatItem: Identifiable, Decodable, Hashable {
|
||||
return item
|
||||
}
|
||||
|
||||
public static func placeholder(_ idx: Int) -> ChatItem {
|
||||
public static func placeholder(idx: Int, text: String, chatDir: CIDirection) -> ChatItem {
|
||||
var item = ChatItem(
|
||||
chatDir: CIDirection.directSnd,
|
||||
chatDir: chatDir,
|
||||
meta: CIMeta(
|
||||
itemId: Int64(idx * -10),
|
||||
itemTs: .now,
|
||||
itemText: "",
|
||||
itemText: text,
|
||||
itemStatus: .rcvRead,
|
||||
createdAt: .now,
|
||||
updatedAt: .now,
|
||||
@@ -2681,7 +2681,7 @@ public struct ChatItem: Identifiable, Decodable, Hashable {
|
||||
deletable: false,
|
||||
editable: false
|
||||
),
|
||||
content: .sndMsgContent(msgContent: .text("")),
|
||||
content: .sndMsgContent(msgContent: .text(text)),
|
||||
quotedItem: nil,
|
||||
file: nil
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user