refine infinite scroll - infiniteStart is a ref variable and infiniteAcctData is a computed one.
This commit is contained in:
@@ -149,11 +149,10 @@ export default {
|
||||
const modalStore = useModalStore();
|
||||
const { isLoading } = storeToRefs(loadingStore);
|
||||
const loginStore = piniaLoginStore();
|
||||
const infiniteAcctData = ref([]);
|
||||
const infiniteStart = ref(0);
|
||||
const infiniteAcctData = computed(() => acctMgmtStore.allUserAccoutList.slice(0, infiniteStart.value + ONCE_RENDER_NUM_OF_DATA));
|
||||
|
||||
const loginUserData = ref(null);
|
||||
const allUserAccoutList = computed(() => acctMgmtStore.allUserAccoutList);
|
||||
|
||||
const fetchLoginUserData = async () => {
|
||||
await loginStore.getUserData();
|
||||
@@ -184,11 +183,6 @@ export default {
|
||||
modalStore.openModal(MODAL_ACCT_INFO);
|
||||
}
|
||||
|
||||
const getFirstPageUserData = async() => {
|
||||
await acctMgmtStore.getAllUserAccounts();
|
||||
infiniteAcctData.value = allUserAccoutList.value.slice(0, ONCE_RENDER_NUM_OF_DATA)
|
||||
};
|
||||
|
||||
const handleDeleteMouseOver = (username) => {
|
||||
acctMgmtStore.changeIsDeleteHoveredByUser(username, true);
|
||||
};
|
||||
@@ -228,12 +222,12 @@ export default {
|
||||
};
|
||||
|
||||
const getRowClass = (curData) => {
|
||||
return curData.isRowHovered ? 'bg-[#F1F5F9]' : '';
|
||||
return curData?.isRowHovered ? 'bg-[#F1F5F9]' : '';
|
||||
};
|
||||
|
||||
onBeforeMount(async () => {
|
||||
await fetchLoginUserData();
|
||||
await getFirstPageUserData();
|
||||
await acctMgmtStore.getAllUserAccounts();
|
||||
moveCurrentLoginUserToFirstRow();
|
||||
});
|
||||
|
||||
@@ -267,10 +261,8 @@ export default {
|
||||
};
|
||||
|
||||
const fetchMoreDataVue3 = () => {
|
||||
infiniteStart.value += ONCE_RENDER_NUM_OF_DATA;
|
||||
if(infiniteAcctData.value.length < acctMgmtStore.allUserAccoutList.length) {
|
||||
infiniteAcctData.value = [...infiniteAcctData.value, ...acctMgmtStore.allUserAccoutList.slice(
|
||||
infiniteStart.value, infiniteStart.value + ONCE_RENDER_NUM_OF_DATA)];
|
||||
infiniteStart.value += ONCE_RENDER_NUM_OF_DATA;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -246,6 +246,7 @@ export default defineComponent({
|
||||
});
|
||||
await toast.success(i18next.t("AcctMgmt.MsgAccountAdded"));
|
||||
await modalStore.closeModal();
|
||||
await acctMgmtStore.getAllUserAccounts();
|
||||
await router.push('/account/account-admin');
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -46,6 +46,7 @@ export default defineComponent({
|
||||
if(acctMgmtStore.deleteAccount(acctMgmtStore.currentViewingUser.username)){
|
||||
toast.success(i18next.t("AcctMgmt.MsgAccountDeleteSuccess"));
|
||||
modalStore.closeModal();
|
||||
await acctMgmtStore.getAllUserAccounts();
|
||||
router.push("/account/account-admin");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user