From 84be956edac257de9c0d93c79f2dce3edd001693 Mon Sep 17 00:00:00 2001 From: Tasso Evangelista Date: Thu, 12 Jan 2023 16:07:58 -0300 Subject: [PATCH] Carry query string on setting location --- .../contextualBar/Threads/hooks/useGoToThread.ts | 6 +++--- .../Threads/hooks/useGoToThreadList.ts | 6 +++--- .../views/room/providers/ToolboxProvider.tsx | 15 +++++++++------ 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/apps/meteor/client/views/room/contextualBar/Threads/hooks/useGoToThread.ts b/apps/meteor/client/views/room/contextualBar/Threads/hooks/useGoToThread.ts index 722274021053..17b2601c6530 100644 --- a/apps/meteor/client/views/room/contextualBar/Threads/hooks/useGoToThread.ts +++ b/apps/meteor/client/views/room/contextualBar/Threads/hooks/useGoToThread.ts @@ -6,7 +6,7 @@ import { useRoom } from '../../../contexts/RoomContext'; export const useGoToThread = (): ((tmid: IMessage['_id']) => void) => { const room = useRoom(); - const [routeName, params] = useCurrentRoute(); + const [routeName, params, queryStringParams] = useCurrentRoute(); if (!routeName) { throw new Error('Route name is not defined'); @@ -16,8 +16,8 @@ export const useGoToThread = (): ((tmid: IMessage['_id']) => void) => { // TODO: remove params recycling return useCallback( (tmid) => { - roomRoute.replace({ rid: room._id, ...params, tab: 'thread', context: tmid }); + roomRoute.replace({ rid: room._id, ...params, tab: 'thread', context: tmid }, queryStringParams); }, - [room._id, params, roomRoute], + [room._id, params, queryStringParams, roomRoute], ); }; diff --git a/apps/meteor/client/views/room/contextualBar/Threads/hooks/useGoToThreadList.ts b/apps/meteor/client/views/room/contextualBar/Threads/hooks/useGoToThreadList.ts index 3c8f8d5a2978..795951132aa1 100644 --- a/apps/meteor/client/views/room/contextualBar/Threads/hooks/useGoToThreadList.ts +++ b/apps/meteor/client/views/room/contextualBar/Threads/hooks/useGoToThreadList.ts @@ -5,7 +5,7 @@ import { useRoom } from '../../../contexts/RoomContext'; export const useGoToThreadList = (): (() => void) => { const room = useRoom(); - const [routeName, { context, ...params } = { context: '' }] = useCurrentRoute(); + const [routeName, { context, ...params } = { context: '' }, queryStringParams] = useCurrentRoute(); if (!routeName) { throw new Error('Route name is not defined'); @@ -13,6 +13,6 @@ export const useGoToThreadList = (): (() => void) => { const roomRoute = useRoute(routeName); return useCallback(() => { - roomRoute.replace({ rid: room._id, ...params, tab: 'thread' }); - }, [room._id, roomRoute, params]); + roomRoute.replace({ rid: room._id, ...params, tab: 'thread' }, queryStringParams); + }, [room._id, roomRoute, params, queryStringParams]); }; diff --git a/apps/meteor/client/views/room/providers/ToolboxProvider.tsx b/apps/meteor/client/views/room/providers/ToolboxProvider.tsx index da814af11939..7021005ffaf4 100644 --- a/apps/meteor/client/views/room/providers/ToolboxProvider.tsx +++ b/apps/meteor/client/views/room/providers/ToolboxProvider.tsx @@ -21,7 +21,7 @@ const ToolboxProvider = ({ children, room }: { children: ReactNode; room: IRoom }); const { listen, actions } = useToolboxActions(room); - const [routeName, params] = useCurrentRoute(); + const [routeName, params, queryStringParams] = useCurrentRoute(); const router = useRoute(routeName || ''); const tab = params?.tab; @@ -33,11 +33,14 @@ const ToolboxProvider = ({ children, room }: { children: ReactNode; room: IRoom ); const close = useMutableCallback(() => { - router.push({ - ...params, - tab: '', - context: '', - }); + router.push( + { + ...params, + tab: '', + context: '', + }, + queryStringParams, + ); }); const open = useMutableCallback((actionId: string, context?: string) => {