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

Check-in dialog shows incorrect number #1906

Open
nbearman opened this issue Jan 12, 2023 · 0 comments
Open

Check-in dialog shows incorrect number #1906

nbearman opened this issue Jan 12, 2023 · 0 comments

Comments

@nbearman
Copy link

Describe the bug
When opening the app for the first time each day, a dialog pops up showing the number of check-ins required before the next login incentive prize. This number is not calculated correctly; instead, it shows the number of total check-ins required for the next incentive.

e.g.: when checking in on the 15th day, the dialog says:

Next prize in 18 Check-ins

but it should say

Next prize in 3 Check-ins

To Reproduce
Steps to reproduce the behavior:

  1. Open the app for the first time in a day
  2. Note the daily check-in dialog
  3. The number displayed ("Next prize in X Check-ins") shows the total number of check-ins required for the next incentive (not the number remaining).

(Android Version 4.0.5 (4760))

Expected behavior

The number shown in the check-in dialog should be the number of check-ins remaining until the next incentive.

Screenshots

Screenshot shows "18 Check-ins" remaining, when the next reward is unlocked at 18 total check-ins. It should show "3 Check-ins".

habitica_bug_cropped

Smartphone (please complete the following information):

  • OS: Android 13
  • App Version: Version 4.0.5 (4760)

Additional context

The offending line appears to be here (ShowNotificationInteractor.kt)

val nextUnlockText = activity.getString(R.string.nextPrizeUnlocks, notificationData?.nextRewardAt)

I think the nextRewardAt contained in the notification comes from the server, and is calculated in loginIncentives.js. This field, stored on each incentive, represents the number of total check-ins required to reach the next incentive (e.g. the incentive earned at 450 check-ins holds 475 as it's nextRewardAt, since the next incentive in order requires 475 total check-ins).

This number is not relative to the player's current number of check-ins; it does not change. In order to show the number of additional check-ins the player needs before reaching the next incentive, the player's current total check-ins needs to be subtracted from the nextRewardAt (e.g. 475 - 468 = 7 == check-ins to next prize).

This calculation is done correctly in both the web app and the iOS app before showing the message:

Web app: (https://github.com/HabitRPG/habitica/blob/develop/website/client/src/components/achievements/login-incentives.vue#L85)

<h3>
    {{ $t('nextRewardUnlocksIn', {
        numberOfCheckinsLeft: data.nextRewardAt - user.loginIncentives}) }}
</h3>

iOS: (https://github.com/HabitRPG/habitica-ios/blob/develop/HabitRPG/Utilities/NotificationManager.swift#L178)

let nextRewardIn = nextRewardAt - loginIncentives
    mutableString.append(NSAttributedString(string: L10n.nextPrizeInXCheckins(nextRewardIn), attributes: [

It looks like the Android app needs to make this calculation as well, something like:

val nextUnlockText = activity.getString(R.string.nextPrizeUnlocks, notificationData.nextRewardAt - user.loginIncentives)

This should be straightforward, but I can't tell if the user is readily available in this context; it looks like it might not be.

An alternative might be to make the calculation on the server side and include it in the notification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant