mirror of https://github.com/oxen-io/session-ios
Merge pull request #676 from RyanRory/emoji-reacts-tweaks
Emoji reacts open group poll & update conflict handlingpull/678/head
commit
d5a1c310f1
@ -0,0 +1,41 @@
|
|||||||
|
// Copyright © 2022 Rangeproof Pty Ltd. All rights reserved.
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
extension OpenGroupAPI {
|
||||||
|
public struct PendingChange: Equatable {
|
||||||
|
enum ChangeType {
|
||||||
|
case reaction
|
||||||
|
}
|
||||||
|
|
||||||
|
enum Metadata {
|
||||||
|
case reaction(messageId: Int64, emoji: String, action: VisibleMessage.VMReaction.Kind)
|
||||||
|
}
|
||||||
|
|
||||||
|
let server: String
|
||||||
|
let room: String
|
||||||
|
let changeType: ChangeType
|
||||||
|
var seqNo: Int64?
|
||||||
|
let metadata: Metadata
|
||||||
|
|
||||||
|
public static func == (lhs: OpenGroupAPI.PendingChange, rhs: OpenGroupAPI.PendingChange) -> Bool {
|
||||||
|
guard lhs.server == rhs.server &&
|
||||||
|
lhs.room == rhs.room &&
|
||||||
|
lhs.changeType == rhs.changeType &&
|
||||||
|
lhs.seqNo == rhs.seqNo
|
||||||
|
else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
switch lhs.changeType {
|
||||||
|
case .reaction:
|
||||||
|
if case .reaction(let lhsMessageId, let lhsEmoji, let lhsAction) = lhs.metadata,
|
||||||
|
case .reaction(let rhsMessageId, let rhsEmoji, let rhsAction) = rhs.metadata {
|
||||||
|
return lhsMessageId == rhsMessageId && lhsEmoji == rhsEmoji && lhsAction == rhsAction
|
||||||
|
} else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,44 @@
|
|||||||
|
// Copyright © 2022 Rangeproof Pty Ltd. All rights reserved.
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
extension OpenGroupAPI {
|
||||||
|
public struct ReactionAddResponse: Codable, Equatable {
|
||||||
|
enum CodingKeys: String, CodingKey {
|
||||||
|
case added
|
||||||
|
case seqNo = "seqno"
|
||||||
|
}
|
||||||
|
|
||||||
|
/// This field indicates whether the reaction was added (true) or already present (false).
|
||||||
|
public let added: Bool
|
||||||
|
|
||||||
|
/// The seqNo after the reaction is added.
|
||||||
|
public let seqNo: Int64
|
||||||
|
}
|
||||||
|
|
||||||
|
public struct ReactionRemoveResponse: Codable, Equatable {
|
||||||
|
enum CodingKeys: String, CodingKey {
|
||||||
|
case removed
|
||||||
|
case seqNo = "seqno"
|
||||||
|
}
|
||||||
|
|
||||||
|
/// This field indicates whether the reaction was removed (true) or was not present to begin with (false).
|
||||||
|
public let removed: Bool
|
||||||
|
|
||||||
|
/// The seqNo after the reaction is removed.
|
||||||
|
public let seqNo: Int64
|
||||||
|
}
|
||||||
|
|
||||||
|
public struct ReactionRemoveAllResponse: Codable, Equatable {
|
||||||
|
enum CodingKeys: String, CodingKey {
|
||||||
|
case removed
|
||||||
|
case seqNo = "seqno"
|
||||||
|
}
|
||||||
|
|
||||||
|
/// This field shows the total number of reactions that were deleted.
|
||||||
|
public let removed: Int64
|
||||||
|
|
||||||
|
/// The seqNo after the reactions is all removed.
|
||||||
|
public let seqNo: Int64
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue