Skip to content
This repository has been archived by the owner on Aug 20, 2023. It is now read-only.

Commit

Permalink
Do not cache state
Browse files Browse the repository at this point in the history
  • Loading branch information
francoism90 committed Mar 24, 2022
1 parent 2495288 commit 93c7b33
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
5 changes: 2 additions & 3 deletions src/components/video/VideoSimilar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<script lang="ts">
import { useSimilar } from 'src/composables/useSimilar';
import { useVideo } from 'src/composables/useVideo';
import { defineAsyncComponent, defineComponent, onBeforeMount, watch } from 'vue';
import { defineAsyncComponent, defineComponent, watch } from 'vue';
export default defineComponent({
name: 'VideoSimilar',
Expand Down Expand Up @@ -65,8 +65,7 @@ export default defineComponent({
done();
};
onBeforeMount(() => reset());
watch(() => video.data, () => reset(), { deep: true });
watch(() => video.data, () => reset(), { deep: true, immediate: true });
return {
onLoad,
Expand Down
18 changes: 9 additions & 9 deletions src/composables/useSimilar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ import { Model, RepositoryLinks, RepositoryMeta, VideosFilters, VideosResponse,
import { api, uri } from 'src/services/api';
import { reactive } from 'vue';

const state = reactive(<VideosState>{
id: null,
data: [],
meta: undefined,
links: undefined,
error: undefined,
filters: undefined,
});

export const useSimilar = () => {
const state = reactive(<VideosState>{
id: null,
data: [],
meta: undefined,
links: undefined,
error: undefined,
filters: undefined,
});

const update = (payload: VideosResponse | null) => {
state.data = state.data.concat(payload?.data || []);
state.meta = { ...state.meta, ...<RepositoryMeta>payload?.meta };
Expand Down

0 comments on commit 93c7b33

Please sign in to comment.