diff --git a/src/modules/contents/attachments/AttachmentList.vue b/src/modules/contents/attachments/AttachmentList.vue index 71ce03d2..bf036b6d 100644 --- a/src/modules/contents/attachments/AttachmentList.vue +++ b/src/modules/contents/attachments/AttachmentList.vue @@ -93,17 +93,17 @@ const selectedSortItemValue = computed(() => { function handleSelectPolicy(policy: Policy | undefined) { selectedPolicy.value = policy; - handleFetchAttachments(1); + handleFetchAttachments({ page: 1 }); } function handleSelectUser(user: User | undefined) { selectedUser.value = user; - handleFetchAttachments(1); + handleFetchAttachments({ page: 1 }); } function handleSortItemChange(sortItem?: SortItem) { selectedSortItem.value = sortItem; - handleFetchAttachments(1); + handleFetchAttachments({ page: 1 }); } function handleKeywordChange() { @@ -111,12 +111,12 @@ function handleKeywordChange() { if (keywordNode) { keyword.value = keywordNode._value as string; } - handleFetchAttachments(1); + handleFetchAttachments({ page: 1 }); } function handleClearKeyword() { keyword.value = ""; - handleFetchAttachments(1); + handleFetchAttachments({ page: 1 }); } const hasFilters = computed(() => { @@ -133,7 +133,7 @@ function handleClearFilters() { selectedUser.value = undefined; selectedSortItem.value = undefined; keyword.value = ""; - handleFetchAttachments(1); + handleFetchAttachments({ page: 1 }); } const { @@ -208,16 +208,12 @@ const onDetailModalClose = () => { selectedAttachment.value = undefined; nameQuery.value = undefined; nameQueryAttachment.value = undefined; - setTimeout(() => { - handleFetchAttachments(); - }, 200); + handleFetchAttachments({ mute: true }); }; const onUploadModalClose = () => { routeQueryAction.value = undefined; - setTimeout(() => { - handleFetchAttachments(); - }, 200); + handleFetchAttachments({ mute: true }); }; const onGroupChange = () => { diff --git a/src/modules/contents/attachments/composables/use-attachment.ts b/src/modules/contents/attachments/composables/use-attachment.ts index a3e479c1..77a70f55 100644 --- a/src/modules/contents/attachments/composables/use-attachment.ts +++ b/src/modules/contents/attachments/composables/use-attachment.ts @@ -19,7 +19,7 @@ interface useAttachmentControlReturn { selectedAttachment: Ref; selectedAttachments: Ref>; checkedAll: Ref; - handleFetchAttachments: (page?: number) => void; + handleFetchAttachments: (options?: { mute?: boolean; page?: number }) => void; handlePaginationChange: ({ page, size, @@ -68,14 +68,19 @@ export function useAttachmentControl(filterOptions?: { const checkedAll = ref(false); const refreshInterval = ref(); - const handleFetchAttachments = async (page?: number) => { + const handleFetchAttachments = async (options?: { + mute?: boolean; + page?: number; + }) => { try { clearInterval(refreshInterval.value); - loading.value = true; + if (!options?.mute) { + loading.value = true; + } - if (page) { - attachments.value.page = page; + if (options?.page) { + attachments.value.page = options.page; } const { data } = await apiClient.attachment.searchAttachments({ @@ -96,7 +101,7 @@ export function useAttachmentControl(filterOptions?: { if (deletedAttachments.length) { refreshInterval.value = setInterval(() => { - handleFetchAttachments(); + handleFetchAttachments({ mute: true }); }, 3000); } } catch (e) { diff --git a/src/modules/contents/comments/CommentList.vue b/src/modules/contents/comments/CommentList.vue index 132e2a98..fb7483d8 100644 --- a/src/modules/contents/comments/CommentList.vue +++ b/src/modules/contents/comments/CommentList.vue @@ -44,14 +44,19 @@ const selectedCommentNames = ref([]); const keyword = ref(""); const refreshInterval = ref(); -const handleFetchComments = async (page?: number) => { +const handleFetchComments = async (options?: { + mute?: boolean; + page?: number; +}) => { try { clearInterval(refreshInterval.value); - loading.value = true; + if (!options?.mute) { + loading.value = true; + } - if (page) { - comments.value.page = page; + if (options?.page) { + comments.value.page = options.page; } const { data } = await apiClient.comment.listComments({ @@ -70,7 +75,7 @@ const handleFetchComments = async (page?: number) => { if (deletedComments.length) { refreshInterval.value = setInterval(() => { - handleFetchComments(); + handleFetchComments({ mute: true }); }, 3000); } } catch (error) { @@ -238,7 +243,7 @@ const handleApprovedFilterItemChange = (filterItem: { }) => { selectedApprovedFilterItem.value = filterItem; selectedCommentNames.value = []; - handleFetchComments(1); + handleFetchComments({ page: 1 }); }; const handleSortFilterItemChange = (filterItem: { @@ -247,12 +252,12 @@ const handleSortFilterItemChange = (filterItem: { }) => { selectedSortFilterItem.value = filterItem; selectedCommentNames.value = []; - handleFetchComments(1); + handleFetchComments({ page: 1 }); }; function handleSelectUser(user: User | undefined) { selectedUser.value = user; - handleFetchComments(1); + handleFetchComments({ page: 1 }); } function handleKeywordChange() { @@ -260,12 +265,12 @@ function handleKeywordChange() { if (keywordNode) { keyword.value = keywordNode._value as string; } - handleFetchComments(1); + handleFetchComments({ page: 1 }); } function handleClearKeyword() { keyword.value = ""; - handleFetchComments(1); + handleFetchComments({ page: 1 }); } const hasFilters = computed(() => { @@ -282,7 +287,7 @@ function handleClearFilters() { selectedSortFilterItem.value = SortFilterItems[0]; selectedUser.value = undefined; keyword.value = ""; - handleFetchComments(1); + handleFetchComments({ page: 1 }); }