no message

This commit is contained in:
overtake 2020-02-28 10:37:09 +04:00
parent 33e2dff931
commit c136502a24
2 changed files with 12 additions and 23 deletions

View File

@ -1044,7 +1044,7 @@ public class Account {
self.managedOperationsDisposable.add(managedApplyPendingMessageReactionsActions(postbox: self.postbox, network: self.network, stateManager: self.stateManager).start()) self.managedOperationsDisposable.add(managedApplyPendingMessageReactionsActions(postbox: self.postbox, network: self.network, stateManager: self.stateManager).start())
self.managedOperationsDisposable.add(managedSynchronizeEmojiKeywordsOperations(postbox: self.postbox, network: self.network).start()) self.managedOperationsDisposable.add(managedSynchronizeEmojiKeywordsOperations(postbox: self.postbox, network: self.network).start())
self.managedOperationsDisposable.add(managedApplyPendingScheduledMessagesActions(postbox: self.postbox, network: self.network, stateManager: self.stateManager).start()) self.managedOperationsDisposable.add(managedApplyPendingScheduledMessagesActions(postbox: self.postbox, network: self.network, stateManager: self.stateManager).start())
//self.managedOperationsDisposable.add(managedChatListFilters(postbox: self.postbox, network: self.network).start()) self.managedOperationsDisposable.add(managedChatListFilters(postbox: self.postbox, network: self.network).start())
let importantBackgroundOperations: [Signal<AccountRunningImportantTasks, NoError>] = [ let importantBackgroundOperations: [Signal<AccountRunningImportantTasks, NoError>] = [
managedSynchronizeChatInputStateOperations(postbox: self.postbox, network: self.network) |> map { $0 ? AccountRunningImportantTasks.other : [] }, managedSynchronizeChatInputStateOperations(postbox: self.postbox, network: self.network) |> map { $0 ? AccountRunningImportantTasks.other : [] },

View File

@ -93,13 +93,10 @@ extension ChatListFilterPeerCategories {
} }
} }
public final class ChatListFilter: PostboxCoding, Equatable { public struct ChatListFilter: PostboxCoding, Equatable {
public static func == (lhs: ChatListFilter, rhs: ChatListFilter) -> Bool {
return lhs.id == rhs.id && lhs.title == rhs.title && lhs.categories == rhs.categories && lhs.excludeMuted == rhs.excludeMuted && lhs.includePeers == rhs.includePeers
}
public var id: Int32 public var id: Int32
public var title: String? public var title: String
public var categories: ChatListFilterPeerCategories public var categories: ChatListFilterPeerCategories
public var excludeMuted: Bool public var excludeMuted: Bool
public var excludeRead: Bool public var excludeRead: Bool
@ -107,7 +104,7 @@ public final class ChatListFilter: PostboxCoding, Equatable {
public init( public init(
id: Int32, id: Int32,
title: String?, title: String,
categories: ChatListFilterPeerCategories, categories: ChatListFilterPeerCategories,
excludeMuted: Bool, excludeMuted: Bool,
excludeRead: Bool, excludeRead: Bool,
@ -123,7 +120,7 @@ public final class ChatListFilter: PostboxCoding, Equatable {
public init(decoder: PostboxDecoder) { public init(decoder: PostboxDecoder) {
self.id = decoder.decodeInt32ForKey("id", orElse: 0) self.id = decoder.decodeInt32ForKey("id", orElse: 0)
self.title = decoder.decodeOptionalStringForKey("title") self.title = decoder.decodeStringForKey("title", orElse: "Filter")
self.categories = ChatListFilterPeerCategories(rawValue: decoder.decodeInt32ForKey("categories", orElse: 0)) self.categories = ChatListFilterPeerCategories(rawValue: decoder.decodeInt32ForKey("categories", orElse: 0))
self.excludeMuted = decoder.decodeInt32ForKey("excludeMuted", orElse: 0) != 0 self.excludeMuted = decoder.decodeInt32ForKey("excludeMuted", orElse: 0) != 0
self.excludeRead = decoder.decodeInt32ForKey("excludeRead", orElse: 0) != 0 self.excludeRead = decoder.decodeInt32ForKey("excludeRead", orElse: 0) != 0
@ -132,11 +129,7 @@ public final class ChatListFilter: PostboxCoding, Equatable {
public func encode(_ encoder: PostboxEncoder) { public func encode(_ encoder: PostboxEncoder) {
encoder.encodeInt32(self.id, forKey: "id") encoder.encodeInt32(self.id, forKey: "id")
if let title = self.title { encoder.encodeString(title, forKey: "title")
encoder.encodeString(title, forKey: "title")
} else {
encoder.encodeNil(forKey: "title")
}
encoder.encodeInt32(self.categories.rawValue, forKey: "categories") encoder.encodeInt32(self.categories.rawValue, forKey: "categories")
encoder.encodeInt32(self.excludeMuted ? 1 : 0, forKey: "excludeMuted") encoder.encodeInt32(self.excludeMuted ? 1 : 0, forKey: "excludeMuted")
encoder.encodeInt32(self.excludeRead ? 1 : 0, forKey: "excludeRead") encoder.encodeInt32(self.excludeRead ? 1 : 0, forKey: "excludeRead")
@ -145,12 +138,12 @@ public final class ChatListFilter: PostboxCoding, Equatable {
} }
extension ChatListFilter { extension ChatListFilter {
convenience init(apiFilter: Api.DialogFilter) { init(apiFilter: Api.DialogFilter) {
switch apiFilter { switch apiFilter {
case let .dialogFilter(flags, id, title, includePeers): case let .dialogFilter(flags, id, title, includePeers):
self.init( self.init(
id: id, id: id,
title: title.isEmpty ? nil : title, title: title,
categories: ChatListFilterPeerCategories(apiFlags: flags), categories: ChatListFilterPeerCategories(apiFlags: flags),
excludeMuted: (flags & (1 << 11)) != 0, excludeMuted: (flags & (1 << 11)) != 0,
excludeRead: (flags & (1 << 12)) != 0, excludeRead: (flags & (1 << 12)) != 0,
@ -179,7 +172,7 @@ extension ChatListFilter {
flags |= 1 << 12 flags |= 1 << 12
} }
flags |= self.categories.apiFlags flags |= self.categories.apiFlags
return .dialogFilter(flags: flags, id: self.id, title: self.title ?? "", includePeers: self.includePeers.compactMap { peerId -> Api.InputPeer? in return .dialogFilter(flags: flags, id: self.id, title: self.title, includePeers: self.includePeers.compactMap { peerId -> Api.InputPeer? in
return transaction.getPeer(peerId).flatMap(apiInputPeer) return transaction.getPeer(peerId).flatMap(apiInputPeer)
}) })
} }
@ -200,10 +193,10 @@ public func requestUpdateChatListFilter(account: Account, id: Int32, filter: Cha
flags |= 1 << 0 flags |= 1 << 0
} }
return account.network.request(Api.functions.messages.updateDialogFilter(flags: flags, id: id, filter: inputFilter)) return account.network.request(Api.functions.messages.updateDialogFilter(flags: flags, id: id, filter: inputFilter))
|> mapError { _ -> RequestUpdateChatListFilterError in |> mapError { error -> RequestUpdateChatListFilterError in
return .generic return .generic
} }
|> mapToSignal { _ -> Signal<Never, RequestUpdateChatListFilterError> in |> mapToSignal { result -> Signal<Never, RequestUpdateChatListFilterError> in
return .complete() return .complete()
} }
} }
@ -334,11 +327,7 @@ public func replaceRemoteChatListFilters(account: Account) -> Signal<Never, NoEr
} }
} }
public final class ChatListFiltersState: PreferencesEntry, Equatable { public struct ChatListFiltersState: PreferencesEntry, Equatable {
public static func == (lhs: ChatListFiltersState, rhs: ChatListFiltersState) -> Bool {
return lhs.filters == rhs.filters && lhs.filters == rhs.filters
}
public var filters: [ChatListFilter] public var filters: [ChatListFilter]
internal var remoteFilters: [ChatListFilter]? internal var remoteFilters: [ChatListFilter]?