Skip to content

Commit

Permalink
some fix in Updates.tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
relaxdd committed May 30, 2023
1 parent e07be06 commit 8c8306e
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/temps/Updates.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { getLocalVersion, LS_VERSION_KEY } from '@/data'
import TableService from '@/service/TableService'
import { appVersion } from '@/defines'

function reformatLegacy214040() {
if (getLocalVersion() >= 214040) return
function reformatLegacy215021(when: boolean) {
if (!when) return

const list = TableService.listOfTablesInfo

Expand All @@ -23,10 +23,12 @@ function reformatLegacy214040() {
}
}

type TestUpdate = { when: boolean, fn: (when: boolean) => void }[]

const listOfUpdates = [
{
when: getLocalVersion() < 214040,
fn: reformatLegacy214040,
when: getLocalVersion() < 215021,
fn: reformatLegacy215021,
},
]

Expand All @@ -36,9 +38,9 @@ const Updates = () => {
useEffect(() => {
if (!isUpdate) return

for (const update of listOfUpdates) {
if (!update.when) continue
update.fn()
for (const { when, fn } of listOfUpdates) {
if (!when) continue
fn(when)
}

localStorage.setItem(LS_VERSION_KEY, String(appVersion.code))
Expand Down

0 comments on commit 8c8306e

Please sign in to comment.