google-calendar-quick-duplicate
google-calendar-quick-duplicate copied to clipboard
Add service worker for redirect user to prev page.
Closes #5
Description
After event duplication, we redirect the users to the previous page they were working on thanks to a service worker.
Removed currentDate
I've removed the currentDate
variable because
currentDate = document
.querySelector(MINI_CALENDAR_CURRENT_DAY_SELECTOR)
.getAttribute("data-date");
was returning the first date on the mini calendar instead of the current date.
Increased INTERVAL_DELAY
I had to increase the INTERVAL_DELAY
because I was getting the browser popup that warned about unsaved changes to the page.
Note
Let me know what do you think about it, and if I've respected coding style and naming convention.
Hey @GabrieleMessina , the whole code doesn't work now, could you please check it out? I have zero development skills, and I really want to use the tool, it would be really appreciated!
Hey @GabrieleMessina 👋🏻 Thank you for the contribution. This is really interesting as it would fix a long-standing bug of this extension! Sadly with the latest changes and the migration to Manifest V3 this does not work. Could you please try to merge conflicts and see if everything works as expected? 🙏🏻
@fabiosangregorio Hi! It's a pleasure to be helpful :)
I did some more tests on this bug and discovered that introducing the service worker was actually a bad idea because when you add (or duplicate) an event now Google shows a popover on the bottom of the page with an undo button. Because of this button, the redirect action I was doing with the service worker was getting blocked by the browser popup that warned about unsaved changes to the page.
So I reverted that, and I luckily discovered that just increasing the delay for the timer of the SaveEvent was fixing #5. I've then set the LONG_INTERVAL_DELAY
constant to 500, let me know if this amount is enough for you too, if not, try with 1000 which should be large enough.
I've also deleted document.body.classList.add("gcqd-active");
because the corresponding document.body.classList.remove("gcqd-active");
was in the function that handled the redirect to the previous page that now is not needed anymore and I've deleted that too.
I think, in case this is good to be merged on the main branch, that we should squash the commit seeing that the first commit was manually reverted and the second is just a merge.
Hi @GabrieleMessina! After a long hiatus I'm resurfacing this. Thanks for your input! In my tests it seems that bumping the delay is a bit unreliable. By any chance, did you find out any other way to address this?