mirror of
https://github.com/nostrlabs-io/zap-stream-flutter.git
synced 2025-06-16 11:58:50 +00:00
refactor: performance
This commit is contained in:
@ -6,8 +6,17 @@ import 'package:zap_stream_flutter/widgets/button.dart';
|
||||
|
||||
class MuteButton extends StatelessWidget {
|
||||
final String pubkey;
|
||||
final void Function()? onTap;
|
||||
final void Function()? onMute;
|
||||
final void Function()? onUnmute;
|
||||
|
||||
const MuteButton({super.key, required this.pubkey});
|
||||
const MuteButton({
|
||||
super.key,
|
||||
required this.pubkey,
|
||||
this.onTap,
|
||||
this.onMute,
|
||||
this.onUnmute,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -32,6 +41,9 @@ class MuteButton extends StatelessWidget {
|
||||
padding: EdgeInsets.symmetric(vertical: 4, horizontal: 12),
|
||||
decoration: BoxDecoration(color: WARNING, borderRadius: DEFAULT_BR),
|
||||
onTap: () async {
|
||||
if (onTap != null) {
|
||||
onTap!();
|
||||
}
|
||||
if (isMuted) {
|
||||
await ndk.lists.broadcastRemoveNip51ListElement(
|
||||
Nip51List.kMute,
|
||||
@ -39,6 +51,9 @@ class MuteButton extends StatelessWidget {
|
||||
pubkey,
|
||||
null,
|
||||
);
|
||||
if (onUnmute != null) {
|
||||
onUnmute!();
|
||||
}
|
||||
} else {
|
||||
await ndk.lists.broadcastAddNip51ListElement(
|
||||
Nip51List.kMute,
|
||||
@ -46,9 +61,10 @@ class MuteButton extends StatelessWidget {
|
||||
pubkey,
|
||||
null,
|
||||
);
|
||||
}
|
||||
if (ctx.mounted) {
|
||||
Navigator.pop(ctx);
|
||||
|
||||
if (onMute != null) {
|
||||
onMute!();
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
|
Reference in New Issue
Block a user