revolter / notepadtab.com

https://notepadtab.com/
GNU General Public License v3.0
128 stars 8 forks source link

Save text to url after focus change to prevent history spam #3

Closed AlexW00 closed 3 months ago

AlexW00 commented 3 months ago

Problem: When typing on notepadtab, my browser history gets polluted as every keystroke is a change in the url

Solution: Only update the url (1) once the focus has been lost or (2) once the browser tab has lost focus

revolter commented 3 months ago

The thing with this is that I did like the fact that it instantly saves the content, and that you can undo/redo each and every change. But I do acknowledge that realistically, it's a stupid thing to have, as no editor has undo/redo history for each individual character 😅

From what I know, the most popular solution for this is to use a debounce function (https://stackoverflow.com/a/62924046/865175).

Now, since the content saving is "free" (doesn't consume bandwidth or things like that), I would go for a shorter debounce delay. Although I would still need to try it a bit to get a feel for it. This StackOverflow answer (https://stackoverflow.com/a/44755058/865175) mentions 250ms (ignoring the backend part) 🤔

So, what do you think about using a rounded value of 300ms for this?