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

Implemented continous check for new pictures in gallery.php #260

Merged
merged 3 commits into from Oct 30, 2020

Conversation

EccoB
Copy link
Contributor

@EccoB EccoB commented Oct 23, 2020

Problem:
When the gallery is used standalone, new pictures won't be visible till the user manually refreshes the page.

Solution:
Added jQuery script that asks the server weather the database changed, if so the page will be reloaded automatically.

Implementation details:

  • Updates are detected by checking weather the file-size of the db.txt changed. For this, the db.php got a new function that returns the file-size.
  • Gallery.php returns a json response, including the db-file size, if the variable 'status' is set via GET method.
  • The regular ajax requests for this are done in a separate js-File (default: every 5s).

@andi34
Copy link
Collaborator

andi34 commented Oct 24, 2020

Hey and thanks for your contribution!
I've rebased and adjusted your changes to work on my Photobooth fork too.

But there's one problem:
If I am on the standalone gallery watching pictures in full size and someone else is taking a picture on the Photobooth my page get refreshed which shouldn't happen while I am active on the gallery.

We need to detect touch and mouse events and only refresh the page if there's no activity.

@andreknieriem
Copy link
Owner

Hey @andi34 and @EccoB. Take a look at core.js for the timetolive variable. That is what you are looking for, to stop refresh on user action.

@andi34
Copy link
Collaborator

andi34 commented Oct 24, 2020

Thanks @andreknieriem ! Will take a look at in the evening 👍

- Added public function to check for pending Timeouts in core.js
- Added check using that function in gallery update check
@EccoB
Copy link
Contributor Author

EccoB commented Oct 25, 2020

Hey @andi34 and @andreknieriem
Thanks for all your comments.
I took a look at the user interaction problem and found it best to introduce a function in core.js that tells weather there is a user interaction pending based on the TimeOut function there. If so, we just skip any further checks and updates as the page nevertheless will be refreshed after the timetolive in core.js

@andi34
Copy link
Collaborator

andi34 commented Oct 27, 2020

Thanks @EccoB !
I've fixed the lint issues and made the DB check optional available, also adjustable interval via admin panel:
https://github.com/andi34/photobooth/pull/121/files

@andreknieriem andreknieriem merged commit b188012 into andreknieriem:master Oct 30, 2020
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.

None yet

3 participants