Skip to content

Commit

Permalink
add fetch toast
Browse files Browse the repository at this point in the history
  • Loading branch information
vipzero committed Dec 30, 2023
1 parent 0577ec5 commit 0c1ead6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/config/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ const { NODE_ENV } = process.env

export const isDev = NODE_ENV === 'development'

// update を促したい時に使う
export const featcherVersion = 1

export const events: Event[] = [
{ id: '2023winter', label: '2023冬', current: true },
{ id: '2023obon', label: '2023盆' },
Expand Down
9 changes: 8 additions & 1 deletion src/hooks/useSongDb.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import {
useEffect,
useState,
} from 'react'
import { toast } from 'react-toastify'
import {
incSongBookCount,
readSong,
saveSongBg,
watchHistSong,
} from '../service/firebase'
import { currentEvent } from '../config'
import { currentEvent, featcherVersion } from '../config'
import { HistoryRaw, Song } from '../types'
import { formatCount } from '../util'
import { useQeuryEid } from './useQueryEid'
Expand Down Expand Up @@ -44,6 +45,12 @@ export function useSongDb(online = true) {
song.wordCountsAna = [...wordCountsAna].sort((a, b) => a.count - b.count)

setSong(song)
if (song.frontVersion && song.frontVersion.ver > featcherVersion) {
const { msg } = song.frontVersion
setTimeout(() => {
toast.info(msg, { autoClose: false })
}, 1000)
}
checkHit(song.icy + ' _ ' + song.animeTitle || '')
setLoaded(true)
})
Expand Down
1 change: 1 addition & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export type SongMiss = {
wordCounts: Record<string, number>
wordCountsAna: { name: string; label: string; count: number }[]
imageSearchWord: string
frontVersion?: { ver: number; msg: string }
hedwig?: string
}

Expand Down

0 comments on commit 0c1ead6

Please sign in to comment.