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

Fix #3842: Remove second/millisecond conversion check for greeting timestamp #5536

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,14 @@ public static void setDrawableEndCompat(
}

private static String getTimeAgo(View view, long lastVisitedTimestamp) {
long timeStampMillis = ensureTimestampIsInMilliseconds(lastVisitedTimestamp);
long currentTimeMillis = getOppiaClock(view).getCurrentTimeMs();
AppLanguageResourceHandler resourceHandler = getResourceHandler(view);

if (timeStampMillis > currentTimeMillis || timeStampMillis <= 0) {
if (lastVisitedTimestamp > currentTimeMillis || lastVisitedTimestamp <= 0) {
return resourceHandler.getStringInLocale(R.string.last_logged_in_recently);
}

long timeDifferenceMillis = currentTimeMillis - timeStampMillis;
long timeDifferenceMillis = currentTimeMillis - lastVisitedTimestamp;

if (timeDifferenceMillis < (int) TimeUnit.MINUTES.toMillis(1)) {
return resourceHandler.getStringInLocale(R.string.just_now);
Expand Down Expand Up @@ -112,15 +111,6 @@ private static String getPluralString(
);
}

private static long ensureTimestampIsInMilliseconds(long lastVisitedTimestamp) {
// TODO(#3842): Investigate & remove this check.
if (lastVisitedTimestamp < 1000000000000L) {
// If timestamp is given in seconds, convert that to milliseconds.
return TimeUnit.SECONDS.toMillis(lastVisitedTimestamp);
}
return lastVisitedTimestamp;
}

private static AppLanguageResourceHandler getResourceHandler(View view) {
AppLanguageActivityInjectorProvider provider =
(AppLanguageActivityInjectorProvider) getAttachedActivity(view);
Expand Down
Loading