Skip to content

Commit 70cb9e8

Browse files
authored
Merge branch 'master' into timeout-error
2 parents 96aaa18 + 24e36d2 commit 70cb9e8

File tree

115 files changed

+1442
-961
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+1442
-961
lines changed

.github/workflows/build.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ jobs:
6464
- uses: VeryGoodOpenSource/[email protected]
6565
with:
6666
path: packages/stream_feed/coverage/lcov.info
67-
min_coverage: 81
67+
min_coverage: 80
6868
- uses: VeryGoodOpenSource/[email protected]
6969
with:
7070
path: packages/faye_dart/coverage/lcov.info
71-
min_coverage: 49
71+
min_coverage: 48
7272
- uses: VeryGoodOpenSource/[email protected]
7373
with:
7474
path: packages/stream_feed_flutter_core/coverage/lcov.info

packages/faye_dart/CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
## [0.1.1+1] - (25-02-2022)
2+
3+
- fix: implement Equatable on `FayeClient`. With this change, if you fetch your client from an `InheritedWidget` for example, `updateShouldNotify` doesn't trigger every time.
4+
5+
6+
## [0.1.1] - (25-02-2022)
7+
8+
- new: expose connexion status stream `Stream<FayeClientState>` via the `Subscription` class to check if the Faye client is unconnected, connecting, connected or disconnected, and act accordingly.
9+
10+
111
## [0.1.0] - (07-05-2021)
212

313
* Initial release.

packages/faye_dart/lib/src/client.dart

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import 'dart:async';
22
import 'dart:convert';
33
import 'dart:math' as math;
44

5+
import 'package:equatable/equatable.dart';
56
import 'package:faye_dart/faye_dart.dart';
67
import 'package:faye_dart/src/channel.dart';
78
import 'package:faye_dart/src/message.dart';
8-
import 'package:faye_dart/src/subscription.dart';
99
import 'package:faye_dart/src/timeout_helper.dart';
1010
import 'package:logging/logging.dart';
1111
import 'package:meta/meta.dart';
@@ -14,6 +14,7 @@ import 'package:web_socket_channel/web_socket_channel.dart';
1414

1515
import 'package:faye_dart/src/extensible.dart';
1616

17+
/// Connexion status of the client
1718
enum FayeClientState {
1819
unconnected,
1920
connecting,
@@ -46,7 +47,7 @@ const defaultConnectionTimeout = 60;
4647
const defaultConnectionInterval = 0;
4748
const bayeuxVersion = '1.0';
4849

49-
class FayeClient with Extensible, TimeoutHelper {
50+
class FayeClient with Extensible, TimeoutHelper, EquatableMixin {
5051
FayeClient(
5152
this.baseUrl, {
5253
this.protocols,
@@ -436,4 +437,14 @@ class FayeClient with Extensible, TimeoutHelper {
436437
}
437438
setTimeout(Duration(milliseconds: _advice.interval), () => connect());
438439
}
440+
441+
@override
442+
List<Object?> get props => [
443+
_clientId,
444+
_advice,
445+
_channels,
446+
_responseCallbacks,
447+
_connectRequestInProgress,
448+
_manuallyClosed,
449+
];
439450
}

packages/faye_dart/lib/src/subscription.dart

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import 'client.dart';
2-
import 'message.dart';
1+
import 'package:faye_dart/src/client.dart';
2+
import 'package:faye_dart/src/message.dart';
33

44
typedef Callback = void Function(Map<String, dynamic>? data);
55
typedef WithChannelCallback = void Function(String, Map<String, dynamic>?);
@@ -11,6 +11,9 @@ class Subscription {
1111
WithChannelCallback? _withChannel;
1212
bool _cancelled = false;
1313

14+
/// Connexion status stream
15+
Stream<FayeClientState> get stateStream => _client.stateStream;
16+
1417
Subscription(
1518
this._client,
1619
this._channel, {
@@ -32,4 +35,7 @@ class Subscription {
3235
_client.unsubscribe(_channel, this);
3336
_cancelled = true;
3437
}
38+
39+
@override
40+
List<Object?> get props => [_client, _channel, _callback, _withChannel];
3541
}

packages/faye_dart/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: faye_dart
22
description: Faye is a publish/subscribe messaging protocol that is built on the Bayeux protocol, a messaging system utilized for transporting asynchronous messages over HTTP.
3-
version: 0.1.0
3+
version: 0.1.1+1
44
homepage: https://github.com/GetStream/stream-feed-flutter/blob/master/packages/faye_dart
55
repository: https://github.com/GetStream/stream-feed-flutter/blob/master/packages/faye_dart
66
issue_tracker: https://github.com/GetStream/stream-feed-flutter/issues

packages/faye_dart/test/mock.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import 'package:faye_dart/src/client.dart';
22
import 'package:mocktail/mocktail.dart';
33

4-
class MockClient extends Mock implements FayeClient {}
4+
class MockClient extends Mock implements FayeClient {
5+
bool operator ==(Object? other) => true;
6+
}

packages/stream_feed/CHANGELOG.md

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
## 0.5.1+1: 24/03/2022
2+
3+
- fix: the `JsonConverter<DateTime,String>` implemented in 0.4.0+1 that was supposed to handle utc dates parsing wasn't working properly. Now that it is actually fixed you can convert dates in the user's local timezone.
4+
- depedencies bumps
5+
6+
## 0.5.1: 12/01/2022
7+
8+
- upstream(realtime): version bump. You can now listen to connexion status in the `Subscription` class. For example:
9+
10+
```dart
11+
final subscription = await feed.subscribe();
12+
final subscriptionStatus = subscription.stateStream;
13+
```
14+
- new(realtime): you can now adjust log level when subscribing
15+
- fix: implement Equatable on `StreamFeedClient`. With this change, if you fetch your client from an `InheritedWidget` for example, `updateShouldNotify` doesn't trigger every time.
16+
17+
118
## 0.5.0: 12/01/2022
219

320
- BREAKING: we no longer accept a token in the constructor. This change is inspired by Stream Chat, and allows for use cases like multi account management. It allows to instantiate `StreamFeedClient` at the top of your widget tree for example, and connecting the user later.
@@ -17,21 +34,25 @@
1734
+ frontendToken,
1835
+ );
1936
```
20-
37+
38+
2139
## 0.4.0+3: 27/12/2021
2240

2341
- fix: call profile in setUser, so that currentUser data is not null
24-
25-
## 0.4.0+2: 22/12/2021
42+
43+
44+
## 0.4.0+2: 22/12/2021
2645

2746
- fix: export image_storage_client.dart
28-
47+
48+
2949
## 0.4.0+1: 07/12/2021
3050

3151
- fix: support null values `extraData`'s map
3252
- fix: utc date parsing with a `JsonConverter<DateTime,String>` and `intl`
3353
- fix: unread/unseen count in `NotificationFeedMeta` model
34-
54+
55+
3556
## 0.4.0: 29/10/2021
3657

3758
- breaking: `StreamFeedClient.connect` is now `StreamFeedClient` for better user session handling.

packages/stream_feed/lib/src/client/aggregated_feed.dart

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
import 'package:stream_feed/src/client/feed.dart';
22
import 'package:stream_feed/src/core/api/feed_api.dart';
3-
import 'package:stream_feed/src/core/http/token.dart';
43
import 'package:stream_feed/src/core/index.dart';
5-
import 'package:stream_feed/src/core/models/activity.dart';
6-
import 'package:stream_feed/src/core/models/activity_marker.dart';
7-
import 'package:stream_feed/src/core/models/feed_id.dart';
8-
import 'package:stream_feed/src/core/models/filter.dart';
9-
import 'package:stream_feed/src/core/models/group.dart';
104
import 'package:stream_feed/src/core/util/default.dart';
115
import 'package:stream_feed/src/core/util/token_helper.dart';
126

packages/stream_feed/lib/src/client/analytics_client.dart

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import 'package:equatable/equatable.dart';
12
import 'package:stream_feed/src/core/api/analytics_api.dart';
23
import 'package:stream_feed/src/core/http/stream_http_client.dart';
34
import 'package:stream_feed/src/core/http/token.dart';
@@ -15,7 +16,7 @@ import 'package:stream_feed/src/core/util/token_helper.dart';
1516
/// - Viewing another user's profile page
1617
/// - Searching for a certain user/content/topic/etc.
1718
/// {@endtemplate}
18-
class StreamAnalytics {
19+
class StreamAnalytics extends Equatable {
1920
/// [StreamAnalytics] constructor:
2021
///
2122
/// {@macro analytics}
@@ -121,4 +122,11 @@ class StreamAnalytics {
121122
userToken ?? TokenHelper.buildAnalytics(secret!, TokenAction.write);
122123
return _analytics.trackEngagements(token, engagementDataList);
123124
}
125+
126+
@override
127+
List<Object?> get props => [
128+
secret,
129+
userToken,
130+
userData,
131+
];
124132
}

packages/stream_feed/lib/src/client/flat_feed.dart

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ import 'package:stream_feed/src/core/models/feed_id.dart';
99
import 'package:stream_feed/src/core/models/filter.dart';
1010
import 'package:stream_feed/src/core/models/personalized_feed.dart';
1111
import 'package:stream_feed/src/core/util/default.dart';
12+
import 'package:stream_feed/src/core/util/parse_next.dart';
1213
import 'package:stream_feed/src/core/util/token_helper.dart';
14+
import 'package:stream_feed/stream_feed.dart';
1315

1416
/// {@template flatFeed}
1517
/// Flat is the default feed type - and the only feed type that you can follow.
@@ -82,6 +84,7 @@ class FlatFeed extends Feed {
8284
final token = userToken ??
8385
TokenHelper.buildFeedToken(secret!, TokenAction.read, feedId);
8486
final result = await feed.getActivities(token, feedId, options);
87+
print(result);
8588
final data = (result.data!['results'] as List)
8689
.map((e) => Activity.fromJson(e))
8790
.toList(growable: false);
@@ -137,6 +140,34 @@ class FlatFeed extends Feed {
137140
return data;
138141
}
139142

143+
/// ```dart
144+
/// final paginated = await getPaginatedEnrichedActivities();
145+
/// final nextParams = parseNext(paginated.next!);
146+
/// await getPaginatedEnrichedActivities(limit: nextParams.limit,filter: nextParams.idLT);
147+
/// ```
148+
Future<PaginatedActivities<A, Ob, T, Or>>
149+
getPaginatedEnrichedActivities<A, Ob, T, Or>({
150+
int? limit,
151+
int? offset,
152+
String? session,
153+
Filter? filter,
154+
EnrichmentFlags? flags,
155+
String? ranking, //TODO: no way to parameterized marker?
156+
}) {
157+
final options = {
158+
'limit': limit ?? Default.limit,
159+
'offset': offset ?? Default.offset, //TODO:add session everywhere
160+
...filter?.params ?? Default.filter.params,
161+
...Default.marker.params,
162+
if (flags != null) ...flags.params,
163+
if (ranking != null) 'ranking': ranking,
164+
if (session != null) 'session': session,
165+
};
166+
final token = userToken ??
167+
TokenHelper.buildFeedToken(secret!, TokenAction.read, feedId);
168+
return feed.paginatedActivities(token, feedId, options);
169+
}
170+
140171
/// {@template personalizedFeed}
141172
/// Retrieve a personalized feed for the currentUser
142173
/// i.e. a feed of based on user's activities.

0 commit comments

Comments
 (0)