Skip to content

Commit

Permalink
Use event instead of watch
Browse files Browse the repository at this point in the history
  • Loading branch information
Sébastien LeBlanc committed Aug 14, 2023
1 parent d893084 commit d55efb5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 5 additions & 0 deletions src/components/TimeEntry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,10 @@ const props = defineProps({
},
});
const emit = defineEmits<{
(e: 'add'): void
}>()
const model = ref(Object.assign({}, props.entry));
const placeholder = ref('00:00:00');
Expand Down Expand Up @@ -378,6 +382,7 @@ function stop() {
function add() {
model.value.is_creating = false;
commitEntry(model.value as Entry);
emit('add');
}
function edit() {
Expand Down
6 changes: 1 addition & 5 deletions src/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TimeEntriesHeader />
<div class="flex flex-col items-center w-full gap-2 mx-auto">
<TimeEntry v-for="(entry, index) in todaysEntries" :key="entry.id" :entry="entry" />
<TimeEntry v-if="canCreateEntry" :key="key" />
<TimeEntry v-if="canCreateEntry" :key="key" @add="key = uuidv4()" />
</div>
</div>
<SummarySidebar />
Expand All @@ -20,8 +20,4 @@ const store = useStore();
const { todaysEntries, canCreateEntry } = storeToRefs(store);
const key = ref(uuidv4());
watch(todaysEntries, () => {
key.value = uuidv4();
});
</script>

0 comments on commit d55efb5

Please sign in to comment.