Merge pull request #748 from wzdnzd/master

reset selectedClashAPIConfigIndex when remove clashApiConfig
This commit is contained in:
haishan 2023-03-11 15:47:43 +08:00 committed by GitHub
commit cd64985500
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -55,6 +55,11 @@ export function removeClashAPIConfig(conf: ClashAPIConfig) {
const idx = findClashAPIConfigIndex(getState, conf);
dispatch('removeClashAPIConfig', (s) => {
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
saveState(getState().app);