Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
1d937ec2
Commit
1d937ec2
authored
Feb 25, 2024
by
Timothy J. Baek
Browse files
fix: cleanup unused tags
parent
7c1b8e39
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
6 deletions
+37
-6
CHANGELOG.md
CHANGELOG.md
+3
-2
backend/apps/web/models/tags.py
backend/apps/web/models/tags.py
+21
-0
backend/apps/web/routers/chats.py
backend/apps/web/routers/chats.py
+5
-2
src/lib/components/layout/Sidebar.svelte
src/lib/components/layout/Sidebar.svelte
+8
-2
No files found.
CHANGELOG.md
View file @
1d937ec2
...
...
@@ -9,11 +9,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
-
**🔄 Check for Updates**
: Now conveniently available in Settings > About.
-
**🔄 Check for Updates**
: Keep your system current by checking for updates conveniently located in Settings > About.
-
**🗑️ Automatic Tag Deletion**
: Unused tags on the sidebar will now be deleted automatically with just a click.
### Changed
-
**🎨 Modernized Styling**
:
Updated
for a more contemporary
appeara
nce.
-
**🎨 Modernized Styling**
:
Enjoy a refreshed look with updated styling
for a more contemporary
experie
nce.
## [0.1.103] - 2024-02-25
...
...
backend/apps/web/models/tags.py
View file @
1d937ec2
...
...
@@ -167,6 +167,27 @@ class TagTable:
.
count
()
)
def
delete_tag_by_tag_name_and_user_id
(
self
,
tag_name
:
str
,
user_id
:
str
)
->
bool
:
try
:
query
=
ChatIdTag
.
delete
().
where
(
(
ChatIdTag
.
tag_name
==
tag_name
)
&
(
ChatIdTag
.
user_id
==
user_id
)
)
res
=
query
.
execute
()
# Remove the rows, return number of rows removed.
print
(
res
)
tag_count
=
self
.
count_chat_ids_by_tag_name_and_user_id
(
tag_name
,
user_id
)
if
tag_count
==
0
:
# Remove tag item from Tag col as well
query
=
Tag
.
delete
().
where
(
(
Tag
.
name
==
tag_name
)
&
(
Tag
.
user_id
==
user_id
)
)
query
.
execute
()
# Remove the rows, return number of rows removed.
return
True
except
Exception
as
e
:
print
(
"delete_tag"
,
e
)
return
False
def
delete_tag_by_tag_name_and_chat_id_and_user_id
(
self
,
tag_name
:
str
,
chat_id
:
str
,
user_id
:
str
)
->
bool
:
...
...
backend/apps/web/routers/chats.py
View file @
1d937ec2
...
...
@@ -115,9 +115,12 @@ async def get_user_chats_by_tag_name(
for
chat_id_tag
in
Tags
.
get_chat_ids_by_tag_name_and_user_id
(
tag_name
,
user
.
id
)
]
print
(
chat_ids
)
chats
=
Chats
.
get_chat_lists_by_chat_ids
(
chat_ids
,
skip
,
limit
)
return
Chats
.
get_chat_lists_by_chat_ids
(
chat_ids
,
skip
,
limit
)
if
len
(
chats
)
==
0
:
Tags
.
delete_tag_by_tag_name_and_user_id
(
tag_name
,
user
.
id
)
return
chats
############################
...
...
src/lib/components/layout/Sidebar.svelte
View file @
1d937ec2
...
...
@@ -13,7 +13,8 @@
getChatList,
getChatById,
getChatListByTagName,
updateChatById
updateChatById,
getAllChatTags
} from '$lib/apis/chats';
import toast from 'svelte-french-toast';
import { slide } from 'svelte/transition';
...
...
@@ -330,7 +331,12 @@
<button
class="px-2.5 text-xs font-medium bg-gray-900 hover:bg-gray-800 transition rounded-full"
on:click={async () => {
await chats.set(await getChatListByTagName(localStorage.token, tag.name));
let chatIds = await getChatListByTagName(localStorage.token, tag.name);
if (chatIds.length === 0) {
await tags.set(await getAllChatTags(localStorage.token));
chatIds = await getChatList(localStorage.token);
}
await chats.set(chatIds);
}}
>
{tag.name}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment