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 { storeToRefs } from 'pinia'
|
||||||
import axiosClient from '@/services/HttpService'
|
import axiosClient from '@/services/HttpService'
|
||||||
import mime from 'mime'
|
import mime from 'mime'
|
||||||
|
import io from 'socket.io-client'
|
||||||
|
|
||||||
import type { StorageFile } from '@/stores/storage'
|
import type { StorageFile } from '@/stores/storage'
|
||||||
import { useSearchDataStore } from '@/stores/searched-data'
|
import { useSearchDataStore } from '@/stores/searched-data'
|
||||||
|
|
@ -14,6 +15,7 @@ import AdvancedSearch from '@/modules/01_user/components/AdvancedSearch.vue'
|
||||||
const loaderStore = useLoader()
|
const loaderStore = useLoader()
|
||||||
const { isFilePreview } = storeToRefs(useFileInfoStore())
|
const { isFilePreview } = storeToRefs(useFileInfoStore())
|
||||||
const {
|
const {
|
||||||
|
foundFile,
|
||||||
isSearch,
|
isSearch,
|
||||||
isAdvSearchCall,
|
isAdvSearchCall,
|
||||||
isActFoundFile,
|
isActFoundFile,
|
||||||
|
|
@ -39,6 +41,24 @@ const props = defineProps<{
|
||||||
mode: 'admin' | 'user'
|
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() {
|
async function submitSearch() {
|
||||||
isFilePreview.value = false
|
isFilePreview.value = false
|
||||||
if (searchData.value.value.trim() !== '') {
|
if (searchData.value.value.trim() !== '') {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue