From bdc85b435ca3d8937eeb366e5a0b875c29a415da Mon Sep 17 00:00:00 2001 From: XiangRongLin <41164160+XiangRongLin@users.noreply.github.com> Date: Sat, 30 Jan 2021 14:24:25 +0100 Subject: [PATCH] Add comments explaining the expiry field Co-authored-by: Tobias Groza --- .../main/java/org/schabi/newpipe/CheckForNewAppVersion.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/src/main/java/org/schabi/newpipe/CheckForNewAppVersion.java b/app/src/main/java/org/schabi/newpipe/CheckForNewAppVersion.java index 8bea85b19..63baef547 100644 --- a/app/src/main/java/org/schabi/newpipe/CheckForNewAppVersion.java +++ b/app/src/main/java/org/schabi/newpipe/CheckForNewAppVersion.java @@ -179,6 +179,8 @@ public final class CheckForNewAppVersion { 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); if (!manager.isExpired(expiry)) { return null; @@ -198,6 +200,8 @@ public final class CheckForNewAppVersion { .subscribe( response -> { try { + // Store a timestamp which needs to be exceeded, + // before a new request to the API is made. final long newExpiry = manager .coerceExpiry(response.getHeader("expires")); prefs.edit()