fix: keep the workspace tab counts in sync with each section's list (#28983)
This commit is contained in:
5 files changed
+25
-5
No files matched your search
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
const i18n = getContext<Writable<i18nType>>('i18n');
|
const i18n = getContext<Writable<i18nType>>('i18n');
|
||||||
|
|
||||||
import { WEBUI_NAME, user, workspaceActions } from '$lib/stores';
|
import { WEBUI_NAME, user, workspaceActions, workspaceCounts } from '$lib/stores';
|
||||||
import {
|
import {
|
||||||
deleteKnowledgeById,
|
deleteKnowledgeById,
|
||||||
searchKnowledgeBases,
|
searchKnowledgeBases,
|
||||||
@@ -153,6 +153,7 @@
|
|||||||
if (res) {
|
if (res) {
|
||||||
console.log(res);
|
console.log(res);
|
||||||
total = res.total;
|
total = res.total;
|
||||||
|
workspaceCounts.update((counts) => ({ ...counts, knowledge: total }));
|
||||||
const pageItems: KnowledgeListItem[] = res.items ?? [];
|
const pageItems: KnowledgeListItem[] = res.items ?? [];
|
||||||
|
|
||||||
if ((pageItems ?? []).length === 0) {
|
if ((pageItems ?? []).length === 0) {
|
||||||
|
|||||||
@@ -20,7 +20,8 @@
|
|||||||
pinnedModels,
|
pinnedModels,
|
||||||
settings,
|
settings,
|
||||||
user,
|
user,
|
||||||
workspaceActions
|
workspaceActions,
|
||||||
|
workspaceCounts
|
||||||
} from '$lib/stores';
|
} from '$lib/stores';
|
||||||
import { WEBUI_API_BASE_URL } from '$lib/constants';
|
import { WEBUI_API_BASE_URL } from '$lib/constants';
|
||||||
import {
|
import {
|
||||||
@@ -165,6 +166,7 @@
|
|||||||
if (res) {
|
if (res) {
|
||||||
models = res.items;
|
models = res.items;
|
||||||
total = res.total;
|
total = res.total;
|
||||||
|
workspaceCounts.update((counts) => ({ ...counts, models: total }));
|
||||||
|
|
||||||
// get tags
|
// get tags
|
||||||
tags = await getModelTags(localStorage.token).catch((error) => {
|
tags = await getModelTags(localStorage.token).catch((error) => {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
import { onMount, getContext, tick, onDestroy } from 'svelte';
|
import { onMount, getContext, tick, onDestroy } from 'svelte';
|
||||||
import type { Writable } from 'svelte/store';
|
import type { Writable } from 'svelte/store';
|
||||||
import type { i18n as i18nType } from 'i18next';
|
import type { i18n as i18nType } from 'i18next';
|
||||||
import { WEBUI_NAME, config, user, workspaceActions } from '$lib/stores';
|
import { WEBUI_NAME, config, user, workspaceActions, workspaceCounts } from '$lib/stores';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
createNewPrompt,
|
createNewPrompt,
|
||||||
@@ -179,6 +179,7 @@
|
|||||||
if (res) {
|
if (res) {
|
||||||
prompts = res.items;
|
prompts = res.items;
|
||||||
total = res.total;
|
total = res.total;
|
||||||
|
workspaceCounts.update((counts) => ({ ...counts, prompts: total }));
|
||||||
|
|
||||||
// get tags
|
// get tags
|
||||||
tags = await getPromptTags(localStorage.token).catch((error) => {
|
tags = await getPromptTags(localStorage.token).catch((error) => {
|
||||||
|
|||||||
@@ -10,7 +10,13 @@
|
|||||||
import { onMount, getContext, tick, onDestroy } from 'svelte';
|
import { onMount, getContext, tick, onDestroy } from 'svelte';
|
||||||
const i18n = getContext('i18n');
|
const i18n = getContext('i18n');
|
||||||
|
|
||||||
import { WEBUI_NAME, user, skills as _skills, workspaceActions } from '$lib/stores';
|
import {
|
||||||
|
WEBUI_NAME,
|
||||||
|
user,
|
||||||
|
skills as _skills,
|
||||||
|
workspaceActions,
|
||||||
|
workspaceCounts
|
||||||
|
} from '$lib/stores';
|
||||||
import { goto } from '$app/navigation';
|
import { goto } from '$app/navigation';
|
||||||
import {
|
import {
|
||||||
getSkills,
|
getSkills,
|
||||||
@@ -117,6 +123,7 @@
|
|||||||
if (res) {
|
if (res) {
|
||||||
filteredItems = res.items;
|
filteredItems = res.items;
|
||||||
total = res.total;
|
total = res.total;
|
||||||
|
workspaceCounts.update((counts) => ({ ...counts, skills: total }));
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
|
|||||||
@@ -10,7 +10,14 @@
|
|||||||
import { onMount, getContext, tick, onDestroy } from 'svelte';
|
import { onMount, getContext, tick, onDestroy } from 'svelte';
|
||||||
const i18n = getContext('i18n');
|
const i18n = getContext('i18n');
|
||||||
|
|
||||||
import { WEBUI_NAME, config, tools as _tools, user, workspaceActions } from '$lib/stores';
|
import {
|
||||||
|
WEBUI_NAME,
|
||||||
|
config,
|
||||||
|
tools as _tools,
|
||||||
|
user,
|
||||||
|
workspaceActions,
|
||||||
|
workspaceCounts
|
||||||
|
} from '$lib/stores';
|
||||||
|
|
||||||
import { goto } from '$app/navigation';
|
import { goto } from '$app/navigation';
|
||||||
import {
|
import {
|
||||||
@@ -152,6 +159,8 @@
|
|||||||
|
|
||||||
return direction * ((a.updated_at ?? 0) - (b.updated_at ?? 0));
|
return direction * ((a.updated_at ?? 0) - (b.updated_at ?? 0));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
workspaceCounts.update((counts) => ({ ...counts, tools: filteredItems.length }));
|
||||||
};
|
};
|
||||||
|
|
||||||
const setSortKey = (key: string) => {
|
const setSortKey = (key: string) => {
|
||||||
|
|||||||
Reference in new issue
Block a user