the-djmaze/snappymail

JS/KO error '$index is not defined' in Settings > Accounts

SergeyMosin opened this issue · 2 comments

Describe the bug
Clicking on the Accounts tab in the Settings does not work on the first try in v2.38.1

Details
Browser console error:

Uncaught ReferenceError: Unable to process binding "template: () => ({ name: RoutedSettingsViewModel.template })"
Message: Unable to process binding "foreach: ()=>(identities)"
Message: Unable to process binding "visible: ()=>(0 === $index())"
Message: $index is not defined

This is most like a regression from c14bbab

Possible fix is to replace this:

<span class="identity-default" data-bind="visible: 0 === $index()" data-i18n="GLOBAL/DEFAULT"></span>

with something like this:

<span class="identity-default" data-bind="visible: id() === ''" data-i18n="GLOBAL/DEFAULT"></span>

only secondary identities have ids

I had the same error once and never again.
Will try to replicate and see what causes it.

Although it is fixed, i might have a better approach for the deprecated with statement.
It also makes the template bindings much more secure.

I have to test this change how much it will impact the speed.
904a353