fix an issue where the group won't be deleted

pull/799/head
ryanzhao 2 years ago
parent 079d6f8c9f
commit 034b67d6a3

@ -422,7 +422,6 @@ public struct Interaction: Codable, Identifiable, Equatable, FetchableRecord, Mu
public extension Interaction { public extension Interaction {
func with( func with(
variant: Variant? = nil,
serverHash: String? = nil, serverHash: String? = nil,
authorId: String? = nil, authorId: String? = nil,
body: String? = nil, body: String? = nil,
@ -439,7 +438,7 @@ public extension Interaction {
messageUuid: self.messageUuid, messageUuid: self.messageUuid,
threadId: self.threadId, threadId: self.threadId,
authorId: (authorId ?? self.authorId), authorId: (authorId ?? self.authorId),
variant: (variant ?? self.variant), variant: self.variant,
body: (body ?? self.body), body: (body ?? self.body),
timestampMs: (timestampMs ?? self.timestampMs), timestampMs: (timestampMs ?? self.timestampMs),
receivedAtTimestampMs: self.receivedAtTimestampMs, receivedAtTimestampMs: self.receivedAtTimestampMs,

@ -529,10 +529,15 @@ extension MessageSender {
publicKey: userPublicKey publicKey: userPublicKey
) )
try interaction.with( try Interaction
variant: .infoClosedGroupCurrentUserLeft, .filter(id: interactionId)
body: "GROUP_YOU_LEFT".localized() .updateAll(
).update(db) db,
[
Interaction.Columns.variant.set(to: Interaction.Variant.infoClosedGroupCurrentUserLeft),
Interaction.Columns.body.set(to: "GROUP_YOU_LEFT".localized())
]
)
// Update the group (if the admin leaves the group is disbanded) // Update the group (if the admin leaves the group is disbanded)
let wasAdminUser: Bool = try GroupMember let wasAdminUser: Bool = try GroupMember

@ -100,7 +100,7 @@ public struct SessionThreadViewModel: FetchableRecordWithRowId, Decodable, Equat
public var canWrite: Bool { public var canWrite: Bool {
switch threadVariant { switch threadVariant {
case .contact: return true case .contact: return true
case .closedGroup: return currentUserIsClosedGroupMember == true case .closedGroup: return (currentUserIsClosedGroupMember == true) && (interactionVariant?.isGroupLeavingStatus != true)
case .openGroup: return openGroupPermissions?.contains(.write) ?? false case .openGroup: return openGroupPermissions?.contains(.write) ?? false
} }
} }

Loading…
Cancel
Save