mirror of
https://github.com/open-webui/open-webui.git
synced 2026-11-27 15:49:23 -05:00
fix: a note or channel link in a chat message opens beside the chat instead of replacing it (#34302)
This commit is contained in:
3 files changed
+15
-3
No files matched your search
@@ -3,10 +3,12 @@
|
||||
import { toast } from 'svelte-sonner';
|
||||
|
||||
import type { Token, Tokens } from 'marked';
|
||||
import type { AppLayoutContext } from '$lib/types';
|
||||
import { getContext } from 'svelte';
|
||||
import { goto } from '$app/navigation';
|
||||
|
||||
const i18n = getContext('i18n');
|
||||
const appLayout = getContext<AppLayoutContext | undefined>('appLayout');
|
||||
const terminalDocument = getContext<
|
||||
| {
|
||||
localPath: (ref: string) => string | null;
|
||||
@@ -86,7 +88,9 @@
|
||||
url.pathname.startsWith('/channels/'))
|
||||
) {
|
||||
e.preventDefault();
|
||||
goto(url.pathname + url.search + url.hash);
|
||||
if (appLayout?.openPageTab && !url.pathname.startsWith('/c/'))
|
||||
appLayout.openPageTab({ href: url.pathname + url.search + url.hash, label: '' });
|
||||
else goto(url.pathname + url.search + url.hash);
|
||||
}
|
||||
} catch {
|
||||
// Invalid URL, let browser handle it
|
||||
|
||||
@@ -22,10 +22,12 @@
|
||||
import { browser } from '$app/environment';
|
||||
|
||||
import { goto } from '$app/navigation';
|
||||
import type { AppLayoutContext } from '$lib/types';
|
||||
import { channels, models } from '$lib/stores';
|
||||
import UserStatusLinkPreview from '$lib/components/channel/Messages/Message/UserStatusLinkPreview.svelte';
|
||||
|
||||
const i18n = getContext<typeof import('$lib/i18n').default>('i18n');
|
||||
const appLayout = getContext<AppLayoutContext | undefined>('appLayout');
|
||||
|
||||
export let token: Tokens.Generic;
|
||||
|
||||
@@ -158,7 +160,9 @@
|
||||
if (idType === 'C') {
|
||||
// Open channel
|
||||
if ($channels.find((c) => c.id === id)) {
|
||||
await goto(`/channels/${id}`);
|
||||
if (appLayout?.openPageTab)
|
||||
appLayout.openPageTab({ href: `/channels/${id}`, label: '' });
|
||||
else await goto(`/channels/${id}`);
|
||||
}
|
||||
} else if (idType === 'T') {
|
||||
// Open thread
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
<script lang="ts">
|
||||
import { onMount, getContext } from 'svelte';
|
||||
import { goto } from '$app/navigation';
|
||||
import type { AppLayoutContext } from '$lib/types';
|
||||
import { getNoteById } from '$lib/apis/notes';
|
||||
import { getUserInfoById } from '$lib/apis/users';
|
||||
import { capitalizeFirstLetter } from '$lib/utils';
|
||||
|
||||
const i18n = getContext<typeof import('$lib/i18n').default>('i18n');
|
||||
const appLayout = getContext<AppLayoutContext | undefined>('appLayout');
|
||||
|
||||
export let noteId: string;
|
||||
export let href: string;
|
||||
@@ -50,7 +52,9 @@
|
||||
on:click|preventDefault|stopPropagation={() => {
|
||||
try {
|
||||
const url = new URL(href, window.location.origin);
|
||||
goto(url.pathname + url.search + url.hash);
|
||||
if (appLayout?.openPageTab)
|
||||
appLayout.openPageTab({ href: url.pathname + url.search + url.hash, label: '' });
|
||||
else goto(url.pathname + url.search + url.hash);
|
||||
} catch {
|
||||
// fallback
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user