♻️ Refactored auth system
This commit is contained in:
@ -26,9 +26,8 @@ class _RealmDetailScreenState extends State<RealmDetailScreen> {
|
||||
|
||||
void checkOwner() async {
|
||||
final AuthProvider auth = Get.find();
|
||||
final prof = await auth.getProfile();
|
||||
setState(() {
|
||||
_isOwned = prof.body['id'] == widget.realm.accountId;
|
||||
_isOwned = auth.userProfile.value!['id'] == widget.realm.accountId;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ class _RealmOrganizeScreenState extends State<RealmOrganizeScreen> {
|
||||
|
||||
void applyRealm() async {
|
||||
final AuthProvider auth = Get.find();
|
||||
if (!await auth.isAuthorized) return;
|
||||
if (auth.isAuthorized.isFalse) return;
|
||||
|
||||
if (_aliasController.value.text.isEmpty) randomizeAlias();
|
||||
|
||||
|
@ -244,44 +244,38 @@ class RealmChannelListWidget extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final AuthProvider auth = Get.find();
|
||||
|
||||
return FutureBuilder(
|
||||
future: auth.getProfile(),
|
||||
builder: (context, snapshot) {
|
||||
return RefreshIndicator(
|
||||
onRefresh: onRefresh,
|
||||
child: Column(
|
||||
children: [
|
||||
ListTile(
|
||||
leading: const Icon(Icons.add_box),
|
||||
contentPadding: const EdgeInsets.only(left: 32, right: 8),
|
||||
tileColor: Theme.of(context).colorScheme.surfaceContainer,
|
||||
title: Text('channelNew'.tr),
|
||||
subtitle: Text(
|
||||
'channelNewInRealmHint'
|
||||
.trParams({'realm': '#${realm.alias}'}),
|
||||
),
|
||||
onTap: () {
|
||||
AppRouter.instance
|
||||
.pushNamed(
|
||||
'channelOrganizing',
|
||||
extra: ChannelOrganizeArguments(realm: realm),
|
||||
)
|
||||
.then((value) {
|
||||
if (value != null) onRefresh();
|
||||
});
|
||||
},
|
||||
),
|
||||
Expanded(
|
||||
child: ChannelListWidget(
|
||||
channels: channels,
|
||||
selfId: snapshot.data?.body['id'] ?? 0,
|
||||
noCategory: true,
|
||||
),
|
||||
return RefreshIndicator(
|
||||
onRefresh: onRefresh,
|
||||
child: Column(
|
||||
children: [
|
||||
ListTile(
|
||||
leading: const Icon(Icons.add_box),
|
||||
contentPadding: const EdgeInsets.only(left: 32, right: 8),
|
||||
tileColor: Theme.of(context).colorScheme.surfaceContainer,
|
||||
title: Text('channelNew'.tr),
|
||||
subtitle: Text(
|
||||
'channelNewInRealmHint'.trParams({'realm': '#${realm.alias}'}),
|
||||
),
|
||||
onTap: () {
|
||||
AppRouter.instance
|
||||
.pushNamed(
|
||||
'channelOrganizing',
|
||||
extra: ChannelOrganizeArguments(realm: realm),
|
||||
)
|
||||
],
|
||||
.then((value) {
|
||||
if (value != null) onRefresh();
|
||||
});
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
Expanded(
|
||||
child: ChannelListWidget(
|
||||
channels: channels,
|
||||
selfId: auth.userProfile.value!['id'],
|
||||
noCategory: true,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user