togglePresence method

Future<void> togglePresence()

Updates the UserPresence to be a next one.

Implementation

Future<void> togglePresence() async {
  final int current = myUser.value?.presence.index ?? 0;

  UserPresence? next = UserPresence.values.elementAtOrNull(current + 1);
  if (next == UserPresence.artemisUnknown) {
    next = null;
  }

  await _myUserService.updateUserPresence(next ?? UserPresence.values.first);
}