Environments order#4048
Conversation
dimitropoulos
left a comment
There was a problem hiding this comment.
Thanks! I tested using the steps in #3822 and can confirm that this PR fixes what's described in those steps.
|
Hi @dimitropoulos. I also include a change to address issue #3922, but I was not sure if it was a good idea since there were no feedback from you under that |
|
@vincendep is it something different than this fix? if so, it'd be great if you knew the reproduction steps (and would open a new PR for that issue so we can handle separately). |
|
It is quite related, since I had to update my previous changes. |
develohpanda
left a comment
There was a problem hiding this comment.
On testing this seems to work well! A couple of notes however, would love your thoughts!
| // Deterministic base env ID. It helps reduce sync complexity since we won't have to | ||
| // de-duplicate environments. | ||
| _id: `${prefix}_${crypto.createHash('sha1').update(parentId).digest('hex')}`, | ||
| metaSortKey: 0, |
There was a problem hiding this comment.
I'm just curious on what purpose this serves specifically? It's worth writing a comment here to explain why the metaSortKey for the base environment should be hard-coded to 0.
| Promise.all(newSubEnvironments.map((environment, idx) => this._updateEnvironment( | ||
| environment, | ||
| { metaSortKey: 1 }, | ||
| { metaSortKey: idx + 1 }, |
There was a problem hiding this comment.
I think setting this to just idx should do the job. Looking at where this regression was introduced, that was the existing behavior: https://github.com/Kong/insomnia/pull/2891/files?authenticity_token=NotWiXgjksFGynH9ySdJfzuPFfvny1ipT861Ia0PCdxxQciOP08il4GzvolDtfnjCbgSLI7MzW3fm3gge3EmMQ%3D%3D&file-filters%5B%5D=.tsx#diff-83bf0bed6b835cb203957ba0b8b615b662856919617cab840b6ced94a9d02708L337-R375. During the refactor, metaSortKey: i was mistakenly changed to metaSortKey: 1.
Is the + 1 strictly necessary?
|
Hi @develohpanda, I introduced that changes after looking at issue #3922. It is to keep the base environment metaSortKey always lower than the sub environment ones. |
Gotcha, thanks! I think we should remove the hard-coded value there and stick with what was there before, for the base environment. The The extra note in #3922 mentions the re-ordering issue, which is fixed by this PR, but that's not directly related to the base environment How does that sound? |
|
It sounds good to me, indeed I was not sure of the utility to have the metaSotKey of the base environment lower than others. So I'll remove the hard coded one and set back the others to index instead of index plus 1 |
This reverts commit 110982c. # Conflicts: # packages/insomnia-app/app/models/environment.ts # packages/insomnia-app/app/ui/components/modals/workspace-environments-edit-modal.tsx

Closes #3922
Closes #3822
Closes INS-954