✨ Post publish zone
This commit is contained in:
@ -1,7 +1,24 @@
|
||||
import 'package:get/get.dart';
|
||||
import 'package:solian/models/realm.dart';
|
||||
import 'package:solian/providers/auth.dart';
|
||||
|
||||
class RealmProvider extends GetxController {
|
||||
RxBool isLoading = false.obs;
|
||||
RxList<Realm> availableRealms = RxList.empty(growable: true);
|
||||
|
||||
Future<void> refreshAvailableRealms() async {
|
||||
final AuthProvider auth = Get.find();
|
||||
if (auth.isAuthorized.isFalse) throw Exception('unauthorized');
|
||||
|
||||
isLoading.value = true;
|
||||
final resp = await listAvailableRealm();
|
||||
isLoading.value = false;
|
||||
|
||||
availableRealms.value =
|
||||
resp.body.map((x) => Realm.fromJson(x)).toList().cast<Realm>();
|
||||
availableRealms.refresh();
|
||||
}
|
||||
|
||||
Future<Response> getRealm(String alias) async {
|
||||
final AuthProvider auth = Get.find();
|
||||
if (auth.isAuthorized.isFalse) throw Exception('unauthorized');
|
||||
|
Reference in New Issue
Block a user