minor refactor
This commit is contained in:
parent
07fb498664
commit
d14cd07a5c
|
@ -22,9 +22,7 @@ public enum SNMessagingKit { // Just to make the external API nice
|
||||||
_007_HomeQueryOptimisationIndexes.self
|
_007_HomeQueryOptimisationIndexes.self
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
_008_EmojiReacts.self
|
_008_EmojiReacts.self,
|
||||||
],
|
|
||||||
[
|
|
||||||
_009_OpenGroupPermission.self
|
_009_OpenGroupPermission.self
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|
|
@ -37,21 +37,21 @@ public struct OpenGroup: Codable, Identifiable, FetchableRecord, PersistableReco
|
||||||
self.rawValue = rawValue
|
self.rawValue = rawValue
|
||||||
}
|
}
|
||||||
|
|
||||||
public func toString() -> String {
|
public init(roomInfo: OpenGroupAPI.RoomPollInfo) {
|
||||||
return ""
|
|
||||||
.appending(self.contains(.read) ? "r" : "-")
|
|
||||||
.appending(self.contains(.write) ? "w" : "-")
|
|
||||||
.appending(self.contains(.upload) ? "u" : "-")
|
|
||||||
}
|
|
||||||
|
|
||||||
public static func getPermissionsfromRoomInfo(_ roomInfo: OpenGroupAPI.RoomPollInfo) -> Permissions {
|
|
||||||
var permissions: Permissions = []
|
var permissions: Permissions = []
|
||||||
|
|
||||||
if roomInfo.read { permissions.insert(.read) }
|
if roomInfo.read { permissions.insert(.read) }
|
||||||
if roomInfo.write { permissions.insert(.write) }
|
if roomInfo.write { permissions.insert(.write) }
|
||||||
if roomInfo.upload { permissions.insert(.upload) }
|
if roomInfo.upload { permissions.insert(.upload) }
|
||||||
|
|
||||||
return permissions
|
self.init(rawValue: permissions.rawValue)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func toString() -> String {
|
||||||
|
return ""
|
||||||
|
.appending(self.contains(.read) ? "r" : "-")
|
||||||
|
.appending(self.contains(.write) ? "w" : "-")
|
||||||
|
.appending(self.contains(.upload) ? "u" : "-")
|
||||||
}
|
}
|
||||||
|
|
||||||
static let read: Permissions = Permissions(rawValue: 1 << 0)
|
static let read: Permissions = Permissions(rawValue: 1 << 0)
|
||||||
|
|
|
@ -384,7 +384,7 @@ public final class OpenGroupManager: NSObject {
|
||||||
|
|
||||||
// Only update the database columns which have changed (this is to prevent the UI from triggering
|
// Only update the database columns which have changed (this is to prevent the UI from triggering
|
||||||
// updates due to changing database columns to the existing value)
|
// updates due to changing database columns to the existing value)
|
||||||
let permissions = OpenGroup.Permissions.getPermissionsfromRoomInfo(pollInfo)
|
let permissions = OpenGroup.Permissions(roomInfo: pollInfo)
|
||||||
|
|
||||||
try OpenGroup
|
try OpenGroup
|
||||||
.filter(id: openGroup.id)
|
.filter(id: openGroup.id)
|
||||||
|
|
Loading…
Reference in New Issue