Skip to content

Commit

Permalink
fix setting migration bugs from update
Browse files Browse the repository at this point in the history
  • Loading branch information
bluecaret committed Jul 27, 2023
1 parent 1d38dd7 commit 50a71a9
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 21 deletions.
8 changes: 6 additions & 2 deletions src/components/settings/AdvancedSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
<script setup>
import { useSettingsStore, getStorage, setStorage } from '@/store.js'
import { mergeV3Settings } from '@/helpers/mergeOldSettings.js'
import { useI18n } from 'vue-i18n'
const store = useSettingsStore()
const { t } = useI18n()
const exportSettings = async () => {
let currentWallpaper = await getStorage('currentWallpaper', 'local')
Expand Down Expand Up @@ -46,7 +48,8 @@ const importSettings = () => {
}
if (!settings.config.global.schema || settings.config.global.schema !== store.config.global.schema) {
alert($t('advanced.importNotCompatible'))
const importNotCompatibleMsg = t('advanced.importNotCompatible')
alert(importNotCompatibleMsg)
store.isLoading = false
return
}
Expand All @@ -56,7 +59,8 @@ const importSettings = () => {
await setStorage({ nextWallpaper: settings.nextWallpaper }, 'local')
await store.save()
store.isLoading = false
alert($t('advanced.importSuccessful', ['[email protected]']))
const importSuccessfulMsg = t('advanced.importSuccessful', ['[email protected]'])
alert(importSuccessfulMsg)
window.location.reload()
}
reader.readAsText(input.files[0])
Expand Down
3 changes: 2 additions & 1 deletion src/components/settings/WallpaperSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ const getUploadedImage = () => {
const reader = new FileReader()
if (!files[0].type.match(fileTypePattern)) {
alert($t('settings.invalidFileType'))
const invalidFileTypeMsg = t('settings.invalidFileType')
alert(invalidFileTypeMsg)
return
}
Expand Down
3 changes: 2 additions & 1 deletion src/components/widgets/WeatherSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ const getMyLoc = () => {
(err) => {
store.isLoading = false
console.warn(`ERROR(${err.code}): ${err.message}`)
alert(t('widget.unableToGetYourLocation'))
const unableToGetYourLocationMsg = t('widget.unableToGetYourLocation')
alert(unableToGetYourLocationMsg)
},
{
timeout: 5000,
Expand Down
48 changes: 31 additions & 17 deletions src/helpers/mergeOldSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ export const mergeV3Settings = async (allowMigration) => {
newWidget.type = 'ql'
newWidget.quickLinks = [
...oldQuickLink.links.map((l) => {
return { id: l.id, title: l.label, url: l.url }
return { id: l.id, title: l.label, url: l.url, special: 'none' }
}),
]
newWidget.link.icons = oldQuickLink.icons
Expand Down Expand Up @@ -317,22 +317,36 @@ export const mergeV3Settings = async (allowMigration) => {
newLayer.on = false

newWidget.timezone = oldDate.timezone
newWidget.day.on = oldDate.day.enabled
newWidget.day.twoDigit = oldDate.day.twoDigit
newWidget.dayOfWeek.on = oldDate.dayOfWeek.enabled
newWidget.dayOfWeek.abbreviated = oldDate.dayOfWeek.abbr
newWidget.dayOfYear.on = oldDate.dayOfYear.enabled
newWidget.dayOfYear.suffixLabel = oldDate.dayOfYear.label
newWidget.month.on = oldDate.month.enabled
newWidget.month.abbreviated = oldDate.month.abbr
newWidget.month.twoDigit = oldDate.month.twoDigit
newWidget.quarter.on = oldDate.quarter.enabled
newWidget.quarter.suffixLabel = oldDate.quarter.label
newWidget.quarter.start = oldDate.quarter.start
newWidget.week.on = oldDate.week.enabled
newWidget.week.prefixLabel = oldDate.week.label
newWidget.year.on = oldDate.year.enabled
newWidget.year.twoDigit = oldDate.year.twoDigit
if (oldDate.day) {
newWidget.day.on = oldDate.day.enabled
newWidget.day.twoDigit = oldDate.day.twoDigit
}
if (oldDate.dayOfWeek) {
newWidget.dayOfWeek.on = oldDate.dayOfWeek.enabled
newWidget.dayOfWeek.abbreviated = oldDate.dayOfWeek.abbr
}
if (oldDate.dayOfYear) {
newWidget.dayOfYear.on = oldDate.dayOfYear.enabled
newWidget.dayOfYear.suffixLabel = oldDate.dayOfYear.label
}
if (oldDate.month) {
newWidget.month.on = oldDate.month.enabled
newWidget.month.abbreviated = oldDate.month.abbr
newWidget.month.twoDigit = oldDate.month.twoDigit
}
if (oldDate.quarter) {
newWidget.quarter.on = oldDate.quarter.enabled
newWidget.quarter.suffixLabel = oldDate.quarter.label
newWidget.quarter.start = oldDate.quarter.start
}
if (oldDate.week) {
newWidget.week.on = oldDate.week.enabled
newWidget.week.prefixLabel = oldDate.week.label
}
if (oldDate.year) {
newWidget.year.on = oldDate.year.enabled
newWidget.year.twoDigit = oldDate.year.twoDigit
}

merge.config.dates = []
merge.config.dates.push(newWidget)
Expand Down

0 comments on commit 50a71a9

Please sign in to comment.