Skip to content

Added caching to getBrowserName()#113

Merged
ErikBjare merged 3 commits intoActivityWatch:masterfrom
qz4:withCaching
Aug 2, 2023
Merged

Added caching to getBrowserName()#113
ErikBjare merged 3 commits intoActivityWatch:masterfrom
qz4:withCaching

Conversation

@qz4
Copy link
Copy Markdown
Contributor

@qz4 qz4 commented Jun 28, 2023

This time (my second PR on this optimizing getBrowserName, previous: #89) I went with a caching approach instead of writing a lightweight alternative to UAParser.

UAParser is still a fairly heavy library, however we will only be using it for the first time we call getBrowserName().

I have only tested in Firefox where it seems to work perfectly fine.

A few functions have been turned asynchronous, however I have not spotted any places where that could be an issue, and awaits have been added where needed.

@ErikBjare
Copy link
Copy Markdown
Member

I rewrote your implementation to store the information in the client object instead of localStorage. Shorter and no async needed.

Review & testing appreciated, then ready for merge :)

@qz4
Copy link
Copy Markdown
Contributor Author

qz4 commented Jul 22, 2023

I removed an async and an await that is not needed anymore.

From a quick test of my commit, it seems that aw-watcher-web is working as expected.
getBrowserName() is only called once, and all my activity is being shown in the AW testing mode timeline.

@ErikBjare ErikBjare merged commit 0b289c4 into ActivityWatch:master Aug 2, 2023
@ErikBjare
Copy link
Copy Markdown
Member

Very nice, thanks!

Not sure when I'll get around to making a new release for the addon stores, hopefully in not too long.

powellnorma pushed a commit to powellnorma/aw-watcher-web that referenced this pull request Oct 3, 2024
* Added caching to getBrowserName()

* fix: improved caching of browserName

* Removed unused async and await

---------

Co-authored-by: Erik Bjäreholt <erik@bjareho.lt>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants