Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: multiple timelineAPI calls and contactAPI calls[WTEL-4843] #109

Merged
merged 2 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions src/modules/contacts/components/contact-popup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,15 @@ async function loadItem(id = props.id) {
draft.value = await ContactsAPI.get({ itemId: id });
}

watch(() => props.shown, () => {
if (props.id) loadItem(props.id);
else {
draft.value = generateNewDraft();
setDefaultManager();
watch(() => props.shown, (value) => {
if(value) {
if (props.id) loadItem(props.id);
else {
draft.value = generateNewDraft();
setDefaultManager();
}
}
}, { immediate: true });
});
</script>

<style lang="scss" scoped>
Expand Down
15 changes: 11 additions & 4 deletions src/modules/contacts/modules/timeline/components/the-timeline.vue
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,6 @@ const {
restoreFilters,
} = useTableFilters(timelineNamespace);

onUnmounted(() => {
flushSubscribers();
});

subscribe({
event: '*',
callback: initializeList,
Expand All @@ -106,6 +102,17 @@ async function loadNext() {
await store.dispatch(`${timelineNamespace}/LOAD_NEXT`);
nextLoading.value = false;
}

onUnmounted(() => {
flushSubscribers();

/* https://webitel.atlassian.net/browse/WTEL-4843 */
/* Store must be reset to prevent multiple calls TimelineAPI */
/* Caching doesn't work because of this code, a fix later. See the task for more details */

store.dispatch(`${timelineNamespace}/RESET_STATE`);
});

</script>

<style lang="scss" scoped>
Expand Down
5 changes: 5 additions & 0 deletions src/modules/contacts/modules/timeline/store/timeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ const actions = {
context.commit('SET', { path: 'dataList', value: [...context.state.dataList, ...items] });
context.commit('SET', { path: 'next', value: next });
},
RESET_STATE: (context) => {
context.commit('SET', { path: 'dataList', value: [] });
context.commit('SET', { path: 'page', value: 1 });
context.commit('SET', { path: 'next', value: false });
}
};

const mutations = {
Expand Down
Loading