Skip to content

Commit

Permalink
Fix build 2
Browse files Browse the repository at this point in the history
  • Loading branch information
dolanske committed Jul 29, 2024
1 parent 395fc8d commit 5489bad
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import dayjs from 'dayjs'
import relativeTime from 'dayjs/plugin/relativeTime'
import customParseFormat from 'dayjs/plugin/customParseFormat'
import duration from 'dayjs/plugin/duration'
import type { FormattedEvent } from './types'
import type { EventItem, FormattedEvent } from './types'
import { INPUT_FORMAT, formatEventData } from './time'
import { CountdownItem } from './components/CountdownItem'
import { Sidebar } from './components/Sidebar'
Expand All @@ -14,7 +14,15 @@ dayjs.extend(relativeTime)
dayjs.extend(customParseFormat)
dayjs.extend(duration)

const events = await getEvents() ?? []
let events: Array<FormattedEvent | EventItem> = []

getEvents()
.then((data) => {
// Initially sort dataset
events = data ?? []
sortAndFormatDataset()
})

const formattedEvents = ref<FormattedEvent[]>([])

// ----------------------------------------------------------------------------
Expand All @@ -41,9 +49,6 @@ function sortAndFormatDataset() {
}
}

// Initially sort dataset
sortAndFormatDataset()

// Watch for hash changes and sort again
window.addEventListener('hashchange', sortAndFormatDataset)

Expand Down

0 comments on commit 5489bad

Please sign in to comment.