Fix blocking, user modal tweaks
This commit is contained in:
parent
8eeed4e716
commit
cac9f46d98
6 changed files with 70 additions and 63 deletions
|
|
@ -78,7 +78,7 @@ SPEC CHECKSUMS:
|
|||
sentry_flutter: 7c3cb050dc23563a4ea5db438c83afdb460a2ae6
|
||||
shared_preferences_ios: aef470a42dc4675a1cdd50e3158b42e3d1232b32
|
||||
sqflite: 6d358c025f5b867b29ed92fc697fd34924e11904
|
||||
url_launcher_ios: 02f1989d4e14e998335b02b67a7590fa34f971af
|
||||
url_launcher_ios: 839c58cdb4279282219f5e248c3321761ff3c4de
|
||||
webview_flutter_wkwebview: 005fbd90c888a42c5690919a1527ecc6649e1162
|
||||
|
||||
PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ abstract class _UserStoreBase with Store {
|
|||
@readonly
|
||||
var _blockedUsers = ObservableList<UserBlockedTwitch>();
|
||||
|
||||
ReactionDisposer? disposeReaction;
|
||||
late final ReactionDisposer disposeReaction;
|
||||
|
||||
_UserStoreBase({required this.twitchApi});
|
||||
|
||||
|
|
@ -33,12 +33,14 @@ abstract class _UserStoreBase with Store {
|
|||
}
|
||||
|
||||
@action
|
||||
Future<void> block({required String targetId, required Map<String, String> headers}) async {
|
||||
Future<void> block({
|
||||
required String targetId,
|
||||
required String displayName,
|
||||
required Map<String, String> headers,
|
||||
}) async {
|
||||
final success = await twitchApi.blockUser(userId: targetId, headers: headers);
|
||||
// Add a slight delay between requests, otherwise the blocked list won't properly update.
|
||||
// Weird behavior, might be something to do with PUT request and time to create and update resource?
|
||||
await Future.delayed(const Duration(milliseconds: 300));
|
||||
if (success) await refreshBlockedUsers(headers: headers);
|
||||
|
||||
if (success) _blockedUsers.add(UserBlockedTwitch(targetId, displayName, displayName));
|
||||
}
|
||||
|
||||
@action
|
||||
|
|
@ -55,6 +57,6 @@ abstract class _UserStoreBase with Store {
|
|||
void dispose() {
|
||||
_details = null;
|
||||
_blockedUsers.clear();
|
||||
if (disposeReaction != null) disposeReaction!();
|
||||
disposeReaction();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,9 +54,11 @@ mixin _$UserStore on _UserStoreBase, Store {
|
|||
|
||||
@override
|
||||
Future<void> block(
|
||||
{required String targetId, required Map<String, String> headers}) {
|
||||
return _$blockAsyncAction
|
||||
.run(() => super.block(targetId: targetId, headers: headers));
|
||||
{required String targetId,
|
||||
required String displayName,
|
||||
required Map<String, String> headers}) {
|
||||
return _$blockAsyncAction.run(() => super
|
||||
.block(targetId: targetId, displayName: displayName, headers: headers));
|
||||
}
|
||||
|
||||
final _$unblockAsyncAction = AsyncAction('_UserStoreBase.unblock');
|
||||
|
|
|
|||
|
|
@ -2,9 +2,8 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter/services.dart';
|
||||
import 'package:frosty/screens/channel/chat/widgets/chat_message.dart';
|
||||
import 'package:frosty/screens/channel/stores/chat_store.dart';
|
||||
import 'package:frosty/widgets/block_button.dart';
|
||||
import 'package:frosty/widgets/block_report_modal.dart';
|
||||
import 'package:frosty/widgets/profile_picture.dart';
|
||||
import 'package:frosty/widgets/report_button.dart';
|
||||
import 'package:frosty/widgets/section_header.dart';
|
||||
|
||||
class ChatUserModal extends StatelessWidget {
|
||||
|
|
@ -37,22 +36,35 @@ class ChatUserModal extends StatelessWidget {
|
|||
leading: ProfilePicture(
|
||||
userLogin: username,
|
||||
),
|
||||
title: Text(
|
||||
displayName,
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
title: Row(
|
||||
children: [
|
||||
Text(
|
||||
displayName,
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
IconButton(
|
||||
tooltip: 'Block or Report User',
|
||||
onPressed: () => showModalBottomSheet(
|
||||
context: context,
|
||||
builder: (context) => BlockReportModal(
|
||||
authStore: chatStore.auth,
|
||||
name: displayName,
|
||||
userLogin: username,
|
||||
userId: userId,
|
||||
),
|
||||
),
|
||||
icon: const Icon(Icons.report),
|
||||
),
|
||||
],
|
||||
),
|
||||
trailing: chatStore.auth.isLoggedIn
|
||||
? Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ReportButton(userLogin: username),
|
||||
const SizedBox(width: 10.0),
|
||||
BlockButton(
|
||||
authStore: chatStore.auth,
|
||||
targetUser: username,
|
||||
targetUserId: userId,
|
||||
),
|
||||
],
|
||||
? OutlinedButton(
|
||||
onPressed: () {
|
||||
chatStore.textController.text = '@$username ';
|
||||
Navigator.pop(context);
|
||||
chatStore.textFieldFocusNode.requestFocus();
|
||||
},
|
||||
child: const Text('Reply'),
|
||||
)
|
||||
: null,
|
||||
),
|
||||
|
|
@ -89,21 +101,6 @@ class ChatUserModal extends StatelessWidget {
|
|||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 10.0,
|
||||
vertical: 5.0,
|
||||
),
|
||||
child: OutlinedButton(
|
||||
onPressed: () {
|
||||
chatStore.textController.text = '@$username ';
|
||||
Navigator.pop(context);
|
||||
chatStore.textFieldFocusNode.requestFocus();
|
||||
},
|
||||
child: const Text('Reply'),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -38,7 +38,11 @@ class BlockButton extends StatelessWidget {
|
|||
if (isBlocked) {
|
||||
authStore.user.unblock(targetId: targetUserId, headers: authStore.headersTwitch);
|
||||
} else {
|
||||
authStore.user.block(targetId: targetUserId, headers: authStore.headersTwitch);
|
||||
authStore.user.block(
|
||||
targetId: targetUserId,
|
||||
displayName: targetUser,
|
||||
headers: authStore.headersTwitch,
|
||||
);
|
||||
}
|
||||
Navigator.pop(context);
|
||||
},
|
||||
|
|
|
|||
|
|
@ -19,28 +19,30 @@ class BlockReportModal extends StatelessWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
||||
width: double.infinity,
|
||||
child: BlockButton(
|
||||
authStore: authStore,
|
||||
targetUser: name,
|
||||
targetUserId: userId,
|
||||
simple: false,
|
||||
return SafeArea(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
||||
width: double.infinity,
|
||||
child: BlockButton(
|
||||
authStore: authStore,
|
||||
targetUser: name,
|
||||
targetUserId: userId,
|
||||
simple: false,
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
||||
width: double.infinity,
|
||||
child: ReportButton(
|
||||
userLogin: userLogin,
|
||||
name: name,
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
||||
width: double.infinity,
|
||||
child: ReportButton(
|
||||
userLogin: userLogin,
|
||||
name: name,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue