-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: remove openRoom meteor method
- Loading branch information
1 parent
d1e8497
commit 80e6842
Showing
12 changed files
with
95 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
apps/meteor/client/views/room/hooks/useOpenRoomMutation.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { useEndpoint, useUserId } from '@rocket.chat/ui-contexts'; | ||
import { useMutation } from '@tanstack/react-query'; | ||
|
||
import { ChatSubscription } from '../../../../app/models/client'; | ||
|
||
export const useOpenRoomMutation = () => { | ||
const openRoom = useEndpoint('POST', '/v1/rooms.open'); | ||
const userId = useUserId(); | ||
|
||
return useMutation({ | ||
mutationFn: async ({ roomId }: { roomId: string }) => { | ||
if (!userId) { | ||
throw new Error('error-invalid-user'); | ||
} | ||
|
||
await openRoom({ roomId }); | ||
return roomId; | ||
}, | ||
onSuccess: (roomId: string) => { | ||
ChatSubscription.update({ roomId, 'u._id': Meteor.userId() }, { $set: { open: true } }); | ||
}, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Subscriptions } from '@rocket.chat/models'; | ||
|
||
import { notifyOnSubscriptionChangedByRoomIdAndUserId } from '../../app/lib/server/lib/notifyListener'; | ||
|
||
export async function openRoom(userId: string, roomId: string) { | ||
check(userId, String); | ||
check(roomId, String); | ||
|
||
if (!roomId) { | ||
throw new Meteor.Error('error-invalid-room', 'Invalid room'); | ||
} | ||
|
||
if (!userId) { | ||
throw new Meteor.Error('error-invalid-user', 'Invalid user'); | ||
} | ||
|
||
const openByRoomResponse = await Subscriptions.openByRoomIdAndUserId(roomId, userId); | ||
|
||
if (openByRoomResponse.modifiedCount) { | ||
void notifyOnSubscriptionChangedByRoomIdAndUserId(roomId, userId); | ||
} | ||
|
||
return openByRoomResponse.modifiedCount; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters