kits-ab / LogLady

Log file viewer
https://loglady.dev/
MIT License
8 stars 0 forks source link

#535 Bugfix for reduxStateBug and filtering #545

Closed Techlemariam closed 4 years ago

Techlemariam commented 4 years ago

In this pull request I've mainly tried to adress:

If we now have a string in filterInput-key, filteredLogs will be fetched in the first render instead of crashing. To battle too high memory consumption filteredLines gets fetched every 1,5 seconds in a running file (this can of course be changed to any other suitable delay). Along with the fetch comes previousFilteredLinesLength. The first time we fetch previousFilteredLinesLength is 0 and therefore we need to read the whole file. All the other times we only read the last 10 lines and filter those. For this I've brought back and reused readNLines which was removed during the scrollback feature implementation i think. Finally I've also added a dispatch function to clear the filtered logs when filterInput gets emptied.

In https://github.com/kits-ab/LogLady/issues/543 I explain how I noticed that lines going to mainScriptOffLoader were not being sent one by one when wanted because of previousLinesLength.current being assigned an undefined value and therefore the slice in newLines doesn't slice at all. When altering this and sending one by one I ran into the crash and thought that this maybe is a seperate issue. For that reason those lines are commented. However I think these comments can be uncommented, and my key in sendMessageToHiddenWindow could be deleted when this has been fixed.

See how this works for you!