[IMPROVEMENT] Remove redundant `await` on synchronous `userPreferences.getBool` in `getUsersPresence`

Open Beginner friendly
#7,737 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@cynicalmindset is already working on this.

Since Sep 28, 2026.

  • #7738 by @cynicalmindset — open

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
92/100
Issue type
Refactor
Clarity
Clearly specified
Activity status
Active
Tech stack
react-native, typescript
Domain
mobile

Research direction

Start in app/lib/methods/getUsersPresence.ts at setPresenceCap, then check app/lib/methods/userPreferences.ts to confirm getBool is synchronous. Review callers in app/lib/methods/getSettings.ts and app/lib/services/connect.ts, remove the unnecessary async handling, and run pnpm lint (oxlint && tsc) to verify completion.

Written by the indexing model from the issue text.

Description

type: feature
Description:

In app/lib/methods/getUsersPresence.ts, the setPresenceCap function contains an unnecessary await when calling userPreferences.getBool(NOTIFICATION_PRESENCE_CAP).

UserPreferences is backed by react-native-mmkv, where getBool(key) is completely synchronous and returns boolean | null (not a Promise). Awaiting a synchronous non-Promise value is redundant, flags @typescript-eslint/await-thenable, and adds unnecessary microtask overhead to an otherwise synchronous routine.

Environment Information:
  • Rocket.Chat Server Version: N/A (Client TypeScript codebase)
  • Rocket.Chat App Version: develop branch
  • Device Name: All
  • OS Version: iOS / Android
Steps to reproduce:
  1. Open app/lib/methods/getUsersPresence.ts lines 140–151.
  2. Note that userPreferences.getBool is called with await.
  3. Check definition of userPreferences.getBool in app/lib/methods/userPreferences.ts: it synchronously returns boolean | null.
Expected behavior:

userPreferences.getBool(NOTIFICATION_PRESENCE_CAP) should be evaluated synchronously without await. Since all internal operations in setPresenceCap are synchronous, the async modifier should also be removed.

Actual behavior:

A non-Promise return value (boolean | null) is awaited using await, and setPresenceCap is unnecessarily declared as async.

Proposed Solution & Approach:
  1. In app/lib/methods/getUsersPresence.ts, remove await on line 142.
  2. Remove async keyword from setPresenceCap on line 140.
  3. Verify that pnpm lint (oxlint && tsc) passes without errors.
Additional context:

All external callers in the codebase (app/lib/methods/getSettings.ts line 186 and app/lib/services/connect.ts line 349) already invoke setPresenceCap(...) synchronously without await. Making setPresenceCap strictly synchronous aligns the implementation with its callers and avoids microtask scheduling.

Dominant language
TypeScript
Stars
2.4k
Forks
1.5k
Avg merge
1d 15h
Merged PRs (30d)
29

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from RocketChat/Rocket.Chat.ReactNative

All issues in RocketChat/Rocket.Chat.ReactNative

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.