mirror of
https://github.com/nostrlabs-io/zap-stream-flutter.git
synced 2025-06-18 20:57:14 +00:00
fix: chat scroll (NDK bugs)
This commit is contained in:
@ -77,7 +77,7 @@ class _RxFilter<T> extends State<RxFilter<T>> {
|
|||||||
if ([0, 3].contains(ev.kind) || (ev.kind >= 10000 && ev.kind < 20000)) {
|
if ([0, 3].contains(ev.kind) || (ev.kind >= 10000 && ev.kind < 20000)) {
|
||||||
return "${ev.kind}:${ev.pubKey}";
|
return "${ev.kind}:${ev.pubKey}";
|
||||||
} else if (ev.kind >= 30000 && ev.kind < 40000) {
|
} else if (ev.kind >= 30000 && ev.kind < 40000) {
|
||||||
return "${ev.kind}:${ev.pubKey}:${ev.getDtag()!}";
|
return "${ev.kind}:${ev.pubKey}:${ev.getDtag()}";
|
||||||
} else {
|
} else {
|
||||||
return ev.id;
|
return ev.id;
|
||||||
}
|
}
|
||||||
|
@ -130,6 +130,9 @@ StreamInfo extractStreamInfo(Nip01Event ev) {
|
|||||||
matchTag(t, 'service', (v) => ret.service = v);
|
matchTag(t, 'service', (v) => ret.service = v);
|
||||||
if (t[0] == "relays") {
|
if (t[0] == "relays") {
|
||||||
ret.relays = t.slice(1);
|
ret.relays = t.slice(1);
|
||||||
|
if (ret.relays!.isEmpty) {
|
||||||
|
ret.relays = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -235,7 +238,7 @@ String formatSats(int n) {
|
|||||||
if (n >= 1000000) {
|
if (n >= 1000000) {
|
||||||
return "${fmt.format(n / 1000000)}M";
|
return "${fmt.format(n / 1000000)}M";
|
||||||
} else if (n >= 1500) {
|
} else if (n >= 1500) {
|
||||||
return "${fmt.format(n / 1000)}k";
|
return "${fmt.format(n / 1000)}K";
|
||||||
} else {
|
} else {
|
||||||
return fmt.format(n);
|
return fmt.format(n);
|
||||||
}
|
}
|
||||||
|
@ -24,11 +24,8 @@ class ChatWidget extends StatelessWidget {
|
|||||||
|
|
||||||
var filters = [
|
var filters = [
|
||||||
Filter(kinds: [1311, 9735], limit: 200, aTags: [stream.aTag]),
|
Filter(kinds: [1311, 9735], limit: 200, aTags: [stream.aTag]),
|
||||||
Filter(kinds: [Nip51List.kMute], authors: muteLists),
|
//Filter(kinds: [Nip51List.kMute], authors: muteLists), // bugged
|
||||||
];
|
];
|
||||||
if (stream.info.goal != null) {
|
|
||||||
filters.add(Filter(kinds: [9041], ids: [stream.info.goal!]));
|
|
||||||
}
|
|
||||||
return RxFilter<Nip01Event>(
|
return RxFilter<Nip01Event>(
|
||||||
relays: stream.info.relays,
|
relays: stream.info.relays,
|
||||||
filters: filters,
|
filters: filters,
|
||||||
@ -57,9 +54,6 @@ class ChatWidget extends StatelessWidget {
|
|||||||
.reversed
|
.reversed
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
final goal = filteredChat.firstWhereOrNull(
|
|
||||||
(e) => e.id == stream.info.goal,
|
|
||||||
);
|
|
||||||
final zaps =
|
final zaps =
|
||||||
filteredChat
|
filteredChat
|
||||||
.where((e) => e.kind == 9735)
|
.where((e) => e.kind == 9735)
|
||||||
@ -70,7 +64,8 @@ class ChatWidget extends StatelessWidget {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
if (zaps.isNotEmpty) _TopZappersWidget(events: zaps),
|
if (zaps.isNotEmpty) _TopZappersWidget(events: zaps),
|
||||||
if (goal != null) _StreamGoalWidget(goal: goal),
|
if (stream.info.goal != null)
|
||||||
|
_StreamGoalWidget.id(stream.info.goal!),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: ListView.builder(
|
child: ListView.builder(
|
||||||
reverse: true,
|
reverse: true,
|
||||||
@ -129,6 +124,18 @@ class _StreamGoalWidget extends StatelessWidget {
|
|||||||
|
|
||||||
const _StreamGoalWidget({required this.goal});
|
const _StreamGoalWidget({required this.goal});
|
||||||
|
|
||||||
|
static Widget id(String id) {
|
||||||
|
return RxFilter<Nip01Event>(
|
||||||
|
filters: [
|
||||||
|
Filter(kinds: [9041], ids: [id]),
|
||||||
|
],
|
||||||
|
builder: (ctx, state) {
|
||||||
|
final goal = state?.firstOrNull;
|
||||||
|
return goal != null ? _StreamGoalWidget(goal: goal) : SizedBox.shrink();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final max = int.parse(goal.getFirstTag("amount") ?? "1");
|
final max = int.parse(goal.getFirstTag("amount") ?? "1");
|
||||||
|
Reference in New Issue
Block a user