Improve long-loading logging code from the WebView. #4195
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Prompted by Greg's suggestions at #4180 (comment).
There are a few differences to call out. If they're problematic, I'll fix them right away, of course!
Since I was making a class anyway, and putting it in its own JS file, I didn't want to entangle that class with the DOM detail of whether the
message-loading
div was visible. Instead, I made it so you can call "start" and "stop" methods on the class. I think this will also be useful if we want to log based on other, unrelated states. The code added injs.js
is still much smaller than in the old way.Makes sense. I've pulled out the "scrubbing" logic into its own function, but the difference is: I don't use it in a
map
. As soon as the class instance becomes aware of the event, it scrubs it right away, before pushing it to the array.