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:
- Open
app/lib/methods/getUsersPresence.ts lines 140–151.
- Note that
userPreferences.getBool is called with await.
- 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:
- In
app/lib/methods/getUsersPresence.ts, remove await on line 142.
- Remove
async keyword from setPresenceCap on 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.
Description:
In
app/lib/methods/getUsersPresence.ts, thesetPresenceCapfunction contains an unnecessaryawaitwhen callinguserPreferences.getBool(NOTIFICATION_PRESENCE_CAP).UserPreferencesis backed byreact-native-mmkv, wheregetBool(key)is completely synchronous and returnsboolean | 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:
developbranchSteps to reproduce:
app/lib/methods/getUsersPresence.tslines 140–151.userPreferences.getBoolis called withawait.userPreferences.getBoolinapp/lib/methods/userPreferences.ts: it synchronously returnsboolean | null.Expected behavior:
userPreferences.getBool(NOTIFICATION_PRESENCE_CAP)should be evaluated synchronously withoutawait. Since all internal operations insetPresenceCapare synchronous, theasyncmodifier should also be removed.Actual behavior:
A non-Promise return value (
boolean | null) is awaited usingawait, andsetPresenceCapis unnecessarily declared asasync.Proposed Solution & Approach:
app/lib/methods/getUsersPresence.ts, removeawaiton line 142.asynckeyword fromsetPresenceCapon line 140.pnpm lint(oxlint && tsc) passes without errors.Additional context:
All external callers in the codebase (
app/lib/methods/getSettings.tsline 186 andapp/lib/services/connect.tsline 349) already invokesetPresenceCap(...)synchronously withoutawait. MakingsetPresenceCapstrictly synchronous aligns the implementation with its callers and avoids microtask scheduling.