Skip to content

Commit

Permalink
Update PreferencesController state to handle references (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
estebanmino authored and MajorLift committed Oct 11, 2023
1 parent 1b70dc5 commit 2b0c306
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/PreferencesController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export class PreferencesController extends BaseController<BaseConfig, Preference
setFeatureFlag(feature: string, activated: boolean) {
const oldFeatureFlags = this.state.featureFlags;
const featureFlags = { ...oldFeatureFlags, ...{ [feature]: activated } };
this.update({ featureFlags });
this.update({ featureFlags: { ...featureFlags } });
}

/**
Expand Down Expand Up @@ -161,7 +161,7 @@ export class PreferencesController extends BaseController<BaseConfig, Preference
};
return ids;
}, {});
this.update({ identities });
this.update({ identities: { ...identities } });
}

/**
Expand All @@ -173,15 +173,15 @@ export class PreferencesController extends BaseController<BaseConfig, Preference
if (url === 'http://localhost:8545') {
return;
}
const newFrequentRpcList = this.state.frequentRpcList;
const index = newFrequentRpcList.findIndex((element) => {
const frequentRpcList = this.state.frequentRpcList;
const index = frequentRpcList.findIndex((element) => {
return element === url;
});
if (index !== -1) {
newFrequentRpcList.splice(index, 1);
frequentRpcList.splice(index, 1);
}
newFrequentRpcList.push(url);
this.update({ frequentRpcList: newFrequentRpcList });
frequentRpcList.push(url);
this.update({ frequentRpcList: [...frequentRpcList] });
}

/**
Expand All @@ -193,14 +193,14 @@ export class PreferencesController extends BaseController<BaseConfig, Preference
if (url === 'http://localhost:8545') {
return;
}
const newFrequentRpcList = this.state.frequentRpcList;
const index = newFrequentRpcList.findIndex((element) => {
const frequentRpcList = this.state.frequentRpcList;
const index = frequentRpcList.findIndex((element) => {
return element === url;
});
if (index !== -1) {
newFrequentRpcList.splice(index, 1);
frequentRpcList.splice(index, 1);
}
this.update({ frequentRpcList: newFrequentRpcList });
this.update({ frequentRpcList: [...frequentRpcList] });
}
}

Expand Down

0 comments on commit 2b0c306

Please sign in to comment.