qbittorrent / qBittorrent

qBittorrent BitTorrent client
https://www.qbittorrent.org
Other
28.48k stars 3.99k forks source link

WebUI: Fix wrong log levels #21812

Closed PatrikElfstrom closed 6 days ago

PatrikElfstrom commented 1 week ago

Fixes bug where the first time visiting Execution Log view all log levels are deselected but log items with all levels are still displayed. This requires you to select a log level and then deselect it to hide that log level.

https://github.com/user-attachments/assets/d817e28c-9d86-4017-8ee8-4962918e5579

Chocobo1 commented 1 week ago

I took a look and I believe the following is the proper fix:

Change https://github.com/qbittorrent/qBittorrent/blob/9dcb477ce08c4f31a1086dfd1f7a4381c8550cd1/src/webui/www/private/views/log.html#L191-L196 to:

for (const option of $("logLevelSelect").options)  // replaced some methods to migrate away from mootools
    option.setAttribute("selected", selectedLogLevels.includes(option.value));
PatrikElfstrom commented 1 week ago

I took a look and I believe the following is the proper fix:

Change

https://github.com/qbittorrent/qBittorrent/blob/9dcb477ce08c4f31a1086dfd1f7a4381c8550cd1/src/webui/www/private/views/log.html#L191-L196

to:

for (const option of $("logLevelSelect").options)  // replaced some methods to migrate away from mootools
    option.setAttribute("selected", selectedLogLevels.includes(option.value));

Yeah, that is probably a more correct fix. But come to think of it I think we could even just remove that loop entirely if we use the selected attributes.

Chocobo1 commented 1 week ago

But come to think of it I think we could even just remove that loop entirely if we use the selected attributes.

I'm not sure about that, here it load/restore the preference: https://github.com/qbittorrent/qBittorrent/blob/9dcb477ce08c4f31a1086dfd1f7a4381c8550cd1/src/webui/www/private/views/log.html#L188

PatrikElfstrom commented 1 week ago

But come to think of it I think we could even just remove that loop entirely if we use the selected attributes.

I'm not sure about that, here it load/restore the preference:

https://github.com/qbittorrent/qBittorrent/blob/9dcb477ce08c4f31a1086dfd1f7a4381c8550cd1/src/webui/www/private/views/log.html#L188

Yeah you're right. I missed that. I've updated the commit with your recommended change.

Chocobo1 commented 6 days ago

@PatrikElfstrom Thank you!