Refactor getLastCommitedState
This commit is contained in:
parent
a0888f8c90
commit
2f847514f0
@ -1451,14 +1451,15 @@ export default class Services {
|
|||||||
.join('');
|
.join('');
|
||||||
}
|
}
|
||||||
|
|
||||||
public getLastCommitedState(process: Process): ProcessState {
|
public getLastCommitedState(process: Process): ProcessState | null {
|
||||||
if (!process || !process.states || process.states.length === 0) {
|
if (process.states.length === 0) return null;
|
||||||
console.error('Invalid process or no states');
|
const processTip = process.states[process.states.length - 1].commited_in;
|
||||||
|
const lastCommitedState = process.states.findLast(state => state.commited_in !== processTip);
|
||||||
|
if (lastCommitedState) {
|
||||||
|
return lastCommitedState;
|
||||||
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dans la nouvelle structure, le premier état est le dernier état validé
|
|
||||||
return process.states[0];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public isPairingProcess(roles: Record<string, RoleDefinition>): boolean {
|
public isPairingProcess(roles: Record<string, RoleDefinition>): boolean {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user