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
|
setting.extensionName = this.name
|
||||||
})
|
})
|
||||||
try {
|
try {
|
||||||
const oldSettings = localStorage.getItem(this.name)
|
const oldSettingsJson = localStorage.getItem(this.name)
|
||||||
// Persists new settings
|
// Persists new settings
|
||||||
if (oldSettings) {
|
if (oldSettingsJson) {
|
||||||
|
const oldSettings = JSON.parse(oldSettingsJson)
|
||||||
settings.forEach((setting) => {
|
settings.forEach((setting) => {
|
||||||
// Keep setting value
|
// Keep setting value
|
||||||
if (setting.controllerProps && Array.isArray(oldSettings))
|
if (setting.controllerProps && Array.isArray(oldSettings))
|
||||||
@ -169,13 +170,13 @@ export abstract class BaseExtension implements ExtensionType {
|
|||||||
if (!this.name) return []
|
if (!this.name) return []
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const settingsString = localStorage.getItem(this.name);
|
const settingsString = localStorage.getItem(this.name)
|
||||||
if (!settingsString) return [];
|
if (!settingsString) return []
|
||||||
const settings: SettingComponentProps[] = JSON.parse(settingsString);
|
const settings: SettingComponentProps[] = JSON.parse(settingsString)
|
||||||
return settings;
|
return settings
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.warn(err);
|
console.warn(err)
|
||||||
return [];
|
return []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -201,7 +202,7 @@ export abstract class BaseExtension implements ExtensionType {
|
|||||||
|
|
||||||
if (!updatedSettings.length) updatedSettings = componentProps as SettingComponentProps[]
|
if (!updatedSettings.length) updatedSettings = componentProps as SettingComponentProps[]
|
||||||
|
|
||||||
localStorage.setItem(this.name, JSON.stringify(updatedSettings));
|
localStorage.setItem(this.name, JSON.stringify(updatedSettings))
|
||||||
|
|
||||||
updatedSettings.forEach((setting) => {
|
updatedSettings.forEach((setting) => {
|
||||||
this.onSettingUpdate<typeof setting.controllerProps.value>(
|
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() {
|
if std::env::var("CLEAN").is_ok() {
|
||||||
clean_up = true;
|
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() {
|
if !clean_up && stored_version == app_version && extensions_path.exists() {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -97,10 +97,7 @@ const ProvidersMenu = ({
|
|||||||
|
|
||||||
<Dialog>
|
<Dialog>
|
||||||
<DialogTrigger asChild>
|
<DialogTrigger asChild>
|
||||||
<div
|
<div className="bg-main-view flex cursor-pointer px-4 my-1.5 items-center gap-1.5 text-main-view-fg/80">
|
||||||
className="bg-main-view flex cursor-pointer px-4 my-1.5 items-center gap-1.5 text-main-view-fg/80"
|
|
||||||
onClick={() => {}}
|
|
||||||
>
|
|
||||||
<IconCirclePlus size={18} />
|
<IconCirclePlus size={18} />
|
||||||
<span className="capitalize">Add Provider</span>
|
<span className="capitalize">Add Provider</span>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user