Skip to content
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

[FIX] Carry query string on setting location #27742

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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],
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ 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');
}

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]);
};
15 changes: 9 additions & 6 deletions apps/meteor/client/views/room/providers/ToolboxProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) => {
Expand Down