Skip to content

Commit 19a65ea

Browse files
Merge pull request #123 from appwrite/dev
2 parents 72ee901 + eff60a1 commit 19a65ea

File tree

7 files changed

+35
-15
lines changed

7 files changed

+35
-15
lines changed

CHANGELOG.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
## 8.2.1
22

3-
* Fix OAuth issue on web
4-
* Make improvements in helper classes
3+
* Fix: notify callback when websocket closes [#604](https://github.com/appwrite/sdk-generator/pull/604)
54

65
## 8.2.0
76

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![pub package](https://img.shields.io/pub/v/appwrite?style=flat-square)](https://pub.dartlang.org/packages/appwrite)
44
![License](https://img.shields.io/github/license/appwrite/sdk-for-flutter.svg?style=flat-square)
5-
![Version](https://img.shields.io/badge/api%20version-1.2.0-blue.svg?style=flat-square)
5+
![Version](https://img.shields.io/badge/api%20version-1.2.1-blue.svg?style=flat-square)
66
[![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)
77
[![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite)
88
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)

lib/src/client_io.dart

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,18 +140,18 @@ class ClientIO extends ClientBase with ClientMixin {
140140
Future init() async {
141141
if(_initProgress) return;
142142
_initProgress = true;
143-
// if web skip cookie implementation and origin header as those are automatically handled by browsers
144143
final Directory cookieDir = await _getCookiePath();
145144
_cookieJar = PersistCookieJar(storage: FileStorage(cookieDir.path));
146145
_interceptors.add(CookieManager(_cookieJar));
147-
PackageInfo packageInfo = await PackageInfo.fromPlatform();
148-
addHeader('Origin',
149-
'appwrite-${Platform.operatingSystem}://${packageInfo.packageName}');
150146

151-
//creating custom user agent
152-
DeviceInfoPlugin deviceInfoPlugin = DeviceInfoPlugin();
153147
var device = '';
154148
try {
149+
PackageInfo packageInfo = await PackageInfo.fromPlatform();
150+
addHeader('Origin',
151+
'appwrite-${Platform.operatingSystem}://${packageInfo.packageName}');
152+
153+
//creating custom user agent
154+
DeviceInfoPlugin deviceInfoPlugin = DeviceInfoPlugin();
155155
if (Platform.isAndroid) {
156156
final andinfo = await deviceInfoPlugin.androidInfo;
157157
device =
@@ -174,12 +174,14 @@ class ClientIO extends ClientBase with ClientMixin {
174174
final macinfo = await deviceInfoPlugin.macOsInfo;
175175
device = '(Macintosh; ${macinfo.model})';
176176
}
177+
addHeader(
178+
'user-agent', '${packageInfo.packageName}/${packageInfo.version} $device');
177179
} catch (e) {
178180
debugPrint('Error getting device info: $e');
179181
device = Platform.operatingSystem;
182+
addHeader(
183+
'user-agent', '$device');
180184
}
181-
addHeader(
182-
'user-agent', '${packageInfo.packageName}/${packageInfo.version} $device');
183185

184186
_initialized = true;
185187
_initProgress = false;

lib/src/cookie_manager.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ class CookieManager extends Interceptor {
2323
}
2424
return request;
2525
}).catchError((e, stackTrace) {
26-
// throw AppwriteException(e.message);
26+
return request;
2727
});
2828
return request;
2929
}
3030

3131
@override
3232
FutureOr<http.Response> onResponse(http.Response response) {
3333
_saveCookies(response).then((_) => response).catchError((e, stackTrace) {
34-
// throw AppwriteException(e.message);
34+
return response;
3535
});
3636
return response;
3737
}

lib/src/models/locale.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class Locale implements Model {
1212
final String continentCode;
1313
/// Continent name. This field support localization.
1414
final String continent;
15-
/// True if country is part of the Europian Union.
15+
/// True if country is part of the European Union.
1616
final bool eu;
1717
/// Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format
1818
final String currency;

lib/src/realtime_mixin.dart

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,24 @@ mixin RealtimeMixin {
7676
}
7777
break;
7878
}
79+
}, onDone: () {
80+
for (var list in _channels.values) {
81+
for (var stream in list) {
82+
stream.close();
83+
}
84+
}
85+
_channels.clear();
86+
_closeConnection();
87+
}, onError: (err, stack) {
88+
for (var list in _channels.values) {
89+
for (var stream in list) {
90+
stream.sink.addError(err, stack);
91+
}
92+
}
93+
if (_websok?.closeCode != null && _websok?.closeCode != 1008) {
94+
debugPrint("Reconnecting in one second.");
95+
Future.delayed(Duration(seconds: 1), _createSocket);
96+
}
7997
});
8098
} catch (e) {
8199
if (e is AppwriteException) {

pubspec.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@ dependencies:
1616
flutter_web_auth_2: ^2.0.2
1717
http: ^0.13.5
1818
package_info_plus: ^3.0.2
19-
path_provider: ^2.0.11
19+
path_provider: ^2.0.12
2020
web_socket_channel: ^2.2.0
2121
universal_html: ^2.0.8
2222

2323
dev_dependencies:
24+
path_provider_platform_interface: ^2.0.5
2425
flutter_lints: ^2.0.1
2526
flutter_test:
2627
sdk: flutter

0 commit comments

Comments
 (0)