Skip to content

Commit

Permalink
fix: get task records on start/stop
Browse files Browse the repository at this point in the history
  • Loading branch information
antonreshetov committed Mar 24, 2024
1 parent d89561f commit 229295b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
9 changes: 1 addition & 8 deletions src/renderer/components/records/composables/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import { computed, ref, shallowRef, watch } from 'vue'
import { computed, ref, shallowRef } from 'vue'
import { format } from 'date-fns'
import { useTasks } from '@/components/tasks/composables'
import type { TaskRecordWithInfo } from '~/services/api/types'

const { api } = window.electron

const { isStarted } = useTasks()

const taskRecords = shallowRef<TaskRecordWithInfo[]>([])
const editRecordId = ref<string>()
const contextRecordId = ref<string>()
Expand Down Expand Up @@ -47,10 +44,6 @@ function deleteTaskRecord(id: string) {
getTaskRecords()
}

watch(isStarted, () => {
getTaskRecords()
})

export function useRecords() {
return {
contextRecordId,
Expand Down
8 changes: 6 additions & 2 deletions src/renderer/components/tasks/Item.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import SolarPauseBold from '~icons/solar/pause-bold'
import { useTasks } from '@/components/tasks/composables'
import { timeFormat } from '@/utils'
import * as Popover from '@/components/ui/shadcn/popover'
import { useRecords } from '@/components/records/composables'
interface Props {
id: string
Expand All @@ -27,16 +28,19 @@ const {
isOpenEditMenu,
editTaskId,
} = useTasks()
const { getTaskRecords } = useRecords()
const isStarted = computed(() => currentTaskId.value === props.id)
const isOpen = computed(
() => isOpenEditMenu.value && editTaskId.value === props.id,
)
function onClick() {
function onStartStop() {
if (!isStarted.value)
start(props.id)
else stop()
getTaskRecords()
}
function onUpdateOpen(bool: boolean) {
Expand Down Expand Up @@ -86,7 +90,7 @@ watchEffect(() => {
<div class="flex items-center gap-2 flex-grow">
<div
class="flex-shrink-0 p-2 relative"
@click="onClick"
@click="onStartStop"
>
<SolarPlayBold
v-if="!isStarted"
Expand Down

0 comments on commit 229295b

Please sign in to comment.