Skip to content

Conversation

ItaloBC
Copy link
Contributor

@ItaloBC ItaloBC commented Dec 9, 2017

Caffeine now will reload the page if the last drip misses, something that happen when the device (laptops, smartphones) go to sleep, halting the browser activity - in this case, pausing Caffeine Drip interval.

This is accomplished in this way;

  1. Save when the Last Drip was sent and successfully acknowledged (server code 204).
  2. Check every 2 seconds if the Last Drip sent is old/missed by 10 seconds.
  3. If the latter is true, reload the page for a new csrf_token.

This allows to evade TokenMismatchException, that happens when the client requests with an invalid (old) csrf_token after long time of network inactivity.

If the page gets reloaded when there is no network connectivity, the browser is intelligent enough (at least on Chrome) to retrieve the page entirely once the connection reestablishes.

The Check Interval and the old/miss Threshold are configurable under the same config array, so it's not necessary to match it up to the application session lifetime.

Happy Holidays.

@mikebronner
Copy link
Owner

@ItaloBC Thanks for creating this PR! :) I will take a look at it and update the failing unit tests.

Repository owner deleted a comment from coveralls Dec 9, 2017
Repository owner deleted a comment from coveralls Dec 9, 2017
Repository owner deleted a comment from coveralls Dec 9, 2017
@mikebronner mikebronner self-assigned this Dec 9, 2017
@mikebronner mikebronner merged commit 39d5b7a into mikebronner:master Dec 9, 2017
mikebronner added a commit that referenced this pull request Dec 9, 2017
commit 39d5b7a
Merge: 986d780 fe3c184
Author: Mike Bronner <mike@genealabs.com>
Date:   Sat Dec 9 09:19:17 2017 -0800

    Merge pull request #71 from ItaloBC/ItaloBC-ReloadOnOldDrip

    Reload the Page if we miss the Drip

commit fe3c184
Author: ItaloBC <ItaloBC@users.noreply.github.com>
Date:   Sat Dec 9 12:35:33 2017 -0300

    Fixed the calc between old/missed drips

    Now it works.

commit 37426aa
Author: ItaloBC <ItaloBC@users.noreply.github.com>
Date:   Sat Dec 9 12:18:26 2017 -0300

    Wtf was I doing? threshold is fine by itself

commit 32fd4f6
Author: ItaloBC <ItaloBC@users.noreply.github.com>
Date:   Sat Dec 9 12:15:03 2017 -0300

    Forgot to add the `interval` to the `threshold`

commit bdba85f
Author: ItaloBC <ItaloBC@users.noreply.github.com>
Date:   Sat Dec 9 12:11:55 2017 -0300

    Changed variable to something more criptic

commit bb8eac7
Author: ItaloBC <ItaloBC@users.noreply.github.com>
Date:   Sat Dec 9 12:09:18 2017 -0300

    Fixed the setInterval for dripping

commit 94aeedf
Author: ItaloBC <ItaloBC@users.noreply.github.com>
Date:   Sat Dec 9 11:48:15 2017 -0300

    Threshold default now matches the config default

commit 154d9b9
Author: ItaloBC <ItaloBC@users.noreply.github.com>
Date:   Sat Dec 9 11:47:40 2017 -0300

    Changed the old drip to a sensible 10 seconds

commit caf1ad6
Author: ItaloBC <ItaloBC@users.noreply.github.com>
Date:   Sat Dec 9 11:40:43 2017 -0300

    Corrected functions to get the new settings.

    Also, changed the JavaScript to check the old drip, send the drip and check oldness at different intervals.

commit a9d4fd6
Author: ItaloBC <ItaloBC@users.noreply.github.com>
Date:   Sat Dec 9 11:36:34 2017 -0300

    Added two new settings for checking old drips

commit e624a51
Author: ItaloBC <ItaloBC@users.noreply.github.com>
Date:   Sat Dec 9 11:29:52 2017 -0300

    Update Dripper.php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants