dont force refresh alll files

This commit is contained in:
2023-08-25 20:08:09 +10:00
parent 104407646c
commit 511da54909

View File

@@ -143,7 +143,9 @@
backgroundImage: `url('${mediaGetThumbnail( backgroundImage: `url('${mediaGetThumbnail(
item, item,
null, null,
true, itemRequiresRefresh(
item.id,
),
)}')`, )}')`,
backgroundColor: backgroundColor:
item.status === 'OK' item.status === 'OK'
@@ -245,7 +247,9 @@
mediaGetThumbnail( mediaGetThumbnail(
lastSelected, lastSelected,
null, null,
true, itemRequiresRefresh(
lastSelected.id,
),
) )
" "
class="max-h-20 max-w-20 mr-2" /> class="max-h-20 max-w-20 mr-2" />
@@ -564,6 +568,8 @@ const refMediaList = ref<HTMLUListElement | null>(null);
const userStore = useUserStore(); const userStore = useUserStore();
const forceRefresh = [];
const allowUploads = ref(props.allowUpload && userStore.id); const allowUploads = ref(props.allowUpload && userStore.id);
const formLoading = ref(false); const formLoading = ref(false);
const form: FormObject = reactive( const form: FormObject = reactive(
@@ -941,6 +947,7 @@ const updateFiles = async () => {
updateResult.data as MediaResponse; updateResult.data as MediaResponse;
if (updateData.medium.status == "OK") { if (updateData.medium.status == "OK") {
mediaItems.value[index] = updateData.medium; mediaItems.value[index] = updateData.medium;
forceRefresh.push(updateData.medium.id);
if ( if (
lastSelected.value && lastSelected.value &&
lastSelected.value.id == lastSelected.value.id ==
@@ -1394,6 +1401,17 @@ const loadInitial = () => {
} }
}; };
const itemRequiresRefresh = (id) => {
const index = forceRefresh.indexOf(id);
if (index !== -1) {
forceRefresh.splice(index, 1); // Remove the item at the found index
return true;
}
return false;
};
// Get max upload size // Get max upload size
api.get({ api.get({
url: "", url: "",