[IMPROVEMENT] Remove redundant `await` on synchronous `userPreferences.getBool` in `getUsersPresence`
Maintainers usually reply within 1 day
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
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:
developbranch - Device Name: All
- OS Version: iOS / Android
Steps to reproduce:
- Open
app/lib/methods/getUsersPresence.tslines 140–151. - Note that
userPreferences.getBoolis called withawait. - Check definition of
userPreferences.getBoolinapp/lib/methods/userPreferences.ts: it synchronously returnsboolean | 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:
- In
app/lib/methods/getUsersPresence.ts, removeawaiton line 142. - Remove
asynckeyword fromsetPresenceCapon line 140. - 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
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from RocketChat/Rocket.Chat.ReactNative
-
UIKit modal: a viewSubmit response with no `type` field fails to close the modal on mobile (regression from #7057)Possibly taken @erikurt9 claimed this 106 days ago. Opentype: bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
RocketChat/Rocket.Chat.ReactNative#7503 · 3 comments · 1 reaction ·
Maintainers usually reply within 1 day
-
type: bug
Difficulty 1/5 Under an hour Newbie friendliness 86/100
RocketChat/Rocket.Chat.ReactNative#7437 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
-
✅ tests 👷 ci type: feature
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
RocketChat/Rocket.Chat.ReactNative#7247 · 1 comment ·
Maintainers usually reply within 1 day
-
bug: goRoom navigates to broken RoomView after failed DM creation from searchPossibly taken @deepak0x claimed this 215 days ago. Opentype: bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
RocketChat/Rocket.Chat.ReactNative#7098 ·
Maintainers usually reply within 1 day
-
bug: useSubscriptions re-queries WatermelonDB on every server connection state change, causing unnecessary rooms list flickerPossibly taken @deepak0x claimed this 226 days ago. Opentype: bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
RocketChat/Rocket.Chat.ReactNative#7093 ·
Maintainers usually reply within 1 day
All issues in RocketChat/Rocket.Chat.ReactNative
Similar issues
-
bug
Difficulty 2/5 Half a day Newbie friendliness 68/100
amosblomqvist/learnharness#758 ·
Maintainers usually reply within 2 days
-
Change WorkspacesOpen
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
bitfocus/companion-module-renewedvision-propresenter-api#134 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
rcpch/digital-growth-charts-react-component-library#304 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
dsh-market/dsh-market#1210 · 1 comment ·
Maintainers usually reply within 1 day
-
good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
trustjonathan/STUDY-HUB#13 ·