[lib-jitsi-meet] Wrong use of splice?


is this code correct ? https://github.com/jitsi/lib-jitsi-meet/blob/301e3a22dd76341b15d3846ab539e713d8e7569b/modules/RTC/RTCUtils.js#L849

I was browsing the code related to the devices list initialization, and there is part of it that I don’t understand.
For example, that comment https://github.com/jitsi/jitsi-meet/blob/898eca86d5c1ed4bfb7de93d4257acb9dff08070/conference.js#L753 is intriguing to me.
It looks like we need to do a double initialization to get things working.

I am working on a modified version on Jisti Meet. During the call, I need to change the config, which then retriggers a library initialization. It was working correctly until I updated to stable/jitsi-meet_5142 . Now when I reinitialized my library, the device list stores in redux is an empty array, and is never back to the correct value.

After some digging, I am thinking that the use of the splice method here is wrong, and that the original author might mean splice. We can find the use of slice here https://github.com/jitsi/lib-jitsi-meet/blob/301e3a22dd76341b15d3846ab539e713d8e7569b/modules/RTC/RTCUtils.js#L661

Another reason of the potential issue, is that in the onMediaDevicesListChanged https://github.com/jitsi/lib-jitsi-meet/blob/301e3a22dd76341b15d3846ab539e713d8e7569b/modules/RTC/RTCUtils.js#L669 we do a copy of the available device, but the one that we forward, is the original Array, which will be emptied by the use of splice.

I am asking here because I am not that familiar with the library code and so might be missing something.

So, what do you think ?

edit: the change of behavior might be related to https://github.com/jitsi/lib-jitsi-meet/pull/1361 , but I think the previous statements are correct

For the record, I opened a PR related to that issue https://github.com/jitsi/lib-jitsi-meet/pull/1411