refactor: optimized refresh logic after update fields for stream type
This commit is contained in:
parent
13f343977a
commit
2a57248228
|
@ -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
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ defineExpose({
|
|||
<n-form-item label="ID">
|
||||
<n-input v-model:value="id" />
|
||||
</n-form-item>
|
||||
<n-form-item :label="$t('dialogue.field.element')" required>
|
||||
<n-form-item :label="$t('common.field') + ':' + $t('common.value')" required>
|
||||
<n-dynamic-input
|
||||
v-model:value="kvList"
|
||||
:key-placeholder="$t('dialogue.field.enter_field')"
|
||||
|
|
|
@ -1601,8 +1601,8 @@ const useBrowserStore = defineStore('browser', {
|
|||
try {
|
||||
const { data = {}, success, msg } = await RemoveStreamValues(connName, db, key, ids)
|
||||
if (success) {
|
||||
// const tab = useTabStore()
|
||||
// tab.removeValueEntries({ server: connName, db, key, type: 'stream', entries: ids })
|
||||
const tab = useTabStore()
|
||||
tab.removeValueEntries({ server: connName, db, key, type: 'stream', entries: ids })
|
||||
return { success }
|
||||
} else {
|
||||
return { success, msg }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { assign, find, findIndex, get, includes, isEmpty, pullAt, remove, set, size } from 'lodash'
|
||||
import { assign, find, findIndex, get, isEmpty, pullAt, remove, set, size } from 'lodash'
|
||||
import { defineStore } from 'pinia'
|
||||
|
||||
const useTabStore = defineStore('tab', {
|
||||
|
@ -478,23 +478,42 @@ const useTabStore = defineStore('tab', {
|
|||
|
||||
case 'hash': // string[]
|
||||
tab.value = tab.value || {}
|
||||
const removedElems = remove(tab.value, ({ k }) => 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
|
||||
}
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue