Update Ghostgram features

This commit is contained in:
ichmagmaus 812
2026-03-07 18:15:32 +01:00
parent 1a3303b059
commit 24a7ec39d9
902 changed files with 148295 additions and 62348 deletions
@@ -3,10 +3,24 @@ import TelegramCore
import SwiftSignalKit
public struct CallListSettings: Codable, Equatable {
public var _showContactsTab: Bool?
public var _showTab: Bool?
public var showContactsTab: Bool {
get {
if let value = self._showContactsTab {
return value
} else {
return true
}
}
set {
self._showContactsTab = newValue
}
}
public static var defaultSettings: CallListSettings {
return CallListSettings(showTab: nil)
return CallListSettings(showContactsTab: nil, showTab: nil)
}
public var showTab: Bool {
@@ -21,13 +35,17 @@ public struct CallListSettings: Codable, Equatable {
}
}
public init(showTab: Bool?) {
public init(showContactsTab: Bool?, showTab: Bool?) {
self._showContactsTab = showContactsTab
self._showTab = showTab
}
public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: StringCodingKey.self)
if let value = try container.decodeIfPresent(Int32.self, forKey: "showContactsTab") {
self._showContactsTab = value != 0
}
if let value = try container.decodeIfPresent(Int32.self, forKey: "showTab") {
self._showTab = value != 0
}
@@ -36,6 +54,11 @@ public struct CallListSettings: Codable, Equatable {
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: StringCodingKey.self)
if let showContactsTab = self._showContactsTab {
try container.encode((showContactsTab ? 1 : 0) as Int32, forKey: "showContactsTab")
} else {
try container.encodeNil(forKey: "showContactsTab")
}
if let showTab = self._showTab {
try container.encode((showTab ? 1 : 0) as Int32, forKey: "showTab")
} else {
@@ -44,11 +67,15 @@ public struct CallListSettings: Codable, Equatable {
}
public static func ==(lhs: CallListSettings, rhs: CallListSettings) -> Bool {
return lhs._showTab == rhs._showTab
return lhs._showContactsTab == rhs._showContactsTab && lhs._showTab == rhs._showTab
}
public func withUpdatedShowContactsTab(_ showContactsTab: Bool) -> CallListSettings {
return CallListSettings(showContactsTab: showContactsTab, showTab: self._showTab)
}
public func withUpdatedShowTab(_ showTab: Bool) -> CallListSettings {
return CallListSettings(showTab: showTab)
return CallListSettings(showContactsTab: self._showContactsTab, showTab: showTab)
}
}
@@ -0,0 +1,49 @@
import Foundation
import TelegramCore
import SwiftSignalKit
public struct ChatSettings: Codable, Equatable {
public let sendWithCmdEnter: Bool
public static var defaultSettings: ChatSettings {
return ChatSettings(sendWithCmdEnter: false)
}
public init(sendWithCmdEnter: Bool) {
self.sendWithCmdEnter = sendWithCmdEnter
}
public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: StringCodingKey.self)
self.sendWithCmdEnter = (try container.decode(Int32.self, forKey: "sendWithCmdEnter")) != 0
}
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: StringCodingKey.self)
try container.encode((self.sendWithCmdEnter ? 1 : 0) as Int32, forKey: "sendWithCmdEnter")
}
public static func ==(lhs: ChatSettings, rhs: ChatSettings) -> Bool {
return lhs.sendWithCmdEnter == rhs.sendWithCmdEnter
}
public func withUpdatedSendWithCmdEnter(_ sendWithCmdEnter: Bool) -> ChatSettings {
return ChatSettings(sendWithCmdEnter: sendWithCmdEnter)
}
}
public func updateChatSettingsInteractively(accountManager: AccountManager<TelegramAccountManagerTypes>, _ f: @escaping (ChatSettings) -> ChatSettings) -> Signal<Void, NoError> {
return accountManager.transaction { transaction -> Void in
transaction.updateSharedData(ApplicationSpecificSharedDataKeys.chatSettings, { entry in
let currentSettings: ChatSettings
if let entry = entry?.get(ChatSettings.self) {
currentSettings = entry
} else {
currentSettings = ChatSettings.defaultSettings
}
return SharedPreferencesEntry(f(currentSettings))
})
}
}
@@ -3,6 +3,7 @@ import TelegramCore
import Postbox
private enum ApplicationSpecificPreferencesKeyValues: Int32 {
case SGUISettings = 900
case voipDerivedState = 16
case chatArchiveSettings = 17
case chatListFilterSettings = 18
@@ -12,6 +13,7 @@ private enum ApplicationSpecificPreferencesKeyValues: Int32 {
}
public struct ApplicationSpecificPreferencesKeys {
public static let SGUISettings = applicationSpecificPreferencesKey(ApplicationSpecificPreferencesKeyValues.SGUISettings.rawValue)
public static let voipDerivedState = applicationSpecificPreferencesKey(ApplicationSpecificPreferencesKeyValues.voipDerivedState.rawValue)
public static let chatArchiveSettings = applicationSpecificPreferencesKey(ApplicationSpecificPreferencesKeyValues.chatArchiveSettings.rawValue)
public static let chatListFilterSettings = applicationSpecificPreferencesKey(ApplicationSpecificPreferencesKeyValues.chatListFilterSettings.rawValue)
@@ -21,6 +23,8 @@ public struct ApplicationSpecificPreferencesKeys {
}
private enum ApplicationSpecificSharedDataKeyValues: Int32 {
// MARK: Swiftgram
case sgStatus = 999
case inAppNotificationSettings = 0
case presentationPasscodeSettings = 1
case automaticMediaDownloadSettings = 2
@@ -43,9 +47,12 @@ private enum ApplicationSpecificSharedDataKeyValues: Int32 {
case drawingSettings = 19
case mediaDisplaySettings = 20
case updateSettings = 21
case chatSettings = 22
}
public struct ApplicationSpecificSharedDataKeys {
// MARK: Swiftgram
public static let sgStatus = applicationSpecificSharedDataKey(ApplicationSpecificSharedDataKeyValues.sgStatus.rawValue)
public static let inAppNotificationSettings = applicationSpecificSharedDataKey(ApplicationSpecificSharedDataKeyValues.inAppNotificationSettings.rawValue)
public static let presentationPasscodeSettings = applicationSpecificSharedDataKey(ApplicationSpecificSharedDataKeyValues.presentationPasscodeSettings.rawValue)
public static let automaticMediaDownloadSettings = applicationSpecificSharedDataKey(ApplicationSpecificSharedDataKeyValues.automaticMediaDownloadSettings.rawValue)
@@ -68,6 +75,7 @@ public struct ApplicationSpecificSharedDataKeys {
public static let drawingSettings = applicationSpecificPreferencesKey(ApplicationSpecificSharedDataKeyValues.drawingSettings.rawValue)
public static let mediaDisplaySettings = applicationSpecificPreferencesKey(ApplicationSpecificSharedDataKeyValues.mediaDisplaySettings.rawValue)
public static let updateSettings = applicationSpecificPreferencesKey(ApplicationSpecificSharedDataKeyValues.updateSettings.rawValue)
public static let chatSettings = applicationSpecificPreferencesKey(ApplicationSpecificSharedDataKeyValues.chatSettings.rawValue)
}
private enum ApplicationSpecificItemCacheCollectionIdValues: Int8 {
@@ -104,12 +112,12 @@ public struct ApplicationSpecificItemCacheCollectionId {
private enum ApplicationSpecificOrderedItemListCollectionIdValues: Int32 {
case webSearchRecentQueries = 0
case wallpaperSearchRecentQueries = 1
case settingsSearchRecentItems = 2
case localThemes = 3
case storyDrafts = 4
case storySources = 5
case hashtagSearchRecentQueries = 6
case browserRecentlyVisited = 7
case settingsSearchRecentItems = 8
}
public struct ApplicationSpecificOrderedItemListCollectionId {