♻️ Refactored auth system
This commit is contained in:
@ -28,7 +28,7 @@ class _ChatCallPrejoinPopupState extends State<ChatCallPrejoinPopup> {
|
||||
void performJoin() async {
|
||||
final AuthProvider auth = Get.find();
|
||||
final ChatCallProvider provider = Get.find();
|
||||
if (!await auth.isAuthorized) return;
|
||||
if (auth.isAuthorized.isFalse) return;
|
||||
|
||||
setState(() => _isBusy = true);
|
||||
|
||||
|
@ -31,7 +31,7 @@ class _ChatCallButtonState extends State<ChatCallButton> {
|
||||
|
||||
Future<void> makeCall() async {
|
||||
final AuthProvider auth = Get.find();
|
||||
if (!await auth.isAuthorized) return;
|
||||
if (auth.isAuthorized.isFalse) return;
|
||||
|
||||
final client = auth.configureClient('messaging');
|
||||
|
||||
@ -55,7 +55,7 @@ class _ChatCallButtonState extends State<ChatCallButton> {
|
||||
|
||||
Future<void> endsCall() async {
|
||||
final AuthProvider auth = Get.find();
|
||||
if (!await auth.isAuthorized) return;
|
||||
if (auth.isAuthorized.isFalse) return;
|
||||
|
||||
final client = auth.configureClient('messaging');
|
||||
|
||||
|
@ -35,15 +35,14 @@ class _ChatEventActionState extends State<ChatEventAction> {
|
||||
void checkAbleToModifyContent() async {
|
||||
if (!['messages.new'].contains(widget.item.type)) return;
|
||||
|
||||
final AuthProvider provider = Get.find();
|
||||
if (!await provider.isAuthorized) return;
|
||||
final AuthProvider auth = Get.find();
|
||||
if (auth.isAuthorized.isFalse) return;
|
||||
|
||||
setState(() => _isBusy = true);
|
||||
|
||||
final prof = await provider.getProfile();
|
||||
setState(() {
|
||||
_canModifyContent =
|
||||
prof.body?['id'] == widget.item.sender.account.externalId;
|
||||
_canModifyContent = auth.userProfile.value!['id'] ==
|
||||
widget.item.sender.account.externalId;
|
||||
_isBusy = false;
|
||||
});
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ class _ChatEventDeletionDialogState extends State<ChatEventDeletionDialog> {
|
||||
|
||||
void performAction() async {
|
||||
final AuthProvider auth = Get.find();
|
||||
if (!await auth.isAuthorized) return;
|
||||
if (auth.isAuthorized.isFalse) return;
|
||||
|
||||
final client = auth.configureClient('messaging');
|
||||
|
||||
|
@ -59,8 +59,8 @@ class _ChatMessageInputState extends State<ChatMessageInput> {
|
||||
_focusNode.requestFocus();
|
||||
|
||||
final AuthProvider auth = Get.find();
|
||||
final prof = await auth.getProfile();
|
||||
if (!await auth.isAuthorized) return;
|
||||
final prof = auth.userProfile.value!;
|
||||
if (auth.isAuthorized.isFalse) return;
|
||||
|
||||
final client = auth.configureClient('messaging');
|
||||
|
||||
@ -87,9 +87,9 @@ class _ChatMessageInputState extends State<ChatMessageInput> {
|
||||
id: 0,
|
||||
createdAt: DateTime.now(),
|
||||
updatedAt: DateTime.now(),
|
||||
account: Account.fromJson(prof.body),
|
||||
account: Account.fromJson(prof),
|
||||
channelId: widget.channel.id,
|
||||
accountId: prof.body['id'],
|
||||
accountId: prof['id'],
|
||||
notify: 0,
|
||||
);
|
||||
final message = Event(
|
||||
|
Reference in New Issue
Block a user