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

オープン 初心者向け
#7,737 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@cynicalmindset がすでに取り組んでいます。

2026年9月28日 から。

  • #7738 @cynicalmindset による — オープン

評価

難易度
1/5
見積もり時間
1時間未満
初心者へのやさしさ
92/100
issue の種類
リファクタリング
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
react-native, typescript
領域
mobile

調査の方向性

app/lib/methods/getUsersPresence.ts の setPresenceCap から始め、次に app/lib/methods/userPreferences.ts を確認して getBool が同期的であることを確認します。app/lib/methods/getSettings.ts と app/lib/services/connect.ts の呼び出し元を確認し、不要な非同期処理を削除して、pnpm lint (oxlint && tsc) を実行して完了を確認します。

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
TypeScript
スター
2.4k
フォーク
1.5k
平均マージ
1日 15時間
マージ済み PR(30日)
29

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

RocketChat/Rocket.Chat.ReactNative のほかの issue

RocketChat/Rocket.Chat.ReactNative の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。