Skip to content

Commit

Permalink
fixed displaying graphic in Codex dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
PrzeSta committed Aug 13, 2022
1 parent 6c95cbd commit e55ece3
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions frontend/src/views/CodexView/dialog/CodexDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,6 @@ export const CodexDialog: React.FC<CodexDialogProps> = props => {
const [fields, setFields] = useState(createEmptyCodexFields(currentSchema));
const [entryImageBase64, setEntryImageBase64] = useState<string | null>(null);

useEffect(() => {
if (currentEntry) {
setDialogTitle(`Edit ${currentSchema?.title} entry`);
setFields(createFilledCodexFields(currentSchema, currentEntry, entries));
setEntryTitle(currentEntry.title);
} else {
setDialogTitle('Create new entry');
setFields(createEmptyCodexFields(currentSchema));
setEntryTitle('');
}
}, [currentEntry, currentSchema, entries]);

const resetDialog = useCallback(() => {
if (currentEntry) {
setDialogTitle(`Edit ${currentSchema?.title} entry`);
Expand All @@ -88,6 +76,10 @@ export const CodexDialog: React.FC<CodexDialogProps> = props => {
}
}, [currentEntry, currentSchema, entries]);

useEffect(() => {
resetDialog();
}, [resetDialog]);

const {
isLoading: isLoadingNew,
data: dataNew,
Expand Down

0 comments on commit e55ece3

Please sign in to comment.