Skip to content

Fix forum topic read state on close - #13

Merged
AbdulKus merged 1 commit into
mainfrom
fix/topic-read-state
Aug 10, 2026
Merged

Fix forum topic read state on close#13
AbdulKus merged 1 commit into
mainfrom
fix/topic-read-state

Conversation

@AbdulKus

Copy link
Copy Markdown
Owner

Причина

При потере фокуса MessagesManager сначала выставлял isFocused = false, а затем пытался сохранить состояние. Из-за проверок allowViewRequest() и saveScrollPosition() финальный ViewMessages и topic-specific scroll anchor отбрасывались.

Кроме того, viewport мог уже снять флаг recent после асинхронного запроса, поэтому повторный flush не всегда включал видимые сообщения.

Исправление

  • read/scroll state сбрасывается до снятия focus
  • при уходе отправляются все фактически видимые сообщения с текущим topic message source и forceRead=true
  • общий flush используется при закрытии, уничтожении экрана и переключении топика
  • исправление одинаково работает для обычного и закреплённого топика

Проверка

  • git diff --check
  • полный ARM64 release build запускается GitHub Actions

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a6a26cfc92

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +2582 to +2583
if (messageViewer != null && canRead()) {
loader.viewport().viewMessages(false, true, null);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Respect focus before forcing topic reads

When prepareForTopicSwitch() is invoked while the controller is unfocused, this direct call bypasses the viewport callback's allowViewRequest() check and marks every tracked message as read because canRead() does not test focus. This can occur, for example, when the asynchronous DeleteForumTopic response in MessagesController calls setForumTopic(null) after the user has already navigated away, potentially marking messages loaded while the screen was in the background as read. Guard the forced submission with the manager's focused state while retaining it for the blur/destroy paths, which deliberately flush before clearing that state.

Useful? React with 👍 / 👎.

@AbdulKus
AbdulKus merged commit c8d1f52 into main Aug 10, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant