1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-07-01 01:23:19 +00:00

Add comments explaining the expiry field

Co-authored-by: Tobias Groza <TobiGr@users.noreply.github.com>
This commit is contained in:
XiangRongLin 2021-01-30 14:24:25 +01:00 committed by GitHub
parent e98838ad7e
commit bdc85b435c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -179,6 +179,8 @@ public final class CheckForNewAppVersion {
return null; return null;
} }
// Check if the last request has happened a certain time ago
// to reduce the number of API requests.
final long expiry = prefs.getLong(app.getString(R.string.update_expiry_key), 0); final long expiry = prefs.getLong(app.getString(R.string.update_expiry_key), 0);
if (!manager.isExpired(expiry)) { if (!manager.isExpired(expiry)) {
return null; return null;
@ -198,6 +200,8 @@ public final class CheckForNewAppVersion {
.subscribe( .subscribe(
response -> { response -> {
try { try {
// Store a timestamp which needs to be exceeded,
// before a new request to the API is made.
final long newExpiry = manager final long newExpiry = manager
.coerceExpiry(response.getHeader("expires")); .coerceExpiry(response.getHeader("expires"));
prefs.edit() prefs.edit()