Skip to content

fix: avatar update not reflecting in ProfileView and SidebarView - #7430

Merged
OtavioStasiak merged 3 commits into
developfrom
fix.profileview-avatar-update
Jun 24, 2026
Merged

fix: avatar update not reflecting in ProfileView and SidebarView#7430
OtavioStasiak merged 3 commits into
developfrom
fix.profileview-avatar-update

Conversation

@OtavioStasiak

@OtavioStasiak OtavioStasiak commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Proposed changes

When the logged-in user changes their avatar, the updateAvatar event from stream-notify-logged only updated the WatermelonDB users record. The logged-user record observed by useAvatarETag was never refreshed, so the avatar stayed stale in ProfileView, SidebarView, etc. until a reconnect.

This change dispatches setUser({ avatarETag }) when the updateAvatar event belongs to the logged user, pushing the new etag through Redux so the avatar updates immediately across the app. The existing users-DB update is preserved.

Added unit tests in connect.test.ts covering the new behavior: dispatch for the logged user, no dispatch for other users or when no user is logged in, and that the DB record is still updated.

Issue(s)

https://rocketchat.atlassian.net/browse/NATIVE-1171

How to test or reproduce

  • Open the app;
  • Update avatar;
  • Back to profileview and open sidebar;

Screenshots

Before After
before after

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • Improvement (non-breaking change which improves a current function)
  • New feature (non-breaking change which adds functionality)
  • Documentation update (if none of the other choices apply)

Checklist

  • I have read the CONTRIBUTING doc
  • I have signed the CLA
  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works (if applicable)
  • I have added necessary documentation (if applicable)
  • Any dependent changes have been merged and published in downstream modules

Further comments

Summary by CodeRabbit

  • Bug Fixes
    • Avatar updates now refresh the logged-in user’s profile image data immediately when a matching account receives an update.
    • Avatar changes are ignored for other accounts, preventing incorrect updates.
    • Added coverage to verify avatar update behavior with and without an active logged-in user.

@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6b54db59-35ce-4bd7-bea9-e46428f6dda8

📥 Commits

Reviewing files that changed from the base of the PR and between 3e15245 and 473c654.

📒 Files selected for processing (2)
  • app/lib/services/connect.test.ts
  • app/lib/services/connect.ts
📜 Recent review details
⏰ Context from checks skipped due to timeout. (2)
  • GitHub Check: ESLint and Test / run-eslint-and-test
  • GitHub Check: format
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{js,ts,jsx,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{js,ts,jsx,tsx}: Use descriptive names for functions, variables, and classes that clearly convey their purpose
Write comments that explain the 'why' behind code decisions, not the 'what'
Keep functions small and focused on a single responsibility
Use const by default, let when reassignment is needed, and avoid var
Prefer async/await over .then() chains for handling asynchronous operations
Use explicit error handling with try/catch blocks for async operations
Avoid deeply nested code; refactor complex logic into helper functions

Files:

  • app/lib/services/connect.test.ts
  • app/lib/services/connect.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Use TypeScript for type safety; add explicit type annotations to function parameters and return types
Prefer interfaces over type aliases for defining object shapes in TypeScript
Use enums for sets of related constants rather than magic strings or numbers

Use TypeScript with strict mode enabled

Files:

  • app/lib/services/connect.test.ts
  • app/lib/services/connect.ts
**/*.{js,jsx,ts,tsx,json}

📄 CodeRabbit inference engine (CLAUDE.md)

Use Prettier formatting with tabs, single quotes, 130 character line width, no trailing commas, and avoid arrow function parentheses

Files:

  • app/lib/services/connect.test.ts
  • app/lib/services/connect.ts
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

Enforce ESLint rules from @rocket.chat/eslint-config with React, React Native, TypeScript, and Jest plugins

Files:

  • app/lib/services/connect.test.ts
  • app/lib/services/connect.ts
app/lib/services/connect.ts

📄 CodeRabbit inference engine (CLAUDE.md)

Use 'app/lib/services/connect.ts' for server connection management

Files:

  • app/lib/services/connect.ts
🧠 Learnings (1)
📚 Learning: 2026-04-30T17:07:51.020Z
Learnt from: diegolmello
Repo: RocketChat/Rocket.Chat.ReactNative PR: 7274
File: app/lib/services/voip/MediaCallEvents.ts:0-0
Timestamp: 2026-04-30T17:07:51.020Z
Learning: In this Rocket.Chat React Native codebase, the ESLint rule `no-void: error` is enforced. When you see a promise returned from an async call that is not awaited (a “floating promise”), do not silence it with the `void somePromise()` pattern. Instead, handle the promise explicitly by attaching `.catch(...)` (or otherwise awaiting/handling the error) so unhandled-rejection risks are addressed in a way that satisfies the existing ESLint configuration.

Applied to files:

  • app/lib/services/connect.test.ts
  • app/lib/services/connect.ts
🔇 Additional comments (2)
app/lib/services/connect.ts (1)

250-258: LGTM!

app/lib/services/connect.test.ts (1)

5-6: LGTM!

Also applies to: 517-603


Walkthrough

The updateAvatar handler now dispatches setUser with the new avatarETag when the event username matches the logged-in user. Tests cover matching, mismatching, and no-user cases, and still verify the database update path.

Changes

Avatar ETag Redux Dispatch

Layer / File(s) Summary
updateAvatar handler dispatch and tests
app/lib/services/connect.ts, app/lib/services/connect.test.ts
connect.ts conditionally dispatches setUser({ avatarETag }) for matching logged-in users, and connect.test.ts adds coverage for matching, mismatching, and missing-user updateAvatar events with database-backed assertions.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested labels

type: bug

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main fix: avatar updates now propagate immediately to the user-facing views.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (2)
  • NATIVE-1171: Request failed with status code 401
  • D760B1C6-3071: Request failed with status code 401

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@OtavioStasiak
OtavioStasiak temporarily deployed to approve_e2e_testing June 23, 2026 17:21 — with GitHub Actions Inactive
@OtavioStasiak
OtavioStasiak marked this pull request as ready for review June 23, 2026 17:56
@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Caution

Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted.

Error details
{}

@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Caution

Review failed

An error occurred during the review process. Please try again later.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants