Skip to content

ObservableMap not notifying Observer mobx 2.2.3 it was woking fine in 2.2.1 #969

Description

@boradparas

I am using so many ObservableMaps in the app and none of them are updating the UI since I upgraded to 2.2.3

@observable ObservableMap<String, ParticipantExtended> sortedParticipants = ObservableMap<String, ParticipantExtended>();

Observer(
                          builder: (_) {
                            return SliverGrid(
                              gridDelegate:
                                  SliverGridDelegateWithFixedCrossAxisCount(
                                crossAxisCount: crossAxisCount,
                                childAspectRatio: tileWidth / tileHeight,
                                crossAxisSpacing: 2,
                                mainAxisSpacing: 2,
                              ),
                              delegate: SliverChildBuilderDelegate(
                                (context, index) {
                                  final participant = videoRoomStore
                                      .sortedParticipants.values
                                      .elementAt(index);
                                 return VisibilityDetector(
                                    key: Key(participant.identity),
                                    onVisibilityChanged: (info) {
                                      final bool isVisible =
                                          info.visibleFraction > 0;
                                      final bool isCompletelyGone =
                                          info.visibleFraction == 0;
                                      final bool isSubscribed = videoRoomStore
                                                  .participantSubscriptions[
                                              participant.identity] ??
                                          false;
                                      final bool shouldSubscribe =
                                          !isSubscribed &&
                                              isVisible &&
                                              !participant.isLocalParticipant;

                                      if (shouldSubscribe) {
                                        videoRoomStore.subscribeToVideoTracks(
                                          participant.participant
                                              as RemoteParticipant,
                                        );
                                        videoRoomStore.visibleParticipants[
                                            participant.identity] = true;
                                      } else if (!participant
                                              .isLocalParticipant &&
                                          isCompletelyGone) {
                                        videoRoomStore.unSubscribeToVideoTracks(
                                          participant.participant
                                              as RemoteParticipant,
                                        );
                                        videoRoomStore.visibleParticipants
                                            .remove(
                                          participant.identity,
                                        );
                                      }
                                    },
                                    child: ParticipantTile(
                                      participant: participant,
                                    ),
                                  );
                                },
                                childCount: videoRoomStore.isAppInForeground
                                    ? videoRoomStore.sortedParticipants.length
                                    : 0,
                              ),
                            );
                          },
                        ),

What change I need to make to keep it working as earlier it used to work?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

investigationNeeds some research and investigationquestionFurther information is requested

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions