channel list fixes
This commit is contained in:
parent
89d1e0f641
commit
778451fa4c
@ -1,4 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||||
import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart';
|
import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:simplecloudnotifier/api/api_client.dart';
|
import 'package:simplecloudnotifier/api/api_client.dart';
|
||||||
@ -142,7 +143,8 @@ class _ChannelRootPageState extends State<ChannelRootPage> with RouteAware {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return RefreshIndicator(
|
return Scaffold(
|
||||||
|
body: RefreshIndicator(
|
||||||
onRefresh: () => Future.sync(
|
onRefresh: () => Future.sync(
|
||||||
() => _pagingController.refresh(),
|
() => _pagingController.refresh(),
|
||||||
),
|
),
|
||||||
@ -158,6 +160,14 @@ class _ChannelRootPageState extends State<ChannelRootPage> with RouteAware {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
floatingActionButton: FloatingActionButton(
|
||||||
|
onPressed: () {
|
||||||
|
//TODO scan qr code to subscribe channel
|
||||||
|
},
|
||||||
|
backgroundColor: ,
|
||||||
|
child: const Icon(FontAwesomeIcons.qrcode),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ enum EditState { none, editing, saving }
|
|||||||
|
|
||||||
class _ChannelViewPageState extends State<ChannelViewPage> {
|
class _ChannelViewPageState extends State<ChannelViewPage> {
|
||||||
late ImmediateFuture<String?> _futureSubscribeKey;
|
late ImmediateFuture<String?> _futureSubscribeKey;
|
||||||
late ImmediateFuture<List<Subscription>> _futureSubscriptions;
|
late ImmediateFuture<List<(Subscription, UserPreview?)>> _futureSubscriptions;
|
||||||
late ImmediateFuture<UserPreview> _futureOwner;
|
late ImmediateFuture<UserPreview> _futureOwner;
|
||||||
|
|
||||||
final TextEditingController _ctrlDisplayName = TextEditingController();
|
final TextEditingController _ctrlDisplayName = TextEditingController();
|
||||||
@ -61,10 +61,10 @@ class _ChannelViewPageState extends State<ChannelViewPage> {
|
|||||||
} else {
|
} else {
|
||||||
_futureSubscribeKey = ImmediateFuture<String?>.ofFuture(_getSubScribeKey(userAcc));
|
_futureSubscribeKey = ImmediateFuture<String?>.ofFuture(_getSubScribeKey(userAcc));
|
||||||
}
|
}
|
||||||
_futureSubscriptions = ImmediateFuture<List<Subscription>>.ofFuture(_listSubscriptions(userAcc));
|
_futureSubscriptions = ImmediateFuture<List<(Subscription, UserPreview?)>>.ofFuture(_listSubscriptions(userAcc));
|
||||||
} else {
|
} else {
|
||||||
_futureSubscribeKey = ImmediateFuture<String?>.ofValue(null);
|
_futureSubscribeKey = ImmediateFuture<String?>.ofValue(null);
|
||||||
_futureSubscriptions = ImmediateFuture<List<Subscription>>.ofValue([]);
|
_futureSubscriptions = ImmediateFuture<List<(Subscription, UserPreview?)>>.ofValue([]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (widget.channel.ownerUserID == userAcc.userID) {
|
if (widget.channel.ownerUserID == userAcc.userID) {
|
||||||
@ -156,13 +156,13 @@ class _ChannelViewPageState extends State<ChannelViewPage> {
|
|||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
children: [
|
children: [
|
||||||
for (final sub in snapshot.data!.where((sub) => sub.subscriptionID != widget.subscription?.subscriptionID))
|
for (final (sub, user) in snapshot.data!.where((v) => v.$1.subscriptionID != widget.subscription?.subscriptionID))
|
||||||
UI.metaCard(
|
UI.metaCard(
|
||||||
context: context,
|
context: context,
|
||||||
icon: FontAwesomeIcons.solidDiagramSuccessor,
|
icon: FontAwesomeIcons.solidDiagramSuccessor,
|
||||||
title: 'Subscription (other)',
|
title: 'Subscription (' + (user?.username ?? user?.userID ?? 'other') + ')',
|
||||||
values: [_formatSubscriptionStatus(sub)],
|
values: [_formatSubscriptionStatus(sub)],
|
||||||
iconActions: _getForignSubActions(sub),
|
iconActions: _getForeignSubActions(sub),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
@ -461,7 +461,7 @@ class _ChannelViewPageState extends State<ChannelViewPage> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<Subscription>> _listSubscriptions(AppAuth auth) async {
|
Future<List<(Subscription, UserPreview?)>> _listSubscriptions(AppAuth auth) async {
|
||||||
try {
|
try {
|
||||||
await Future.delayed(const Duration(seconds: 0), () {}); // this is annoyingly important - otherwise we call setLoadingIndeterminate directly in initStat() and get an exception....
|
await Future.delayed(const Duration(seconds: 0), () {}); // this is annoyingly important - otherwise we call setLoadingIndeterminate directly in initStat() and get an exception....
|
||||||
|
|
||||||
@ -469,9 +469,11 @@ class _ChannelViewPageState extends State<ChannelViewPage> {
|
|||||||
|
|
||||||
var subs = await APIClient.getChannelSubscriptions(auth, widget.channel.channelID);
|
var subs = await APIClient.getChannelSubscriptions(auth, widget.channel.channelID);
|
||||||
|
|
||||||
|
var userMap = {for (var v in (await Future.wait(subs.map((e) => e.subscriberUserID).toSet().map((e) => APIClient.getUserPreview(auth, e)).toList()))) v.userID: v};
|
||||||
|
|
||||||
//await Future.delayed(const Duration(seconds: 10), () {});
|
//await Future.delayed(const Duration(seconds: 10), () {});
|
||||||
|
|
||||||
return subs;
|
return subs.map((e) => (e, userMap[e.subscriberUserID] ?? null)).toList();
|
||||||
} finally {
|
} finally {
|
||||||
_incLoadingIndeterminateCounter(-1);
|
_incLoadingIndeterminateCounter(-1);
|
||||||
}
|
}
|
||||||
@ -493,7 +495,7 @@ class _ChannelViewPageState extends State<ChannelViewPage> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<(IconData, void Function())> _getForignSubActions(Subscription sub) {
|
List<(IconData, void Function())> _getForeignSubActions(Subscription sub) {
|
||||||
if (sub.confirmed) {
|
if (sub.confirmed) {
|
||||||
return [(FontAwesomeIcons.solidSquareXmark, () => _cancelForeignSubscription(sub))];
|
return [(FontAwesomeIcons.solidSquareXmark, () => _cancelForeignSubscription(sub))];
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user