mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-07-18 01:26:12 +00:00
ios
This commit is contained in:
@@ -1754,6 +1754,25 @@ func markChatUnread(_ chat: Chat, unreadChat: Bool = true) async {
|
||||
}
|
||||
}
|
||||
|
||||
func markSupportChatRead(_ groupInfo: GroupInfo, _ member: GroupMember) async {
|
||||
do {
|
||||
if let supportChat = member.supportChat, member.supportChatNotRead {
|
||||
try await apiChatRead(type: .group, id: groupInfo.apiId, scope: .memberSupport(groupMemberId_: member.groupMemberId))
|
||||
await MainActor.run {
|
||||
var updatedSupportChat = supportChat
|
||||
updatedSupportChat.memberAttention = 0
|
||||
updatedSupportChat.mentions = 0
|
||||
updatedSupportChat.unread = 0
|
||||
var updatedMember = member
|
||||
updatedMember.supportChat = updatedSupportChat
|
||||
_ = ChatModel.shared.upsertGroupMember(groupInfo, updatedMember)
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
logger.error("markChatRead apiChatRead error: \(responseError(error))")
|
||||
}
|
||||
}
|
||||
|
||||
func apiMarkChatItemsRead(_ im: ItemsModel, _ cInfo: ChatInfo, _ itemIds: [ChatItem.ID], mentionsRead: Int) async {
|
||||
do {
|
||||
let updatedChatInfo = try await apiChatItemsRead(type: cInfo.chatType, id: cInfo.apiId, scope: cInfo.groupChatScope(), itemIds: itemIds)
|
||||
|
||||
@@ -101,6 +101,14 @@ struct MemberSupportView: View {
|
||||
}
|
||||
.tint(theme.colors.primary)
|
||||
} else {
|
||||
if memberWithChat.wrapped.supportChatNotRead {
|
||||
Button {
|
||||
Task { await markSupportChatRead(groupInfo, memberWithChat.wrapped) }
|
||||
} label: {
|
||||
Label("Read", systemImage: "checkmark")
|
||||
}
|
||||
.tint(theme.colors.primary)
|
||||
}
|
||||
Button {
|
||||
showDeleteMemberSupportChatAlert(groupInfo, memberWithChat.wrapped)
|
||||
} label: {
|
||||
|
||||
@@ -2650,6 +2650,15 @@ public struct GroupMember: Identifiable, Decodable, Hashable {
|
||||
memberRole >= .moderator && versionRange.maxVersion >= REPORTS_VERSION
|
||||
}
|
||||
|
||||
public var supportChatNotRead: Bool {
|
||||
if let supportChat = supportChat,
|
||||
supportChat.memberAttention > 0 || supportChat.mentions > 0 || supportChat.unread > 0 {
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
public var versionRange: VersionRange {
|
||||
if let activeConn {
|
||||
activeConn.peerChatVRange
|
||||
|
||||
Reference in New Issue
Block a user