mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-24 00:34:09 +00:00
Remove app.storageLocation handling (#1731)
This commit is contained in:
@@ -36,7 +36,6 @@ import {
|
||||
LGraphNode,
|
||||
LiteGraph
|
||||
} from '@comfyorg/litegraph'
|
||||
import { StorageLocation } from '@/types/settingTypes'
|
||||
import { ExtensionManager } from '@/types/extensionTypes'
|
||||
import {
|
||||
ComfyNodeDefImpl,
|
||||
@@ -144,7 +143,6 @@ export class ComfyApp {
|
||||
progress: { value: number; max: number } | null
|
||||
configuringGraph: boolean
|
||||
isNewUserSession: boolean
|
||||
storageLocation: StorageLocation
|
||||
ctx: CanvasRenderingContext2D
|
||||
bodyTop: HTMLElement
|
||||
bodyLeft: HTMLElement
|
||||
@@ -180,6 +178,14 @@ export class ComfyApp {
|
||||
return ComfyWidgets
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated storageLocation is always 'server' since
|
||||
* https://github.com/comfyanonymous/ComfyUI/commit/53c8a99e6c00b5e20425100f6680cd9ea2652218
|
||||
*/
|
||||
get storageLocation() {
|
||||
return 'server'
|
||||
}
|
||||
|
||||
constructor() {
|
||||
this.vueAppReady = false
|
||||
this.ui = new ComfyUI(this)
|
||||
@@ -1699,30 +1705,12 @@ export class ComfyApp {
|
||||
)
|
||||
}
|
||||
|
||||
async #migrateSettings() {
|
||||
this.isNewUserSession = true
|
||||
// Store all current settings
|
||||
const settings = Object.keys(this.ui.settings).reduce((p, n) => {
|
||||
const v = localStorage[`Comfy.Settings.${n}`]
|
||||
if (v) {
|
||||
try {
|
||||
p[n] = JSON.parse(v)
|
||||
} catch (error) {}
|
||||
}
|
||||
return p
|
||||
}, {})
|
||||
|
||||
await api.storeSettings(settings)
|
||||
}
|
||||
|
||||
async #setUser() {
|
||||
const userConfig = await api.getUserConfig()
|
||||
this.storageLocation = userConfig.storage
|
||||
if (typeof userConfig.migrated == 'boolean') {
|
||||
// Single user mode migrated true/false for if the default user is created
|
||||
if (!userConfig.migrated && this.storageLocation === 'server') {
|
||||
// Default user not created yet
|
||||
await this.#migrateSettings()
|
||||
if (!userConfig.migrated) {
|
||||
this.isNewUserSession = true
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -1747,7 +1735,7 @@ export class ComfyApp {
|
||||
|
||||
if (created) {
|
||||
api.user = user
|
||||
await this.#migrateSettings()
|
||||
this.isNewUserSession = true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -55,15 +55,11 @@ export class ComfySettingsDialog extends ComfyDialog<HTMLDialogElement> {
|
||||
}
|
||||
|
||||
async load() {
|
||||
if (this.app.storageLocation === 'browser') {
|
||||
this.settingsValues = localStorage
|
||||
} else {
|
||||
this.settingsValues = await api.getSettings()
|
||||
}
|
||||
this.settingsValues = await api.getSettings()
|
||||
|
||||
// Trigger onChange for any settings added before load
|
||||
for (const id in this.settingsLookup) {
|
||||
const compatId = this.getId(id)
|
||||
const compatId = id
|
||||
this.settingsValues[compatId] = this.tryMigrateDeprecatedValue(
|
||||
id,
|
||||
this.settingsValues[compatId]
|
||||
@@ -74,25 +70,11 @@ export class ComfySettingsDialog extends ComfyDialog<HTMLDialogElement> {
|
||||
}
|
||||
}
|
||||
|
||||
getId(id: string) {
|
||||
if (this.app.storageLocation === 'browser') {
|
||||
id = 'Comfy.Settings.' + id
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
getSettingValue<K extends keyof Settings>(
|
||||
id: K,
|
||||
defaultValue?: Settings[K]
|
||||
): Settings[K] {
|
||||
let value = this.settingsValues[this.getId(id)]
|
||||
if (value != null) {
|
||||
if (this.app.storageLocation === 'browser') {
|
||||
try {
|
||||
value = JSON.parse(value)
|
||||
} catch (error) {}
|
||||
}
|
||||
}
|
||||
let value = this.settingsValues[id]
|
||||
return (value ?? defaultValue) as Settings[K]
|
||||
}
|
||||
|
||||
@@ -111,7 +93,7 @@ export class ComfySettingsDialog extends ComfyDialog<HTMLDialogElement> {
|
||||
localStorage['Comfy.Settings.' + id] = json // backwards compatibility for extensions keep setting in storage
|
||||
|
||||
let oldValue = this.getSettingValue(id, undefined)
|
||||
this.settingsValues[this.getId(id)] = value
|
||||
this.settingsValues[id] = value
|
||||
|
||||
if (id in this.settingsLookup) {
|
||||
this.settingsLookup[id].onChange?.(value, oldValue)
|
||||
|
||||
Reference in New Issue
Block a user