-
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
Sync client from server using last update timestamp #846
Merged
Merged
Changes from 9 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
7e1e575
ensure entry date can be used by the client side js code
niol 3946683
use db lastUpdatetime to prevent uneeded computation of stats
niol 6a2667b
get updated item status from server and show them
niol 9c781c0
show stream more on unread view when there are new items on the server
niol 20f740b
fix reverting ui changes after starr xhr error
niol e9e69f8
fix stream-more xhr sent upon each scroll event when auto_stream_more=1
niol 3071660
improve nav-refresh button
niol 6235fcb
use \DateTime::ATOM rather than \DateTime::ISO8601 for better compliance
niol 31ca9e6
restore ECMAScript 5 compatibility (and IE compatibility)
niol 1b820f7
fix typo in restore IE compatibility patch
niol 21de209
fix typo preventing syncing starred status to the ui
niol a20e83b
remove js superfluous parentheses
niol 85196bd
ensure proper types in JSON for /items/sync regardless of the db backend
niol 7fea6c9
ensureRowTypes: prevent copying of $rows in memory for no reason
niol 795fccc
ensureRowTypes(): do not use PHP references
niol File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -478,4 +478,32 @@ public function stats() { | |
FROM '.\F3::get('db_prefix').'items;'); | ||
return $res[0]; | ||
} | ||
|
||
|
||
/** | ||
* returns the datetime of the last item update or user action in db | ||
* | ||
* @return timestamp | ||
*/ | ||
public function lastUpdate() { | ||
$res = \F3::get('db')->exec('SELECT | ||
MAX(updatetime) AS last_update_time | ||
FROM '.\F3::get('db_prefix').'items;'); | ||
return $res[0]['last_update_time']; | ||
} | ||
|
||
|
||
/** | ||
* returns the statuses of items last update | ||
* | ||
* @param date since to return item statuses | ||
* @return array of unread, starred, etc. status of specified items | ||
*/ | ||
public function statuses($since) { | ||
$res = \F3::get('db')->exec('SELECT id, unread, starred | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it possible to use proper booleans? Otherwise the sync will mark all changed items as starred and unread since unlike in PHP $ php -r 'var_dump(!!"0");'
Command line code:1:
bool(false)
$ node -e 'console.log(!!"0")'
true
|
||
FROM '.\F3::get('db_prefix').'items | ||
WHERE '.\F3::get('db_prefix').'items.updatetime > :since;', | ||
array(':since' => array($since, \PDO::PARAM_STR))); | ||
return $res; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Now this is almost like GraphQL. Would not it be better to create a GraphQL endpoint? It could also save a lot requests during initial connection.