Leaving party always asks if you want to leave challenges even if none exist - CSCI-462-01-2021/Fork-Bomb GitHub Wiki

Leaving party always asks if you want to leave challenges even if none exist - #1442 (habitica-android)

Status:

  • Chloe requested to be assigned the topic (2.8)
  • Isabel asked clarifying question on issue and bumped it to see if we get approval (2.23)

Notes:

  • Current Pop-Up

  • Goal

  • Part 1: Does not need to ask user if they want to leave challenges if there are none.

    • Guild
    • Party
  • Part 2: If user opts to leave all challenges, remove challenges from task list.

  • Currently both buttons have the same functionality.

  • File Notes:

    • Habitica/src/main/java/com/habitrpg/android/habitica/ui/fragments/social/guilds/GuildDetailFragment.kt (line 133 - fun leaveGuild)
    • Habitica/src/main/java/com/habitrpg/android/habitica/ui/fragments/social/party/PartyDetailFragment.kt (line 333 - fun leaveParty)
    • Habitica/src/main/java/com/habitrpg/android/habitica/ui/viewmodels/GroupViewModel.kt (line 166 - fun leaveGroup)
    • Habitica/src/main/java/com/habitrpg/android/habitica/models/social/Group.kt (var challengeCount)
    • Habitica/src/main/java/com/habitrpg/android/habitica/data/ChallengeRepository.kt
    • Habitica/src/main/java/com/habitrpg/android/habitica/models/LeaveChallengeBody.kt
    • Habitica/src/main/java/com/habitrpg/android/habitica/data/ApiClient.kt
    • Habitica/src/main/java/com/habitrpg/android/habitica/api/ApiService.kt
  • API:

Changes:

Roadblocks:

  • API documentation contains a get challenges based on group, however, it does not seem to be implemented in the android code
    • Plan for asking if user wants to leave challenge: check first if the group even has challenges, then check to see if user is participating in any of these challenges
    • API for challenges by user is implemented
      • In this case, can just check to see if user is participating in any challenges "owned" by the group
  • Incorrect code flow was causing an if/else statement to always go to if
    • fixed with a delay which doesn't seem like the best solution, but it is one they also use so it seems accceptable
  • 2 failed tests involving party
    • Brainstorming:
      • Should you technically be "in" challenge if not in party?
      • Leaving challenges/ deleting tasks should likely be done in GroupViewModel in leaveGroup (line 167)
      • getGroupChallenges should maybe be moved to a different class and possibly renamed

Tests:

Party Tests:

  • User is part of no group challenges; leads to pop up confirming they want to leave, pass
  • User is part of group challenge, but not the one they're trying to leave; leads to pop up confirming they want to leave; pass
  • User is part of group challenge, of they group they're trying to leave; leads to pop up warning of group challenges; pass
    • User chooses to keep challenges; challenge remains and tasks remain; fail
      • Tasks remain, but challenge does not (for party at least)
    • User chooses to leave challenges and delete tasks; challenge is removed from user repository and tasks are removed; fail
      • Challenge is removed, but tasks remain

Feedback:


Results: