♻️ Refactored auth system

This commit is contained in:
2024-07-25 01:18:47 +08:00
parent ef58430060
commit 6d92a16a62
38 changed files with 444 additions and 523 deletions

View File

@ -25,7 +25,7 @@ class _ChannelDeletionDialogState extends State<ChannelDeletionDialog> {
Future<void> deleteChannel() async {
final AuthProvider auth = Get.find();
if (!await auth.isAuthorized) return;
if (auth.isAuthorized.isFalse) return;
setState(() => _isBusy = true);
@ -44,7 +44,7 @@ class _ChannelDeletionDialogState extends State<ChannelDeletionDialog> {
Future<void> leaveChannel() async {
final AuthProvider auth = Get.find();
if (!await auth.isAuthorized) return;
if (auth.isAuthorized.isFalse) return;
setState(() => _isBusy = true);

View File

@ -31,10 +31,9 @@ class _ChannelMemberListPopupState extends State<ChannelMemberListPopup> {
void getProfile() async {
final AuthProvider auth = Get.find();
if (!await auth.isAuthorized) return;
if (auth.isAuthorized.isFalse) return;
final prof = await auth.getProfile();
setState(() => _accountId = prof.body['id']);
setState(() => _accountId = auth.userProfile.value!['id']);
}
void getMembers() async {
@ -72,7 +71,7 @@ class _ChannelMemberListPopupState extends State<ChannelMemberListPopup> {
void addMember(String username) async {
final AuthProvider auth = Get.find();
if (!await auth.isAuthorized) return;
if (auth.isAuthorized.isFalse) return;
setState(() => _isBusy = true);
@ -93,7 +92,7 @@ class _ChannelMemberListPopupState extends State<ChannelMemberListPopup> {
void removeMember(ChannelMember item) async {
final AuthProvider auth = Get.find();
if (!await auth.isAuthorized) return;
if (auth.isAuthorized.isFalse) return;
setState(() => _isBusy = true);