-
Notifications
You must be signed in to change notification settings - Fork 13k
chore: Replace Meteor.userId() for client code
#36911
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
f40645a
8d653b0
de4d233
9128d5f
7a7307e
61eaee7
3b40ed6
6571ff6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,9 +1,9 @@ | ||||||||||||||||||||||||
| import type { IExtras, IRoomActivity, IUser } from '@rocket.chat/core-typings'; | ||||||||||||||||||||||||
| import { Emitter } from '@rocket.chat/emitter'; | ||||||||||||||||||||||||
| import { debounce } from 'lodash'; | ||||||||||||||||||||||||
| import { Meteor } from 'meteor/meteor'; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| import { settings } from '../../../../client/lib/settings'; | ||||||||||||||||||||||||
| import { getUser, getUserId } from '../../../../client/lib/user'; | ||||||||||||||||||||||||
| import { Users } from '../../../../client/stores'; | ||||||||||||||||||||||||
| import { sdk } from '../../../utils/client/lib/SDKClient'; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
|
@@ -40,7 +40,7 @@ const shownName = function (user: IUser | null | undefined): string | undefined | |||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| const emitActivities = debounce(async (rid: string, extras: IExtras): Promise<void> => { | ||||||||||||||||||||||||
| const activities = roomActivities.get(extras?.tmid || rid) || new Set(); | ||||||||||||||||||||||||
| sdk.publish('notify-room', [`${rid}/${USER_ACTIVITY}`, shownName(Meteor.user() as unknown as IUser), [...activities], extras]); | ||||||||||||||||||||||||
| sdk.publish('notify-room', [`${rid}/${USER_ACTIVITY}`, shownName(getUser()), [...activities], extras]); | ||||||||||||||||||||||||
| }, 500); | ||||||||||||||||||||||||
|
Comment on lines
41
to
44
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Guard against undefined username in activity broadcast
- sdk.publish('notify-room', [`${rid}/${USER_ACTIVITY}`, shownName(getUser()), [...activities], extras]);
+ const username = shownName(getUser());
+ if (!username) return;
+ sdk.publish('notify-room', [`${rid}/${USER_ACTIVITY}`, username, [...activities], extras]);📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| function handleStreamAction(rid: string, username: string, activityTypes: string[], extras?: IExtras): void { | ||||||||||||||||||||||||
|
|
@@ -74,7 +74,7 @@ export const UserAction = new (class { | |||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| const handler = function (username: string, activityType: string[], extras?: object): void { | ||||||||||||||||||||||||
| const uid = Meteor.userId(); | ||||||||||||||||||||||||
| const uid = getUserId(); | ||||||||||||||||||||||||
| const user = uid ? Users.state.get(uid) : undefined; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| if (username === shownName(user)) { | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ import type { IOmnichannelRoom, IRoom, IRoomWithRetentionPolicy } from '@rocket. | |
| import { DEFAULT_SLA_CONFIG, isRoomNativeFederated, LivechatPriorityWeight } from '@rocket.chat/core-typings'; | ||
| import type { SubscriptionWithRoom } from '@rocket.chat/ui-contexts'; | ||
|
|
||
| import { PrivateCachedStore } from '../lib/cachedStores'; | ||
| import { PrivateCachedStore } from '../lib/cachedStores/CachedStore'; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion 🧩 Analysis chainImport path migration looks correct; verify consistent exports/usages repo-wide. Directly importing from the concrete module reduces barrel coupling and potential cycles. Please confirm the symbol is a named export at the new path and that no files still import from the old barrel. Run: 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "1) Confirm PrivateCachedStore is exported from CachedStore.ts"
rg -nP '\bexport\b[^{\n]*\bPrivateCachedStore\b|\bexport\s*{\s*[^}]*\bPrivateCachedStore\b' -g '**/CachedStore.ts'
echo "2) Find lingering barrel imports from ../lib/cachedStores"
rg -nP --type ts --type tsx -n -C1 "from ['\"]\.\.\/lib\/cachedStores['\"]"
echo "3) Detect default imports of PrivateCachedStore (should be named)"
rg -nP --type ts --type tsx -n "import\s+PrivateCachedStore\s+from"
echo "4) Confirm consistent direct imports to CachedStore"
rg -nP --type ts --type tsx -n -C1 "from ['\"][^\"]*lib\/cachedStores\/CachedStore['\"]"Length of output: 298 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "1) Confirm PrivateCachedStore is exported (show surrounding lines)"
rg -nP -C2 "export\s+class\s+PrivateCachedStore\b" apps/meteor/client/lib/cachedStores/CachedStore.ts || true
echo
echo "2) Find imports that reference 'lib/cachedStores' but NOT '/CachedStore' (possible barrel/index imports)"
rg -nP -C1 "from\s+['\"][^'\"]*lib\/cachedStores(?!\/CachedStore)[^'\"]*['\"]" || true
echo
echo "3) Find direct imports from 'lib/cachedStores/CachedStore'"
rg -nP -C1 "from\s+['\"][^'\"]*lib\/cachedStores\/CachedStore['\"]" || true
echo
echo "4) Detect default imports of PrivateCachedStore"
rg -nP -n "import\s+PrivateCachedStore\s+from\s+['\"][^'\"]+['\"]" || true
echo
echo "5) List any occurrences of 'lib/cachedStores' for manual inspection"
rg -nP -n -C1 "lib\/cachedStores" || trueLength of output: 8527 PrivateCachedStore is a named export; update remaining barrel imports
🤖 Prompt for AI Agents |
||
| import { Rooms, Subscriptions } from '../stores'; | ||
|
|
||
| class RoomsCachedStore extends PrivateCachedStore<IRoom> { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reset user-dependent globals on logout to avoid stale language/username.
When
watchUser()becomesundefined(logout),userLanguageandusernamekeep the last values, affecting translations until reload.Apply this diff:
📝 Committable suggestion
🤖 Prompt for AI Agents