handling missing ids better + more tranlsations

This commit is contained in:
ari committed 2022-09-01 17:21:00 -04:00
1 parent 69a9805c02
commit 774ebe482a
45 files changed
+556 -262

No files matched your search

@@ -37,7 +37,11 @@ export const useAutomationManagerState = ({
.map(({ id, tags = {} }) => ({
id,
tags,
})),
}))
.filter(({ id }) => typeof id === "string") as Array<{
id: string;
tags: Record<string, string>;
}>,
onUpdateTags
);
const automationDB = useAutomationDB(hassEntities, configAutomations, tagsDB);
@@ -78,6 +82,14 @@ export const useAutomationManagerState = ({
get currentAutomationEntityId(): string | null {
return currentAutomation === null ? null : currentAutomation[0].entityId;
},
get currentAutomationIsReadOnly(): boolean {
return currentAutomation === null ? true : currentAutomation[0].readonly;
},
get currentAutomationIssue(): string | undefined {
return currentAutomation === null
? undefined
: currentAutomation[0].issue;
},
async setSelectedAutomationId(i: string | null, force: boolean = false) {
if (methods.currentAutomationIsNew && !force) {
if (!(await stillHaveNewAreYouSure())) {
@@ -94,7 +106,9 @@ export const useAutomationManagerState = ({
}
}
const auto = automationDB.addNew();
methods.setSelectedAutomationId(auto.id, true);
if (auto.id) {
methods.setSelectedAutomationId(auto.id, true);
}
},
editorUpdateAutomation(auto: AutomationData | BareAutomationData) {
if (methods.currentAutomationIsNew) {