Skip to content

refactor(main): simplify _updateDom with async/await#4185

Merged
khassel merged 1 commit into
MagicMirrorOrg:developfrom
KristjanESPERANTO:refactor/updatedom
Jun 12, 2026
Merged

refactor(main): simplify _updateDom with async/await#4185
khassel merged 1 commit into
MagicMirrorOrg:developfrom
KristjanESPERANTO:refactor/updatedom

Conversation

@KristjanESPERANTO

Copy link
Copy Markdown
Collaborator

_updateDom was wrapping its entire body in a new Promise(resolve => {...}) constructor just to chain getDom() and updateDomWithContent() together. Since updateDomWithContent was already converted to async in #4182, we can now just await it directly - the manual wrapper, the explicit Promise.resolve() normalization, and the nested .then().catch() chain all become unnecessary, making the control flow easier to follow.
Also added .catch(Log.error) at both call sites, since async functions reject on error instead of swallowing it silently.

@sdetweil

Copy link
Copy Markdown
Collaborator

Cool, that was a head scratcher. Trouble caused long before await

@KristjanESPERANTO

Copy link
Copy Markdown
Collaborator Author

I'm glad you like it. And kudos to everyone who set this up and managed to make sense of such pre-async/await patterns 🤯

@khassel khassel merged commit b9be026 into MagicMirrorOrg:develop Jun 12, 2026
12 checks passed
KristjanESPERANTO added a commit to KristjanESPERANTO/MagicMirror that referenced this pull request Jun 12, 2026
…4185)

`_updateDom` was wrapping its entire body in a `new Promise(resolve =>
{...})` constructor just to chain `getDom()` and
`updateDomWithContent()` together. Since `updateDomWithContent` was
already converted to async in MagicMirrorOrg#4182, we can now just `await` it directly
- the manual wrapper, the explicit `Promise.resolve()` normalization,
and the nested `.then().catch()` chain all become unnecessary, making
the control flow easier to follow.
Also added `.catch(Log.error)` at both call sites, since async functions
reject on error instead of swallowing it silently.
@KristjanESPERANTO KristjanESPERANTO deleted the refactor/updatedom branch June 12, 2026 22:24
KristjanESPERANTO added a commit to KristjanESPERANTO/MagicMirror that referenced this pull request Jun 12, 2026
…4185)

`_updateDom` was wrapping its entire body in a `new Promise(resolve =>
{...})` constructor just to chain `getDom()` and
`updateDomWithContent()` together. Since `updateDomWithContent` was
already converted to async in MagicMirrorOrg#4182, we can now just `await` it directly
- the manual wrapper, the explicit `Promise.resolve()` normalization,
and the nested `.then().catch()` chain all become unnecessary, making
the control flow easier to follow.
Also added `.catch(Log.error)` at both call sites, since async functions
reject on error instead of swallowing it silently.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants