Skip to content

Commit

Permalink
more type fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ad1992 committed Mar 29, 2024
1 parent 799af4e commit 2fd6de0
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions packages/mermaid/src/diagrams/sequence/sequenceDb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type Actor = {
type Message = {
from?: { actor: string };
to?: { actor: string };
message?:
message:
| string
| {
start: number;
Expand Down Expand Up @@ -146,19 +146,23 @@ export const addActor = function (
state.records.prevActor = id;
};

const activationCount = (part?: string) => {
const activationCount = (part: string) => {
let i;
let count = 0;
if (!part) {
return 0;
}

for (i = 0; i < state.records.messages.length; i++) {
if (
state.records.messages[i].type === LINETYPE.ACTIVE_START &&
state.records.messages[i].from?.actor === part
state.records.messages[i].from!.actor === part
) {
count++;
}
if (
state.records.messages[i].type === LINETYPE.ACTIVE_END &&
state.records.messages[i].from?.actor === part
state.records.messages[i].from!.actor === part
) {
count--;
}
Expand Down Expand Up @@ -189,7 +193,7 @@ export const addSignal = function (
activate: boolean = false
) {
if (messageType === LINETYPE.ACTIVE_END) {
const cnt = activationCount(idFrom?.actor);
const cnt = activationCount(idFrom?.actor || '');
if (cnt < 1) {
// Bail out as there is an activation signal from an inactive participant
const error = new Error(
Expand All @@ -210,7 +214,7 @@ export const addSignal = function (
state.records.messages.push({
from: idFrom,
to: idTo,
message: message?.text,
message: message?.text ?? '',
wrap: (message?.wrap === undefined && autoWrap()) || !!message?.wrap,
type: messageType,
activate,
Expand Down

0 comments on commit 2fd6de0

Please sign in to comment.