fix reconnection event

This commit is contained in:
Salvatore Giordano
2022-03-22 16:34:06 +01:00
parent 1358a68ebb
commit 5f12802799
4 changed files with 25 additions and 14 deletions
@@ -417,6 +417,7 @@ class StreamChatClient {
}
void _connectionStatusHandler(ConnectionStatus status) async {
final previousState = wsConnectionStatus;
final currentState = _wsConnectionStatus = status;
handleEvent(Event(
@@ -436,10 +437,12 @@ class StreamChatClient {
await sync(cids: cids, lastSyncAt: _lastSyncedAt);
}
}
handleEvent(Event(
type: EventType.connectionRecovered,
online: true,
));
if (previousState != ConnectionStatus.connected) {
handleEvent(Event(
type: EventType.connectionRecovered,
online: true,
));
}
}
}
@@ -40,7 +40,7 @@ android {
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.example"
minSdkVersion 21
minSdkVersion 22
targetSdkVersion 31
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
@@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 50;
objectVersion = 51;
objects = {
/* Begin PBXBuildFile section */
@@ -68,7 +68,6 @@
59062C6EC2CCFE110AC70AB8 /* Pods-Runner.release.xcconfig */,
4684439012E1DB1A82103E26 /* Pods-Runner.profile.xcconfig */,
);
name = Pods;
path = Pods;
sourceTree = "<group>";
};
@@ -356,13 +355,17 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = EHV7XZLAHA;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
);
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
@@ -488,13 +491,17 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = EHV7XZLAHA;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
);
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
@@ -515,13 +522,17 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = EHV7XZLAHA;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
);
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
@@ -221,6 +221,7 @@ class StreamChannelListController extends PagedValueNotifier<int, Channel> {
}
_channelEventSubscription = client.on().listen((event) {
print('event.type: ${event.type}');
// Returns early if the event is already handled by the listener.
if (eventListener?.call(event) ?? false) return;
@@ -237,10 +238,6 @@ class StreamChannelListController extends PagedValueNotifier<int, Channel> {
_eventHandler.onChannelVisible(event, this);
} else if (eventType == EventType.connectionRecovered) {
_eventHandler.onConnectionRecovered(event, this);
} else if (eventType == EventType.connectionChanged) {
if (event.online != null) {
_eventHandler.onConnectionRecovered(event, this);
}
} else if (eventType == EventType.messageNew) {
_eventHandler.onMessageNew(event, this);
} else if (eventType == EventType.notificationAddedToChannel) {