27 lines
832 B
TypeScript
27 lines
832 B
TypeScript
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;
|
|
}
|