Skip to content

Commit 9871594

Browse files
committed
fix: incorrect state transition
1 parent 8af1257 commit 9871594

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/background/model/background-app.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,22 @@ export class BackgroundApp {
8282
ipcMain.on(DirectStateTransition, (e, id: string) => {
8383
console.log('Direct state transition');
8484
const index = SymbolIndex.getIndex(this.project.projectSymbols);
85+
const lastState = this.states[this.states.length - 1];
8586
const nextState = index.get(id);
8687
if (nextState) {
87-
this.states.push(nextState.stateFactory());
88-
console.log('Found next state');
89-
success(e.sender, DirectStateTransition, true);
90-
} else {
91-
console.log('No next state');
92-
error(e.sender, DirectStateTransition, false);
88+
let state: State | null = nextState.stateFactory();
89+
if (lastState instanceof state.constructor) {
90+
state = lastState.nextState(id);
91+
}
92+
if (state) {
93+
this.states.push(state);
94+
console.log('Found next state');
95+
success(e.sender, DirectStateTransition, true);
96+
return;
97+
}
9398
}
99+
console.log('No next state');
100+
error(e.sender, DirectStateTransition, false);
94101
});
95102

96103
ipcMain.on(GetSymbols, e => {

0 commit comments

Comments
 (0)