GetStream / stream-chat-flutter

Flutter Chat SDK - Build your own chat app experience using Dart, Flutter and the Stream Chat Messaging API.
https://getstream.io/chat/sdk/flutter/
Other
930 stars 342 forks source link

Loading Channels - State = Loading / No Channels / Channels #1038

Closed Abacaxi-Nelson closed 2 years ago

Abacaxi-Nelson commented 2 years ago

Which packages are you using?

stream_chat, stream_chat_flutter, stream_chat_persistance

On what platforms did you experience the issue?

iOS, Android

What version are you using?

stream_chat_persistence 3.1.0 stream_chat 3.5.0

What happened?

Im seeing wrong loading state when loading channels. I see Loading > No Channels > Channels

https://user-images.githubusercontent.com/556990/159691484-59694b33-1f28-41b6-82c3-19dbaeddba52.mp4

Steps to reproduce

Check code below

Supporting info to reproduce

ChannelsBloc(
                  child: Padding(
                    padding: const EdgeInsets.only(left: 11, right: 14),
                    child: AnimatedSwitcher(
                      duration: const Duration(milliseconds: 350),
                      child: GestureDetector(
                        behavior: HitTestBehavior.opaque,
                        onPanDown: (_) {
                          final FocusScopeNode currentScope = FocusScope.of(context);
                          if (!currentScope.hasPrimaryFocus && currentScope.hasFocus) {
                            FocusManager.instance.primaryFocus?.unfocus();
                          }
                        },
                        child: Padding(
                          padding: const EdgeInsets.only(top: 10),
                          child: ChannelListView(
                            onChannelLongPress: (c) {
                              onChannelLongPress(c, context);
                            },
                            swipeToAction: false,
                            separatorBuilder: (_, __) => const SizedBox(height: 16),
                            filter: Filter.and([
                              Filter.in_('members', [user!.id]),
                              Filter.equal('type', type)
                            ]),
                            presence: true,
                            limit: 20,
                            channelWidget: ChannelPage(
                              changeToFeedPage: changeToFeedPage,
                              getstreamClient: getstreamClient,
                            ),
                            channelPreviewBuilder: (context, channel) {
                              if (channel.type != 'livestream') {
                                return DecoratedBox(
                                  decoration: const BoxDecoration(
                                    color: PicnicTheme.pageBackground,
                                  ),
                                  child: ChannelPreview(
                                    //onLongPress: onChannelLongPress,
                                    onLongPress: (c) {
                                      onChannelLongPress(c, context);
                                    },
                                    channel: channel,
                                    onTap: (channel) => Navigator.push(
                                      context,
                                      MaterialPageRoute(
                                        builder: (context) => StreamChannel(
                                          channel: channel,
                                          child: ChannelPage(
                                            changeToFeedPage: changeToFeedPage,
                                            getstreamClient: getstreamClient,
                                          ),
                                        ),
                                      ),
                                    ),
                                  ),
                                );
                              }
                              final circleId = channel.id!.replaceFirst('circle_', '');
                              return Stack(children: [
                                ChannelPreview(
                                    //onLongPress: onChannelLongPress,
                                    onLongPress: (c) {
                                      onChannelLongPress(c, context);
                                    },
                                    channel: channel,
                                    onTap: (channel) async {
                                      final ret = await Navigator.push(
                                        context,
                                        MaterialPageRoute(
                                          builder: (context) => StreamChannel(
                                            channel: channel,
                                            child: ChannelPage(
                                              changeToFeedPage: changeToFeedPage,
                                              getstreamClient: getstreamClient,
                                            ),
                                          ),
                                        ),
                                      );
                                      await hiveChatNotificationBox.delete(channel.id!.replaceFirst('circle_', ''));
                                      await hiveChatBox.put(channel.id!.replaceFirst('circle_', ''),
                                          DateTime.now().millisecondsSinceEpoch);
                                    }),
                                Align(alignment: Alignment.centerRight, child: UnreadWidget(circleId: circleId))
                              ]);
                            },
                            onViewInfoTap: (channel) {},
                          ),
                        ),
                      ),
                    ),
                  ),
                )

Relevant log output

No response

Flutter analyze output

No response

Flutter doctor output

No response

Code of Conduct

Abacaxi-Nelson commented 2 years ago

Hi, If i remove persistence, its smoother..

imtoori commented 2 years ago

@Abacaxi-Nelson can I ask you if you can try the beta release? I think it should solve this issue Let me know if you can

Abacaxi-Nelson commented 2 years ago

Sorry @imtoori You mean version 4 beta ?

ayush221b commented 2 years ago

Hey @Abacaxi-Nelson yes. Here's the beta release: https://pub.dev/packages/stream_chat_flutter/versions/4.0.0-beta.2

imtoori commented 2 years ago

did you try with v4 @Abacaxi-Nelson ?

github-actions[bot] commented 2 years ago

Without additional information, we are unfortunately not sure how to resolve this issue. We are therefore reluctantly going to close this bug for now. Please don't hesitate to comment on the bug if you have any more information for us; we will reopen it right away! Thanks for your contribution.