Skip to content

Commit ce54e24

Browse files
Forum topics fixes: link opening, WebP sticker crash, reaction badge
- Fix forum message link opening: load forum topic when messageTopicId is set but forumTopic is null (shows correct topic header) - Fix WebP sticker crash in ChatHeaderView: check sticker.format instead of sticker.fullType to determine ImageFile vs GifFile - Fix reaction badge icon size: use 16f to match TGChat pattern 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 57bc7df commit ce54e24

3 files changed

Lines changed: 42 additions & 13 deletions

File tree

app/src/main/java/org/thunderdog/challegram/component/chat/ChatHeaderView.java

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -109,18 +109,26 @@ private void loadTopicEmojiFiles () {
109109
}
110110

111111
int size = Screen.dp(40f); // Avatar size
112-
if (sticker.fullType instanceof TdApi.StickerFullTypeRegular) {
113-
topicImageFile = new ImageFile(tdlib, sticker.sticker);
114-
topicImageFile.setSize(size);
115-
topicImageFile.setScaleType(ImageFile.CENTER_CROP);
116-
topicGifFile = null;
117-
topicIconReceiver.getImageReceiver(0).requestFile(topicImageFile);
118-
} else {
119-
topicGifFile = new GifFile(tdlib, sticker);
120-
topicGifFile.setOptimizationMode(GifFile.OptimizationMode.EMOJI);
121-
topicGifFile.setRequestedSize(size);
122-
topicImageFile = null;
123-
topicIconReceiver.getGifReceiver(0).requestFile(topicGifFile);
112+
// Check sticker format to determine file type
113+
// WebP stickers use ImageFile, TGS and WEBM use GifFile
114+
switch (sticker.format.getConstructor()) {
115+
case TdApi.StickerFormatWebp.CONSTRUCTOR: {
116+
topicImageFile = new ImageFile(tdlib, sticker.sticker);
117+
topicImageFile.setSize(size);
118+
topicImageFile.setScaleType(ImageFile.CENTER_CROP);
119+
topicGifFile = null;
120+
topicIconReceiver.getImageReceiver(0).requestFile(topicImageFile);
121+
break;
122+
}
123+
case TdApi.StickerFormatTgs.CONSTRUCTOR:
124+
case TdApi.StickerFormatWebm.CONSTRUCTOR: {
125+
topicGifFile = new GifFile(tdlib, sticker);
126+
topicGifFile.setOptimizationMode(GifFile.OptimizationMode.EMOJI);
127+
topicGifFile.setRequestedSize(size);
128+
topicImageFile = null;
129+
topicIconReceiver.getGifReceiver(0).requestFile(topicGifFile);
130+
break;
131+
}
124132
}
125133
}
126134

app/src/main/java/org/thunderdog/challegram/ui/ForumTopicView.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,10 +280,11 @@ public void setTopic (Tdlib tdlib, TdApi.ForumTopic topic, @Nullable String high
280280
}
281281

282282
// Reactions counter - show if there are unread reactions
283+
// Using same pattern as TGChat: baseline_favorite_14 icon at 16f size
283284
if (topic.unreadReactionCount > 0) {
284285
if (reactionsCounter == null) {
285286
reactionsCounter = new Counter.Builder()
286-
.drawable(R.drawable.baseline_favorite_14, 14f, 0f, Gravity.CENTER)
287+
.drawable(R.drawable.baseline_favorite_14, 16f, 0f, Gravity.CENTER)
287288
.callback(this)
288289
.build();
289290
}

app/src/main/java/org/thunderdog/challegram/ui/MessagesController.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2818,6 +2818,26 @@ private void updateView () {
28182818
updateForcedSubtitle(); // must be called before calling headerCell.setChat
28192819
headerCell.setCallback(areScheduled ? null : this);
28202820
}
2821+
2822+
// Load forum topic if we have a messageTopicId but no forumTopic
2823+
// This happens when opening a message via link in a forum
2824+
if (forumTopic == null && messageTopicId != null &&
2825+
messageTopicId.getConstructor() == TdApi.MessageTopicForum.CONSTRUCTOR) {
2826+
long forumTopicId = ((TdApi.MessageTopicForum) messageTopicId).messageThreadId;
2827+
tdlib.client().send(new TdApi.GetForumTopic(chat.id, (int) forumTopicId), result -> {
2828+
if (result.getConstructor() == TdApi.ForumTopic.CONSTRUCTOR) {
2829+
runOnUiThreadOptional(() -> {
2830+
forumTopic = (TdApi.ForumTopic) result;
2831+
// Update header with loaded topic
2832+
TdApi.Chat hChat = messageThread != null ? tdlib.chatSync(messageThread.getContextChatId()) : null;
2833+
headerCell.setChat(tdlib, hChat != null ? hChat : chat, messageThread, forumTopic);
2834+
// Update unread counts
2835+
updateCounters(true);
2836+
});
2837+
}
2838+
});
2839+
}
2840+
28212841
TdApi.Chat headerChat = messageThread != null ? tdlib.chatSync(messageThread.getContextChatId()) : null;
28222842
headerCell.setChat(tdlib, headerChat != null ? headerChat : chat, messageThread, forumTopic);
28232843

0 commit comments

Comments
 (0)