Skip to content

Commit

Permalink
remove props.histories and directly access store instead: hist scro…
Browse files Browse the repository at this point in the history
…ll list
  • Loading branch information
ahmedhamidawan committed Jan 16, 2024
1 parent 283e71e commit 57163a5
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 15 deletions.
8 changes: 2 additions & 6 deletions client/src/components/History/HistoryScrollList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ type PinnedHistory = { id: string };
const props = defineProps({
multiple: { type: Boolean, default: false },
histories: { type: Array as PropType<HistorySummary[]>, default: () => [] },
selectedHistories: { type: Array as PropType<PinnedHistory[]>, default: () => [] },
additionalOptions: { type: Array as PropType<AdditionalOptions[]>, default: () => [] },
showModal: { type: Boolean, default: false },
Expand All @@ -49,7 +48,7 @@ const showAdvanced = ref(false);
const scrollableDiv: Ref<HTMLElement | null> = ref(null);
const historyStore = useHistoryStore();
const { currentHistoryId, totalHistoryCount, pinnedHistories } = storeToRefs(useHistoryStore());
const { currentHistoryId, histories, totalHistoryCount, pinnedHistories } = storeToRefs(historyStore);
const { currentUser } = storeToRefs(useUserStore());
const hasNoResults = computed(() => props.filter && filtered.value.length == 0);
Expand Down Expand Up @@ -85,13 +84,10 @@ watch(
}
);
// reactive proxy for props.histories, as the prop is not
// always guaranteed to be reactive for some strange reason.
// TODO: Re investigate when upgrading to vue3
/** `historyStore` histories for current user */
const historiesProxy: Ref<HistorySummary[]> = ref([]);
watch(
() => props.histories as HistoryDetailed[],
() => histories.value as HistoryDetailed[],
(h: HistoryDetailed[]) => {
historiesProxy.value = h.filter(
(h) => !h.user_id || (!currentUser.value?.isAnonymous && h.user_id === currentUser.value?.id)
Expand Down
1 change: 0 additions & 1 deletion client/src/components/History/Modals/SelectorModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ function setFilterValue(newFilter: string, newValue: string) {
<HistoryList
v-show="!showAdvanced"
:multiple="props.multiple"
:histories="histories"
:selected-histories="selectedHistories"
:additional-options="props.additionalOptions"
:show-modal.sync="propShowModal"
Expand Down
10 changes: 2 additions & 8 deletions client/src/components/Panels/MultiviewPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const loading = ref(false);
const isAnonymous = computed(() => useUserStore().isAnonymous);
const historyStore = useHistoryStore();
const { histories, historiesLoading, currentHistoryId } = storeToRefs(historyStore);
const { historiesLoading, currentHistoryId } = storeToRefs(historyStore);
const pinnedHistoryCount = computed(() => {
return Object.keys(historyStore.pinnedHistories).length;
Expand Down Expand Up @@ -155,12 +155,6 @@ function userTitle(title: string) {
Please <a :href="withPrefix('/login')">log in or register</a> to create multiple histories.
</b-badge>
</div>
<HistoryList
v-show="!showAdvanced"
multiple
:filter="filter"
:histories="histories"
:loading.sync="loading"
@setFilter="setFilter" />
<HistoryList v-show="!showAdvanced" multiple :filter="filter" :loading.sync="loading" @setFilter="setFilter" />
</div>
</template>
1 change: 1 addition & 0 deletions client/src/stores/historyStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ export const useHistoryStore = defineStore("historyStore", () => {
await createNewHistory();
}
Vue.delete(storedHistories.value, deletedHistory.id);
unpinHistories([deletedHistory.id]);
await handleTotalCountChange(1, true);
}

Expand Down

0 comments on commit 57163a5

Please sign in to comment.