Skip to content

Commit

Permalink
revert from and to type to object
Browse files Browse the repository at this point in the history
  • Loading branch information
ad1992 committed Apr 5, 2024
1 parent a14637b commit 12bd301
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions packages/mermaid/src/diagrams/sequence/sequenceDb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,13 @@ const activationCount = (part: string) => {
for (i = 0; i < state.records.messages.length; i++) {
if (
state.records.messages[i].type === LINETYPE.ACTIVE_START &&
state.records.messages[i].from === part
state.records.messages[i].from?.actor === part
) {
count++;
}
if (
state.records.messages[i].type === LINETYPE.ACTIVE_END &&
state.records.messages[i].from === part
state.records.messages[i].from?.actor === part
) {
count--;
}
Expand Down Expand Up @@ -157,10 +157,12 @@ export const addSignal = function (
activate: boolean = false
) {
if (messageType === LINETYPE.ACTIVE_END) {
const cnt = activationCount(idFrom || '');
const cnt = activationCount(idFrom?.actor || '');
if (cnt < 1) {
// Bail out as there is an activation signal from an inactive participant
const error = new Error('Trying to inactivate an inactive participant (' + idFrom + ')');
const error = new Error(
'Trying to inactivate an inactive participant (' + idFrom?.actor + ')'
);

// @ts-ignore: we are passing hash param to the error object, however we should define our own custom error class to make it type safe
error.hash = {
Expand Down
4 changes: 2 additions & 2 deletions packages/mermaid/src/diagrams/sequence/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export interface Actor {
}

export interface Message {
from?: string;
to?: string;
from?: { actor: string };
to?: { actor: string };
message:
| string
| {
Expand Down

0 comments on commit 12bd301

Please sign in to comment.