Skip to content

Commit

Permalink
fix: Dialog creation, trigger creation error resolved (#4934)
Browse files Browse the repository at this point in the history
* Dialog creation issues fixed

Signed-off-by: Srinaath Ravichandran <srravich@microsoft.com>

* Project tree prevent rerender

Signed-off-by: Srinaath Ravichandran <srravich@microsoft.com>

Co-authored-by: Srinaath Ravichandran <srravich@microsoft.com>
  • Loading branch information
srinaath and Srinaath Ravichandran authored Nov 23, 2020
1 parent 74a95ad commit d18422c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,10 @@ export const ProjectTree: React.FC<Props> = ({

const jsonSchemaFilesByProjectId = useRecoilValue(jsonSchemaFilesByProjectIdSelector);

const createSubtree = useCallback(() => {
return projectCollection.map(createBotSubtree);
}, [projectCollection]);

if (rootProjectId == null) {
// this should only happen before a project is loaded in, so it won't last very long
return <LoadingSpinner />;
Expand Down Expand Up @@ -658,7 +662,7 @@ export const ProjectTree: React.FC<Props> = ({
}
};

const projectTree = projectCollection.map(createBotSubtree);
const projectTree = createSubtree();

return (
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
onDelLanguageDialogCompleteState,
showDelLanguageModalState,
botDisplayNameState,
qnaFilesState,
} from './../atoms/botState';

const copyLanguageResources = (files: any[], fromLanguage: string, toLanguages: string[]): any[] => {
Expand Down Expand Up @@ -90,12 +91,14 @@ export const multilangDispatcher = () => {
const { set, snapshot } = callbackHelpers;
const prevlgFiles = await snapshot.getPromise(lgFilesState(projectId));
const prevluFiles = await snapshot.getPromise(luFilesState(projectId));
const prevQnaFiles = await snapshot.getPromise(qnaFilesState(projectId));
const prevSettings = await snapshot.getPromise(settingsState(projectId));
const onAddLanguageDialogComplete = (await snapshot.getPromise(onAddLanguageDialogCompleteState(projectId))).func;

// copy files from default language
const lgFiles = copyLanguageResources(prevlgFiles, defaultLang, languages);
const luFiles = copyLanguageResources(prevluFiles, defaultLang, languages);
const qnaFiles = copyLanguageResources(prevQnaFiles, defaultLang, languages);

const settings: any = cloneDeep(prevSettings);
if (Array.isArray(settings.languages)) {
Expand All @@ -112,6 +115,8 @@ export const multilangDispatcher = () => {

set(lgFilesState(projectId), [...prevlgFiles, ...lgFiles]);
set(luFilesState(projectId), [...prevluFiles, ...luFiles]);
set(qnaFilesState(projectId), [...prevQnaFiles, ...qnaFiles]);

set(settingsState(projectId), settings);

if (typeof onAddLanguageDialogComplete === 'function') {
Expand Down
13 changes: 9 additions & 4 deletions Composer/packages/client/src/shell/useShell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,15 @@ export function useShell(source: EventSource, projectId: string): Shell {
confirm: OpenConfirmModal,
};

const currentDialog = useMemo(() => dialogs.find((d) => d.id === dialogId) ?? stubDialog(), [
dialogs,
dialogId,
]) as DialogInfo;
const currentDialog = useMemo(() => {
let result: any = dialogs.find((d) => d.id === dialogId) ?? dialogs.find((dialog) => dialog.isRoot);
if (!result) {
// Should not hit here as the seed content should atleast be the root dialog if no current dialog
result = stubDialog();
}
return result;
}, [dialogs, dialogId]);

const editorData = useMemo(() => {
return source === 'PropertyEditor'
? getDialogData(dialogsMap, dialogId, focused || selected || '')
Expand Down

0 comments on commit d18422c

Please sign in to comment.