refactor(chat): show images in page overlay
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import { ROUTES } from "@/router/routes";
|
||||
|
||||
export const CHAT_IMAGE_QUERY_PARAM = "image";
|
||||
|
||||
export function getChatImageOverlayMessageId(input: {
|
||||
get: (key: string) => string | null;
|
||||
}): string | null {
|
||||
const value = input.get(CHAT_IMAGE_QUERY_PARAM)?.trim();
|
||||
return value && value.length > 0 ? value : null;
|
||||
}
|
||||
|
||||
export function buildChatImageOverlayUrl(messageId: string): `/chat?${string}` {
|
||||
const params = new URLSearchParams({
|
||||
[CHAT_IMAGE_QUERY_PARAM]: messageId,
|
||||
});
|
||||
return `${ROUTES.chat}?${params.toString()}` as const;
|
||||
}
|
||||
|
||||
export function buildChatWithoutImageOverlayUrl(input: {
|
||||
toString: () => string;
|
||||
}): string {
|
||||
const params = new URLSearchParams(input.toString());
|
||||
params.delete(CHAT_IMAGE_QUERY_PARAM);
|
||||
const query = params.toString();
|
||||
return query ? `${ROUTES.chat}?${query}` : ROUTES.chat;
|
||||
}
|
||||
Reference in New Issue
Block a user