From 0c1ead65b1a9b0849598155f4e4c8683e71fe594 Mon Sep 17 00:00:00 2001 From: vipzero Date: Sat, 30 Dec 2023 19:24:56 +0900 Subject: [PATCH] add fetch toast --- src/config/index.tsx | 3 +++ src/hooks/useSongDb.tsx | 9 ++++++++- src/types/index.ts | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/config/index.tsx b/src/config/index.tsx index 56bec3499..c5735c193 100644 --- a/src/config/index.tsx +++ b/src/config/index.tsx @@ -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盆' }, diff --git a/src/hooks/useSongDb.tsx b/src/hooks/useSongDb.tsx index a5c6fd7f3..d346799aa 100644 --- a/src/hooks/useSongDb.tsx +++ b/src/hooks/useSongDb.tsx @@ -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' @@ -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) }) diff --git a/src/types/index.ts b/src/types/index.ts index cbfcfdbc4..932bc307e 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -19,6 +19,7 @@ export type SongMiss = { wordCounts: Record wordCountsAna: { name: string; label: string; count: number }[] imageSearchWord: string + frontVersion?: { ver: number; msg: string } hedwig?: string }