Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add service worker for redirect user to prev page. #17

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

GabrieleMessina
Copy link

@GabrieleMessina GabrieleMessina commented Mar 31, 2023

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.

After event duplication we redirect the users to the previous page they were working on.
@belldragon7
Copy link

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!

@fabiosangregorio
Copy link
Owner

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? 🙏🏻

@GabrieleMessina
Copy link
Author

@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.

@fabiosangregorio
Copy link
Owner

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?

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.

View switched to Daily view after duplicating event (related to #4)
3 participants