fix: edit file info on search should change
This commit is contained in:
parent
2c90d99338
commit
b98f7d5980
1 changed files with 20 additions and 0 deletions
|
|
@ -3,6 +3,7 @@ import { ref, watch } from 'vue'
|
|||
import { storeToRefs } from 'pinia'
|
||||
import axiosClient from '@/services/HttpService'
|
||||
import mime from 'mime'
|
||||
import io from 'socket.io-client'
|
||||
|
||||
import type { StorageFile } from '@/stores/storage'
|
||||
import { useSearchDataStore } from '@/stores/searched-data'
|
||||
|
|
@ -14,6 +15,7 @@ import AdvancedSearch from '@/modules/01_user/components/AdvancedSearch.vue'
|
|||
const loaderStore = useLoader()
|
||||
const { isFilePreview } = storeToRefs(useFileInfoStore())
|
||||
const {
|
||||
foundFile,
|
||||
isSearch,
|
||||
isAdvSearchCall,
|
||||
isActFoundFile,
|
||||
|
|
@ -39,6 +41,24 @@ const props = defineProps<{
|
|||
mode: 'admin' | 'user'
|
||||
}>()
|
||||
|
||||
const socket = io(import.meta.env.VITE_API_HOST)
|
||||
|
||||
socket.on('FileUpdate', (data: StorageFile) =>
|
||||
replaceSearchItem(data.pathname, data),
|
||||
)
|
||||
socket.on('FileUpload', (data: StorageFile) =>
|
||||
replaceSearchItem(data.pathname, data),
|
||||
)
|
||||
socket.on('FileUpdateMove', (data: { from: StorageFile; to: StorageFile }) =>
|
||||
replaceSearchItem(data.from.pathname, data.to),
|
||||
)
|
||||
|
||||
function replaceSearchItem(pathname: string, data: StorageFile) {
|
||||
const idx = foundFile.value.findIndex((v) => v.pathname === pathname)
|
||||
|
||||
if (idx !== -1) foundFile.value[idx] = data
|
||||
}
|
||||
|
||||
async function submitSearch() {
|
||||
isFilePreview.value = false
|
||||
if (searchData.value.value.trim() !== '') {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue