Remove migration logic (settings & templates storage location) (#1732)

* Remove isNewUserSession handling

* Remove writing of setting and templates to localStorage
This commit is contained in:
Chenlei Hu
2024-11-28 11:24:06 -08:00
committed by GitHub
parent b0085114d7
commit df3fff5dbb
4 changed files with 21 additions and 55 deletions

View File

@@ -85,29 +85,19 @@ class ManageTemplates extends ComfyDialog {
async load() {
let templates = []
if (app.isNewUserSession) {
// New user so migrate existing templates
const json = localStorage.getItem(id)
if (json) {
templates = JSON.parse(json)
}
await api.storeUserData(file, json, { stringify: false })
} else {
const res = await api.getUserData(file)
if (res.status === 200) {
try {
templates = await res.json()
} catch (error) {}
} else if (res.status !== 404) {
console.error(res.status + ' ' + res.statusText)
}
const res = await api.getUserData(file)
if (res.status === 200) {
try {
templates = await res.json()
} catch (error) {}
} else if (res.status !== 404) {
console.error(res.status + ' ' + res.statusText)
}
return templates ?? []
}
async store() {
const templates = JSON.stringify(this.templates, undefined, 4)
localStorage.setItem(id, templates) // Backwards compatibility
try {
await api.storeUserData(file, templates, { stringify: false })
} catch (error) {