fix: extension settings are not retained in new sessions (#5154)
This commit is contained in:
parent
9265a56f04
commit
646ba86de8
@ -118,9 +118,10 @@ export abstract class BaseExtension implements ExtensionType {
|
||||
setting.extensionName = this.name
|
||||
})
|
||||
try {
|
||||
const oldSettings = localStorage.getItem(this.name)
|
||||
const oldSettingsJson = localStorage.getItem(this.name)
|
||||
// Persists new settings
|
||||
if (oldSettings) {
|
||||
if (oldSettingsJson) {
|
||||
const oldSettings = JSON.parse(oldSettingsJson)
|
||||
settings.forEach((setting) => {
|
||||
// Keep setting value
|
||||
if (setting.controllerProps && Array.isArray(oldSettings))
|
||||
@ -169,13 +170,13 @@ export abstract class BaseExtension implements ExtensionType {
|
||||
if (!this.name) return []
|
||||
|
||||
try {
|
||||
const settingsString = localStorage.getItem(this.name);
|
||||
if (!settingsString) return [];
|
||||
const settings: SettingComponentProps[] = JSON.parse(settingsString);
|
||||
return settings;
|
||||
const settingsString = localStorage.getItem(this.name)
|
||||
if (!settingsString) return []
|
||||
const settings: SettingComponentProps[] = JSON.parse(settingsString)
|
||||
return settings
|
||||
} catch (err) {
|
||||
console.warn(err);
|
||||
return [];
|
||||
console.warn(err)
|
||||
return []
|
||||
}
|
||||
}
|
||||
|
||||
@ -201,7 +202,7 @@ export abstract class BaseExtension implements ExtensionType {
|
||||
|
||||
if (!updatedSettings.length) updatedSettings = componentProps as SettingComponentProps[]
|
||||
|
||||
localStorage.setItem(this.name, JSON.stringify(updatedSettings));
|
||||
localStorage.setItem(this.name, JSON.stringify(updatedSettings))
|
||||
|
||||
updatedSettings.forEach((setting) => {
|
||||
this.onSettingUpdate<typeof setting.controllerProps.value>(
|
||||
|
||||
@ -49,6 +49,12 @@ pub fn install_extensions(app: tauri::AppHandle, force: bool) -> Result<(), Stri
|
||||
if std::env::var("CLEAN").is_ok() {
|
||||
clean_up = true;
|
||||
}
|
||||
log::info!(
|
||||
"Installing extensions. Clean up: {}, Stored version: {}, App version: {}",
|
||||
clean_up,
|
||||
stored_version,
|
||||
app_version
|
||||
);
|
||||
if !clean_up && stored_version == app_version && extensions_path.exists() {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
@ -97,10 +97,7 @@ const ProvidersMenu = ({
|
||||
|
||||
<Dialog>
|
||||
<DialogTrigger asChild>
|
||||
<div
|
||||
className="bg-main-view flex cursor-pointer px-4 my-1.5 items-center gap-1.5 text-main-view-fg/80"
|
||||
onClick={() => {}}
|
||||
>
|
||||
<div className="bg-main-view flex cursor-pointer px-4 my-1.5 items-center gap-1.5 text-main-view-fg/80">
|
||||
<IconCirclePlus size={18} />
|
||||
<span className="capitalize">Add Provider</span>
|
||||
</div>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user