-
Notifications
You must be signed in to change notification settings - Fork 345
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
client: Switch from jQuery.ajax to fetch #1215
Conversation
I should be able to look into it by tomorrow. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cannot add a source, clicking does not show the form.
Thanks for checking it out. It should be fixed now. The add source button not functioning was caused by forgetting to call I also had to fix the |
With offline storage enabled, the client does not chain load items and stops after |
And then it seems to load the same entries over and over again. |
I I shut down the server, it keeps the ajax requests unfinished although the "Connection refused" should terminate them immediately. |
If I manually trigger |
when |
That seems to be true here but no luck. |
I would try the following but I'm stuck with a bundler error. --- a/assets/js/selfoss-db.js
+++ b/assets/js/selfoss-db.js
@@ -157,16 +157,19 @@ selfoss.dbOnline = {
selfoss.dbOffline.storeEntries(data.newItems)
.then(function() {
selfoss.dbOffline.storeLastUpdate(dataDate);
-
selfoss.dbOnline._syncDone();
-
- // fetch more if server has more
- if (selfoss.dbOffline.newerEntriesMissing) {
- selfoss.dbOnline.sync();
- }
});
}
+ if (selfoss.dbOffline.newerEntriesMissing
+ || selfoss.dbOffline.needsSync) {
+ // There are still new items to fetch
+ // or statuses to send
+ syncing.request.promise.then(function () {
+ selfoss.dbOffline.sendNewStatuses();
+ });
+ }
+
if ('itemUpdates' in data) {
// refresh entry statuses in db and dequeue queued
// statuses but do not calculate stats as they are taken |
Yeah, the bundlers are somewhat finicky in my experience. If I do That seems to work with a minor tweak: --- a/assets/js/selfoss-db.js
+++ b/assets/js/selfoss-db.js
@@ -159,14 +159,18 @@ selfoss.dbOnline = {
selfoss.dbOffline.storeLastUpdate(dataDate);
selfoss.dbOnline._syncDone();
-
- // fetch more if server has more
- if (selfoss.dbOffline.newerEntriesMissing) {
- selfoss.dbOnline.sync();
- }
});
}
+ if (selfoss.dbOffline.newerEntriesMissing
+ || selfoss.dbOffline.needsSync) {
+ // There are still new items to fetch
+ // or statuses to send
+ selfoss.dbOnline.syncing.request.promise.then(function () {
+ selfoss.dbOffline.sendNewStatuses();
+ });
+ }
+
if ('itemUpdates' in data) {
// refresh entry statuses in db and dequeue queued
// statuses but do not calculate stats as they are taken Thanks. |
But that patch triggers a sync loop you mention, the last page does not seem to get picked up:
|
The sync loop seems to be specific to sqlite and how we compare dates as simple strings. We should either use specific syntax for sqlite queries or ensure compared dates share the same timezone. For instance, the following seems to be fixing the problem. --- a/src/controllers/Items/Sync.php
+++ b/src/controllers/Items/Sync.php
@@ -56,11 +56,12 @@ class Sync {
}
$since = new \DateTime($params['since']);
+ $since->setTimeZone(new \DateTimeZone(date_default_timezone_get()));
$last_update = new \DateTime($this->itemsDao->lastUpdate());
$sync = [
- 'lastUpdate' => $last_update->format('Y-m-d H:i:s'),
+ 'lastUpdate' => $last_update->format(\DateTime::ATOM),
];
$sinceId = 0;
@@ -73,6 +74,7 @@ class Sync {
// only send 1 day worth of items
$notBefore = new \DateTime();
$notBefore->sub(new \DateInterval('P1D'));
+ $notBefore->->setTimeZone(new \DateTimeZone(date_default_timezone_get()));
}
$itemsHowMany = $f3->get('items_perpage'); |
This will bring us one step closer to removing jQuery. Unfortunately the native promises lack built-in support for aborting so we need to clumsily return AbortController alongside them.
So that `then` handlers only fire on success and we can attach `catch` handlers to it.
This will bring us one step closer to removing jQuery.
Unfortunately the native promises lack built-in support for aborting so we need to somewhat clumsily return
AbortController
alongside them.While at it, I also got rid of the jQuery Deferreds so the only remaining use of jQuery is the DOM manipulation. Hopefully, it will not remain for long.