zadam / trilium

Build your personal knowledge base with Trilium Notes
GNU Affero General Public License v3.0
27.2k stars 1.9k forks source link

(Bug report) Promoted relations not in correct order #4105

Closed mm21 closed 1 year ago

mm21 commented 1 year ago

Trilium Version

next61 (f8c9178)

What operating system are you using?

Ubuntu

What is your setup?

Server access only

Operating System Version

Ubuntu 22.04 LTS

Description

The order of promoted relations:

image

Doesn't follow the actual attribute order:

image

But promoted labels seem to be ordered fine. This applies to labels too.

Error logs

No response

mm21 commented 1 year ago

For some background, these relations are created via ETAPI and can be created out of order, which I think is what's causing this.

mm21 commented 1 year ago

Did some digging and can confirm that values of promoted attributes are showing in the order in which they're created, not their position, even after restarting frontend and backend. It reproduces in the UI for me as well.

From looking at the code, I think FNote.getOwnedAttributes() is not taking position into account while FNote.getAttributes() is.

Edit: and this indeed applies to labels too, it was just a coincidence that I was creating the labels in the right order.

zadam commented 1 year ago

Actually not even getAttributes() has guaranteed sorting. The position order of attributes is mostly important for UI in a few places and thus the data model does not keep them sorted.

So this fixes it in the promoted attributes UI.

mm21 commented 1 year ago

Makes sense. Thanks for the background and quick fix!