fix channels query

This commit is contained in:
Salvatore Giordano
2020-04-10 14:47:57 +02:00
parent 2c6273c080
commit 552f4ee600
3 changed files with 23 additions and 13 deletions
+2 -1
View File
@@ -51,7 +51,7 @@ class MyApp extends StatelessWidget {
return MaterialApp(
theme: ThemeData.light(),
darkTheme: ThemeData.dark(),
themeMode: ThemeMode.dark,
themeMode: ThemeMode.system,
home: Container(
child: StreamChat(
client: client,
@@ -99,6 +99,7 @@ class ChannelPage extends StatelessWidget {
child: Stack(
children: <Widget>[
MessageListView(
showVideoFullScreen: false,
threadBuilder: (_, parentMessage) {
return ThreadPage(
parent: parentMessage,
+9 -4
View File
@@ -326,7 +326,8 @@ class _ChannelListViewState extends State<ChannelListView>
void _listenChannelPagination(ChannelsBlocState channelsProvider) {
if (_scrollController.position.maxScrollExtent ==
_scrollController.offset) {
_scrollController.offset &&
_scrollController.offset != 0) {
channelsProvider.queryChannels(
filter: widget.filter,
sortOptions: widget.sort,
@@ -342,11 +343,11 @@ class _ChannelListViewState extends State<ChannelListView>
void initState() {
super.initState();
final channelsProvider = ChannelsBloc.of(context);
final channelsBloc = ChannelsBloc.of(context);
WidgetsBinding.instance.addObserver(this);
channelsProvider.queryChannels(
channelsBloc.queryChannels(
filter: widget.filter,
sortOptions: widget.sort,
paginationParams: widget.pagination,
@@ -354,7 +355,11 @@ class _ChannelListViewState extends State<ChannelListView>
);
_scrollController.addListener(() {
_listenChannelPagination(channelsProvider);
channelsBloc.queryChannelsLoading.first.then((loading) {
if (!loading) {
_listenChannelPagination(channelsBloc);
}
});
});
}
+12 -8
View File
@@ -194,14 +194,16 @@ class StreamChatState extends State<StreamChat> with WidgetsBindingObserver {
void didChangeAppLifecycleState(AppLifecycleState state) {
if (state == AppLifecycleState.paused) {
if (Platform.isAndroid) {
_newMessageSubscription =
client.on(EventType.messageNew).listen((event) {
client.androidNotificationHandler({
'data': {
'message_id': event.message.id,
},
if (client.pushNotificationsEnabled) {
_newMessageSubscription =
client.on(EventType.messageNew).listen((event) {
client.androidNotificationHandler({
'data': {
'message_id': event.message.id,
},
});
});
});
}
_disconnectTimer = Timer(Duration(minutes: 1), () {
client.disconnect();
});
@@ -214,7 +216,9 @@ class StreamChatState extends State<StreamChat> with WidgetsBindingObserver {
_disconnectTimer.cancel();
} else {
if (client.wsConnectionStatus.value == ConnectionStatus.disconnected) {
NotificationService.handleIosMessageQueue(client);
if (client.pushNotificationsEnabled) {
NotificationService.handleIosMessageQueue(client);
}
client.connect();
}
}