Skip to content

Commit

Permalink
fix:Dialog deletion warning shows undefined when removing a dialog wi…
Browse files Browse the repository at this point in the history
…thout any callers (#8397)
  • Loading branch information
lei9444 committed Jul 14, 2021
1 parent 206915e commit 72c4e3a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions Composer/packages/client/src/pages/design/SideBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/** @jsx jsx */
import { jsx } from '@emotion/core';
import formatMessage from 'format-message';
import { Diagnostic } from '@bfc/shared';
import { Diagnostic, DialogInfo } from '@bfc/shared';
import { useRecoilValue } from 'recoil';
import { OpenConfirmModal, dialogStyle } from '@bfc/ui-shared';
import { useSetRecoilState } from 'recoil';
Expand Down Expand Up @@ -47,13 +47,13 @@ function onRenderContent(subTitle, style) {
);
}

function getAllRef(targetId, dialogs) {
let refs: string[] = [];
function getAllRef(targetId: string, dialogs: DialogInfo[]) {
const refs: string[] = [];

// find target dialog's all parent
dialogs.forEach((dialog) => {
if (dialog.id === targetId) {
refs = refs.concat(dialog.referredDialogs);
} else if (!dialog.referredDialogs.every((item) => item !== targetId)) {
refs.push(dialog.displayName || dialog.id);
if (dialog.referredDialogs?.some((name) => name === targetId)) {
refs.push(dialog.id);
}
});
return refs;
Expand Down
2 changes: 1 addition & 1 deletion Composer/packages/lib/indexers/src/dialogIndexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ function extractReferredDialogs(dialog): string[] {
* */
const visitor: VisitorFunc = (path: string, value: any): boolean => {
// it's a valid schema dialog node.
if (has(value, '$kind') && value.$kind === SDKKinds.BeginDialog) {
if (has(value, '$kind') && value.$kind === SDKKinds.BeginDialog && value.dialog) {
const dialogName = value.dialog;
dialogs.push(dialogName);
}
Expand Down

0 comments on commit 72c4e3a

Please sign in to comment.