reset selectedClashAPIConfigIndex when remove clashApiConfig
This commit is contained in:
parent
e7a5088b97
commit
79ebb04438
1 changed files with 5 additions and 0 deletions
|
@ -55,6 +55,11 @@ export function removeClashAPIConfig(conf: ClashAPIConfig) {
|
||||||
const idx = findClashAPIConfigIndex(getState, conf);
|
const idx = findClashAPIConfigIndex(getState, conf);
|
||||||
dispatch('removeClashAPIConfig', (s) => {
|
dispatch('removeClashAPIConfig', (s) => {
|
||||||
s.app.clashAPIConfigs.splice(idx, 1);
|
s.app.clashAPIConfigs.splice(idx, 1);
|
||||||
|
if (idx === s.app.selectedClashAPIConfigIndex) {
|
||||||
|
s.app.selectedClashAPIConfigIndex = 0;
|
||||||
|
} else if (idx < s.app.selectedClashAPIConfigIndex) {
|
||||||
|
s.app.selectedClashAPIConfigIndex -= 1;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
// side effect
|
// side effect
|
||||||
saveState(getState().app);
|
saveState(getState().app);
|
||||||
|
|
Loading…
Reference in a new issue