refactor: performance

This commit is contained in:
2025-05-13 16:09:04 +01:00
parent 9e5108930a
commit e3dc985b0d
13 changed files with 325 additions and 259 deletions

View File

@ -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!();
}
}
},
);