Skip to content

Commit 7b72c1a

Browse files
author
Isaac
committed
Monoforums
1 parent da477ec commit 7b72c1a

File tree

11 files changed

+636
-224
lines changed

11 files changed

+636
-224
lines changed

submodules/ContactsPeerItem/Sources/ContactsPeerItem.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,11 @@ public class ContactsPeerItemNode: ItemListRevealOptionsItemNode {
933933
} else if case let .legacyGroup(group) = peer {
934934
titleAttributedString = NSAttributedString(string: group.title, font: titleBoldFont, textColor: item.presentationData.theme.list.itemPrimaryTextColor)
935935
} else if case let .channel(channel) = peer {
936-
titleAttributedString = NSAttributedString(string: channel.title, font: titleBoldFont, textColor: item.presentationData.theme.list.itemPrimaryTextColor)
936+
if case let .channel(mainChannel) = chatPeer, mainChannel.isMonoForum {
937+
titleAttributedString = NSAttributedString(string: item.presentationData.strings.Monoforum_NameFormat(channel.title).string, font: titleBoldFont, textColor: item.presentationData.theme.list.itemPrimaryTextColor)
938+
} else {
939+
titleAttributedString = NSAttributedString(string: channel.title, font: titleBoldFont, textColor: item.presentationData.theme.list.itemPrimaryTextColor)
940+
}
937941
}
938942

939943
switch item.status {

submodules/TelegramApi/Sources/Api38.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3240,6 +3240,22 @@ public extension Api.functions.channels {
32403240
})
32413241
}
32423242
}
3243+
public extension Api.functions.channels {
3244+
static func getMessageAuthor(channel: Api.InputChannel, id: Int32) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.User>) {
3245+
let buffer = Buffer()
3246+
buffer.appendInt32(-320691994)
3247+
channel.serialize(buffer, true)
3248+
serializeInt32(id, buffer: buffer, boxed: false)
3249+
return (FunctionDescription(name: "channels.getMessageAuthor", parameters: [("channel", String(describing: channel)), ("id", String(describing: id))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.User? in
3250+
let reader = BufferReader(buffer)
3251+
var result: Api.User?
3252+
if let signature = reader.readInt32() {
3253+
result = Api.parse(reader, signature: signature) as? Api.User
3254+
}
3255+
return result
3256+
})
3257+
}
3258+
}
32433259
public extension Api.functions.channels {
32443260
static func getMessages(channel: Api.InputChannel, id: [Api.InputMessage]) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.messages.Messages>) {
32453261
let buffer = Buffer()

submodules/TelegramCore/Sources/TelegramEngine/Messages/TelegramEngineMessages.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1575,5 +1575,9 @@ public extension TelegramEngine {
15751575
return filteredResult
15761576
}
15771577
}
1578+
1579+
public func requestMessageAuthor(id: EngineMessage.Id) -> Signal<EnginePeer?, NoError> {
1580+
return _internal_requestMessageAuthor(account: self.account, id: id)
1581+
}
15781582
}
15791583
}

submodules/TelegramCore/Sources/TelegramEngine/Peers/SearchPeers.swift

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,3 +156,31 @@ func _internal_searchLocalSavedMessagesPeers(account: Account, query: String, in
156156
return transaction.searchSubPeers(peerId: account.peerId, query: query, indexNameMapping: indexNameMapping).map(EnginePeer.init)
157157
}
158158
}
159+
160+
func _internal_requestMessageAuthor(account: Account, id: EngineMessage.Id) -> Signal<EnginePeer?, NoError> {
161+
return account.postbox.transaction { transaction -> Api.InputChannel? in
162+
return transaction.getPeer(id.peerId).flatMap(apiInputChannel)
163+
}
164+
|> mapToSignal { inputChannel -> Signal<EnginePeer?, NoError> in
165+
guard let inputChannel else {
166+
return .single(nil)
167+
}
168+
if id.namespace != Namespaces.Message.Cloud {
169+
return .single(nil)
170+
}
171+
return account.network.request(Api.functions.channels.getMessageAuthor(channel: inputChannel, id: id.id))
172+
|> map(Optional.init)
173+
|> `catch` { _ -> Signal<Api.User?, NoError> in
174+
return .single(nil)
175+
}
176+
|> mapToSignal { user -> Signal<EnginePeer?, NoError> in
177+
guard let user else {
178+
return .single(nil)
179+
}
180+
return account.postbox.transaction { transaction -> EnginePeer? in
181+
updatePeers(transaction: transaction, accountPeerId: account.peerId, peers: AccumulatedPeers(users: [user]))
182+
return transaction.getPeer(user.peerId).flatMap(EnginePeer.init)
183+
}
184+
}
185+
}
186+
}

submodules/TelegramPresentationData/Sources/Resources/PresentationResourcesSettings.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public struct PresentationResourcesSettings {
8585
public static let balance = renderIcon(name: "Settings/Menu/Balance", scaleFactor: 0.97, backgroundColors: [UIColor(rgb: 0x34c759)])
8686
public static let affiliateProgram = renderIcon(name: "Settings/Menu/AffiliateProgram")
8787
public static let earnStars = renderIcon(name: "Settings/Menu/EarnStars")
88-
public static let channelMessages = renderIcon(name: "Chat/Info/ChannelMessages", backgroundColors: [UIColor(rgb: 0xFF9500)])
88+
public static let channelMessages = renderIcon(name: "Chat/Info/ChannelMessages", backgroundColors: [UIColor(rgb: 0x5856D6)])
8989

9090
public static let premium = generateImage(CGSize(width: 29.0, height: 29.0), contextGenerator: { size, context in
9191
let bounds = CGRect(origin: CGPoint(), size: size)

0 commit comments

Comments
 (0)