1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-11-22 21:09:21 +00:00
comunicmobile/lib/forez/helpers/forez_group_helper.dart

34 lines
970 B
Dart
Raw Normal View History

2021-04-24 08:14:56 +00:00
import 'package:comunic/helpers/groups_helper.dart';
2021-04-23 17:32:34 +00:00
import 'package:comunic/helpers/preferences_helper.dart';
2021-04-24 08:14:56 +00:00
import 'package:comunic/models/advanced_group_info.dart';
2021-04-23 17:32:34 +00:00
/// Forez group helper
///
/// Contains the ID of the currently selected Forez group
///
/// @author Pierre Hubert
AdvancedGroupInfo? _forezGroup;
2021-04-24 08:14:56 +00:00
2021-04-23 17:32:34 +00:00
class ForezGroupHelper {
static Future<void> setId(int groupID) async {
2022-03-10 19:36:55 +00:00
(await PreferencesHelper.getInstance())
2021-04-23 17:32:34 +00:00
.setInt(PreferencesKeyList.FOREZ_GROUP, groupID);
}
static Future<int?> getId() async {
2022-03-10 19:36:55 +00:00
return (await PreferencesHelper.getInstance())
2021-04-23 17:32:34 +00:00
.getInt(PreferencesKeyList.FOREZ_GROUP);
}
2021-04-24 08:14:56 +00:00
static Future<void> refreshInfo() async {
final res = await GroupsHelper().getAdvancedInfo(await getId());
assert(res.status == GetAdvancedInfoStatus.SUCCESS);
_forezGroup = res.info;
}
static AdvancedGroupInfo? getGroup() => _forezGroup;
2021-04-23 17:32:34 +00:00
}
2021-04-24 08:14:56 +00:00
AdvancedGroupInfo? get forezGroup => ForezGroupHelper.getGroup();