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