-
Notifications
You must be signed in to change notification settings - Fork 11k
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 client meteor method (#33833)
- Loading branch information
1 parent
85980d7
commit 7f22793
Showing
10 changed files
with
138 additions
and
40 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 was deleted.
Oops, something went wrong.
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
32 changes: 32 additions & 0 deletions
32
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,32 @@ | ||
import { useEndpoint } from '@rocket.chat/ui-contexts'; | ||
import { useMutation } from '@tanstack/react-query'; | ||
|
||
import { updateSubscription } from '../../../lib/mutationEffects/updateSubscription'; | ||
|
||
type OpenRoomParams = { | ||
roomId: string; | ||
userId: string; | ||
}; | ||
|
||
export const useOpenRoomMutation = () => { | ||
const openRoom = useEndpoint('POST', '/v1/rooms.open'); | ||
|
||
return useMutation({ | ||
mutationFn: async ({ roomId, userId }: OpenRoomParams) => { | ||
await openRoom({ roomId }); | ||
|
||
return { userId, roomId }; | ||
}, | ||
onMutate: async ({ roomId, userId }) => { | ||
return updateSubscription(roomId, userId, { open: true }); | ||
}, | ||
onError: async (_, { roomId, userId }, rollbackDocument) => { | ||
if (!rollbackDocument) { | ||
return; | ||
} | ||
|
||
const { open } = rollbackDocument; | ||
await updateSubscription(roomId, userId, { open }); | ||
}, | ||
}); | ||
}; |
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,13 @@ | ||
import { Subscriptions } from '@rocket.chat/models'; | ||
|
||
import { notifyOnSubscriptionChangedByRoomIdAndUserId } from '../../app/lib/server/lib/notifyListener'; | ||
|
||
export async function openRoom(userId: string, roomId: string) { | ||
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 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