mirror of
https://github.com/ichmagmaus111/ghostgram.git
synced 2026-05-31 23:31:37 +02:00
chore: migrate to new version + fixed several critical bugs
- Migrated project to latest Telegram iOS base (v12.3.2+) - Fixed circular dependency between GhostModeManager and MiscSettingsManager - Fixed multiple Bazel build configuration errors (select() default conditions) - Fixed duplicate type definitions in PeerInfoScreen - Fixed swiftmodule directory resolution in build scripts - Added Ghostgram Settings tab in main Settings menu with all 5 features - Cleared sensitive credentials from config.json (template-only now) - Excluded bazel-cache from version control
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
import Foundation
|
||||
import Postbox
|
||||
import TelegramApi
|
||||
|
||||
public final class SummarizationMessageAttribute: Equatable, MessageAttribute {
|
||||
public struct Summary: Equatable, Codable, PostboxCoding {
|
||||
public let text: String
|
||||
public let entities: [MessageTextEntity]
|
||||
|
||||
public init(
|
||||
text: String,
|
||||
entities: [MessageTextEntity]
|
||||
) {
|
||||
self.text = text
|
||||
self.entities = entities
|
||||
}
|
||||
|
||||
public init(decoder: PostboxDecoder) {
|
||||
self.text = decoder.decodeStringForKey("text", orElse: "")
|
||||
self.entities = decoder.decodeObjectArrayWithDecoderForKey("entities")
|
||||
}
|
||||
|
||||
public func encode(_ encoder: PostboxEncoder) {
|
||||
encoder.encodeString(self.text, forKey: "text")
|
||||
encoder.encodeObjectArray(self.entities, forKey: "entities")
|
||||
}
|
||||
}
|
||||
|
||||
public let fromLang: String
|
||||
public let summary: Summary?
|
||||
public let translated: [String: Summary]
|
||||
|
||||
public init(
|
||||
fromLang: String,
|
||||
summary: Summary? = nil,
|
||||
translated: [String: Summary] = [:]
|
||||
) {
|
||||
self.fromLang = fromLang
|
||||
self.summary = summary
|
||||
self.translated = translated
|
||||
}
|
||||
|
||||
required public init(decoder: PostboxDecoder) {
|
||||
self.fromLang = decoder.decodeStringForKey("fl", orElse: "")
|
||||
self.summary = decoder.decodeObjectForKey("s", decoder: { Summary(decoder: $0) }) as? Summary
|
||||
self.translated = decoder.decodeObjectDictionaryForKey("t", keyDecoder: { decoder in
|
||||
return decoder.decodeStringForKey("k", orElse: "")
|
||||
}, valueDecoder: { decoder in
|
||||
return Summary(decoder: decoder)
|
||||
})
|
||||
}
|
||||
|
||||
public func encode(_ encoder: PostboxEncoder) {
|
||||
encoder.encodeString(self.fromLang, forKey: "fl")
|
||||
if let summary = self.summary {
|
||||
encoder.encodeObject(summary, forKey: "s")
|
||||
} else {
|
||||
encoder.encodeNil(forKey: "s")
|
||||
}
|
||||
encoder.encodeObjectDictionary(self.translated, forKey: "t", keyEncoder: { k, e in
|
||||
e.encodeString(k, forKey: "k")
|
||||
})
|
||||
}
|
||||
|
||||
public static func ==(lhs: SummarizationMessageAttribute, rhs: SummarizationMessageAttribute) -> Bool {
|
||||
if lhs.fromLang != rhs.fromLang {
|
||||
return false
|
||||
}
|
||||
if lhs.summary != rhs.summary {
|
||||
return false
|
||||
}
|
||||
if lhs.translated != rhs.translated {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
public extension SummarizationMessageAttribute {
|
||||
func summaryForLang(_ lang: String?) -> Summary? {
|
||||
if let lang {
|
||||
return self.translated[lang]
|
||||
} else {
|
||||
return self.summary
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user