mirror of
https://github.com/zadam/trilium.git
synced 2026-02-19 12:14:23 +01:00
chore(client): address requested changes
This commit is contained in:
parent
7a534c3ea7
commit
b0a3d54276
@ -190,7 +190,7 @@ async function toggleDangerousAttribute(note: FNote, type: "label" | "relation",
|
||||
for (const attr of attrs) {
|
||||
const baseName = getNameWithoutDangerousPrefix(attr.name);
|
||||
const newName = willEnable ? baseName : `disabled:${baseName}`;
|
||||
if (newName === attr.name) return;
|
||||
if (newName === attr.name) continue;
|
||||
|
||||
// We are adding and removing afterwards to avoid a flicker (because for a moment there would be no active content attribute anymore) because the operations are done in sequence and not atomically.
|
||||
if (attr.type === "label") {
|
||||
|
||||
@ -203,14 +203,10 @@ function ActiveContentToggle({ note, info }: { note: FNote, info: ActiveContentI
|
||||
switchOffTooltip={t("active_content_badges.toggle_tooltip_disable_tooltip", { type: title })}
|
||||
switchOnTooltip={t("active_content_badges.toggle_tooltip_enable_tooltip", { type: title })}
|
||||
onChange={async (willEnable) => {
|
||||
const attrs = note.getOwnedAttributes()
|
||||
.filter(attr => {
|
||||
if (attr.isInheritable) return false;
|
||||
const baseName = attributes.getNameWithoutDangerousPrefix(attr.name);
|
||||
return DANGEROUS_ATTRIBUTES.some(item => item.name === baseName && item.type === attr.type);
|
||||
});
|
||||
|
||||
await Promise.all(attrs.map(a => attributes.toggleDangerousAttribute(note, a.type, a.name, willEnable)));
|
||||
await Promise.all(note.getOwnedAttributes()
|
||||
.map(attr => ({ name: attributes.getNameWithoutDangerousPrefix(attr.name), type: attr.type }))
|
||||
.filter(({ name, type }) => DANGEROUS_ATTRIBUTES.some(item => item.name === name && item.type === type))
|
||||
.map(({ name, type }) => attributes.toggleDangerousAttribute(note, type, name, willEnable)));
|
||||
}}
|
||||
/>;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user