Skip to content

Bug: Duplicate branch logic in getLatestAlarm (Firestore provider) makes wantNextAlarm flag useless #880

@dorodb-web22

Description

@dorodb-web22

Description

While comparing the DB providers, I noticed the getLatestAlarm method in firestore_provider.dart has identical code in both its if (wantNextAlarm) and else branches .. both add + 1 to the current minute.

Because both branches do the exact same thing, passing wantNextAlarm: false yields the same behavior as wantNextAlarm: true.

Tho the isar_provider.dart version of this same method implements this correctly , its else branch uses the current minute without the
+ 1 offset

Affected Code

lib/app/data/providers/firestore_provider.dart, line 197:

} else {
  nowInMinutes = Utils.timeOfDayToInt(TimeOfDay(
    hour: TimeOfDay.now().hour,
    minute: TimeOfDay.now().minute + 1, // ❌ should not have + 1
  ));
}

Fix

I can just remove the + 1 from the else branch so it matches the expected behavior (and the Isar provider's behavior).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions