From 2a5724822855f29e85ad860ebe9fa692401084f8 Mon Sep 17 00:00:00 2001
From: Lykin <137850705+tiny-craft@users.noreply.github.com>
Date: Sat, 18 Nov 2023 00:51:40 +0800
Subject: [PATCH] refactor: optimized refresh logic after update fields for
stream type
---
backend/services/browser_service.go | 6 ++-
.../components/new_value/NewStreamValue.vue | 2 +-
frontend/src/stores/browser.js | 4 +-
frontend/src/stores/tab.js | 39 ++++++++++++++-----
4 files changed, 36 insertions(+), 15 deletions(-)
diff --git a/backend/services/browser_service.go b/backend/services/browser_service.go
index ded2c8a..caeb4fe 100644
--- a/backend/services/browser_service.go
+++ b/backend/services/browser_service.go
@@ -1673,8 +1673,10 @@ func (b *browserService) RemoveStreamValues(connName string, db int, k any, IDs
}
resp.Success = true
- resp.Data = map[string]any{
- "affected": affected,
+ resp.Data = struct {
+ Affected int64 `json:"affected"`
+ }{
+ Affected: affected,
}
return
}
diff --git a/frontend/src/components/new_value/NewStreamValue.vue b/frontend/src/components/new_value/NewStreamValue.vue
index 7c41f3f..4888a8f 100644
--- a/frontend/src/components/new_value/NewStreamValue.vue
+++ b/frontend/src/components/new_value/NewStreamValue.vue
@@ -43,7 +43,7 @@ defineExpose({
-
+
includes(entries, k))
- tab.length -= size(removedElems)
- break
-
- case 'set': // []string
- tab.value = tab.value || []
- tab.length -= size(remove(tab.value, ({ v }) => includes(entries, v)))
+ for (const k of entries) {
+ for (let i = 0; i < tab.value.length; i++) {
+ if (tab.value[i].k === k) {
+ tab.value.splice(i, 1)
+ tab.length -= 1
+ break
+ }
+ }
+ }
break
+ case 'set': // string[]
case 'zset': // string[]
tab.value = tab.value || []
- tab.length -= size(remove(tab.value, ({ v }) => includes(entries, v)))
+ for (const v of entries) {
+ for (let i = 0; i < tab.value.length; i++) {
+ if (tab.value[i].v === v) {
+ tab.value.splice(i, 1)
+ tab.length -= 1
+ break
+ }
+ }
+ }
break
case 'stream': // string[]
tab.value = tab.value || []
- tab.length -= size(remove(tab.value, ({ v }) => includes(entries, v)))
+ for (const id of entries) {
+ for (let i = 0; i < tab.value.length; i++) {
+ if (tab.value[i].id === id) {
+ tab.value.splice(i, 1)
+ tab.length -= 1
+ break
+ }
+ }
+ }
break
}
},