Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions lib/src/fixtures/interests.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ final List<Interest> interestsFixturesData = [
sources: [sourcesFixturesData[0]], // TechCrunch
countries: const [],
),
isFeedFilter: true,
isPinnedFeedFilter: true,
deliveryTypes: const {
PushNotificationSubscriptionDeliveryType.breakingOnly,
},
Expand All @@ -26,7 +26,7 @@ final List<Interest> interestsFixturesData = [
sources: const [],
countries: const [],
),
isFeedFilter: true,
isPinnedFeedFilter: true,
deliveryTypes: const {},
),
Interest(
Expand All @@ -38,7 +38,7 @@ final List<Interest> interestsFixturesData = [
sources: [sourcesFixturesData[40]], // ESPN
countries: const [],
),
isFeedFilter: true,
isPinnedFeedFilter: true,
deliveryTypes: const {PushNotificationSubscriptionDeliveryType.dailyDigest},
),
Interest(
Expand All @@ -50,7 +50,7 @@ final List<Interest> interestsFixturesData = [
sources: const [],
countries: const [],
),
isFeedFilter: true,
isPinnedFeedFilter: true,
deliveryTypes: const {},
),
Interest(
Expand All @@ -65,7 +65,7 @@ final List<Interest> interestsFixturesData = [
],
countries: const [],
),
isFeedFilter: true,
isPinnedFeedFilter: true,
deliveryTypes: const {},
),
Interest(
Expand All @@ -77,7 +77,7 @@ final List<Interest> interestsFixturesData = [
sources: [sourcesFixturesData[0]], // TechCrunch
countries: const [],
),
isFeedFilter: true,
isPinnedFeedFilter: true,
deliveryTypes: const {},
),
];
6 changes: 3 additions & 3 deletions lib/src/fixtures/remote_configs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ final List<RemoteConfig> remoteConfigsFixturesData = [
limits: {
AppUserRole.guestUser: InterestLimits(
total: 3,
feedFilters: 3,
pinnedFeedFilters: 3,
notifications: {
PushNotificationSubscriptionDeliveryType.breakingOnly: 1,
PushNotificationSubscriptionDeliveryType.dailyDigest: 0,
Expand All @@ -36,7 +36,7 @@ final List<RemoteConfig> remoteConfigsFixturesData = [
),
AppUserRole.standardUser: InterestLimits(
total: 10,
feedFilters: 5,
pinnedFeedFilters: 5,
notifications: {
PushNotificationSubscriptionDeliveryType.breakingOnly: 3,
PushNotificationSubscriptionDeliveryType.dailyDigest: 2,
Expand All @@ -45,7 +45,7 @@ final List<RemoteConfig> remoteConfigsFixturesData = [
),
AppUserRole.premiumUser: InterestLimits(
total: 25,
feedFilters: 10,
pinnedFeedFilters: 10,
notifications: {
PushNotificationSubscriptionDeliveryType.breakingOnly: 10,
PushNotificationSubscriptionDeliveryType.dailyDigest: 10,
Expand Down
14 changes: 7 additions & 7 deletions lib/src/models/config/interest_limits.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ part 'interest_limits.g.dart';
/// feature.
///
/// This includes the total number of interests a user can create, how many
/// can be used as feed filters, and the subscription limits for each
/// can be used as a pinned feed filters, and the subscription limits for each
/// notification type.
/// {@endtemplate}
@immutable
Expand All @@ -19,7 +19,7 @@ class InterestLimits extends Equatable {
/// {@macro interest_limits}
const InterestLimits({
required this.total,
required this.feedFilters,
required this.pinnedFeedFilters,
required this.notifications,
});

Expand All @@ -30,9 +30,9 @@ class InterestLimits extends Equatable {
/// The total number of interests a user with this role can create.
final int total;

/// The maximum number of interests that can be marked as a "feed filter"
/// The maximum number of interests that can be marked as a "pinned feed filter"
/// by a user with this role.
final int feedFilters;
final int pinnedFeedFilters;

/// A map defining the subscription limits for each notification type.
///
Expand All @@ -45,18 +45,18 @@ class InterestLimits extends Equatable {
Map<String, dynamic> toJson() => _$InterestLimitsToJson(this);

@override
List<Object> get props => [total, feedFilters, notifications];
List<Object> get props => [total, pinnedFeedFilters, notifications];

/// Creates a copy of this [InterestLimits] but with the given fields
/// replaced with the new values.
InterestLimits copyWith({
int? total,
int? feedFilters,
int? pinnedFeedFilters,
Map<PushNotificationSubscriptionDeliveryType, int>? notifications,
}) {
return InterestLimits(
total: total ?? this.total,
feedFilters: feedFilters ?? this.feedFilters,
pinnedFeedFilters: pinnedFeedFilters ?? this.pinnedFeedFilters,
notifications: notifications ?? this.notifications,
);
}
Expand Down
7 changes: 5 additions & 2 deletions lib/src/models/config/interest_limits.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions lib/src/models/interests/interest.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ part 'interest.g.dart';

/// {@template interest}
/// Represents a user's saved set of content criteria, unifying the concepts
/// of a "Saved Filter" for on-demand feed filtering and a "Notification
/// of a saved "Feed Filter" for on-demand feed filtering and a "Notification
/// Subscription" for push alerts.
///
/// An Interest is a single entity that can be used for multiple purposes,
/// determined by the `isFeedFilter` flag and the `deliveryTypes` set.
/// determined by the `isPinnedFeedFilter` flag and the `deliveryTypes` set.
/// {@endtemplate}
@immutable
@JsonSerializable(explicitToJson: true, includeIfNull: true, checked: true)
Expand All @@ -23,7 +23,7 @@ class Interest extends Equatable {
required this.userId,
required this.name,
required this.criteria,
required this.isFeedFilter,
required this.isPinnedFeedFilter,
required this.deliveryTypes,
});

Expand All @@ -45,8 +45,8 @@ class Interest extends Equatable {
final InterestCriteria criteria;

/// A flag indicating whether this interest should be available as a
/// one-click filter in the user's feed.
final bool isFeedFilter;
/// one-click pinned filter in the user's feed.
final bool isPinnedFeedFilter;

/// The set of notification delivery types the user has opted into for this
/// interest (e.g., `breakingOnly`, `dailyDigest`).
Expand All @@ -64,7 +64,7 @@ class Interest extends Equatable {
userId,
name,
criteria,
isFeedFilter,
isPinnedFeedFilter,
deliveryTypes,
];

Expand All @@ -75,15 +75,15 @@ class Interest extends Equatable {
String? userId,
String? name,
InterestCriteria? criteria,
bool? isFeedFilter,
bool? isPinnedFeedFilter,
Set<PushNotificationSubscriptionDeliveryType>? deliveryTypes,
}) {
return Interest(
id: id ?? this.id,
userId: userId ?? this.userId,
name: name ?? this.name,
criteria: criteria ?? this.criteria,
isFeedFilter: isFeedFilter ?? this.isFeedFilter,
isPinnedFeedFilter: isPinnedFeedFilter ?? this.isPinnedFeedFilter,
deliveryTypes: deliveryTypes ?? this.deliveryTypes,
);
}
Expand Down
56 changes: 27 additions & 29 deletions lib/src/models/interests/interest.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions test/src/models/config/interest_limits_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ void main() {
// Arrange: Create another instance with the same values.
final anotherLimits = InterestLimits(
total: interestLimitsFixture.total,
feedFilters: interestLimitsFixture.feedFilters,
pinnedFeedFilters: interestLimitsFixture.pinnedFeedFilters,
notifications: interestLimitsFixture.notifications,
);

Expand All @@ -28,7 +28,7 @@ void main() {
interestLimitsFixture.props,
equals([
interestLimitsFixture.total,
interestLimitsFixture.feedFilters,
interestLimitsFixture.pinnedFeedFilters,
interestLimitsFixture.notifications,
]),
);
Expand Down Expand Up @@ -58,12 +58,12 @@ void main() {
// Act: Create a copy with the new values.
final copiedLimits = interestLimitsFixture.copyWith(
total: newTotal,
feedFilters: newFeedFilters,
pinnedFeedFilters: newFeedFilters,
);

// Assert: The new instance should have the updated values.
expect(copiedLimits.total, equals(newTotal));
expect(copiedLimits.feedFilters, equals(newFeedFilters));
expect(copiedLimits.pinnedFeedFilters, equals(newFeedFilters));

// Assert: Unchanged properties remain the same.
expect(
Expand Down
2 changes: 1 addition & 1 deletion test/src/models/interests/interest_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ void main() {
interestFixture.userId,
interestFixture.name,
interestFixture.criteria,
interestFixture.isFeedFilter,
interestFixture.isPinnedFeedFilter,
interestFixture.deliveryTypes,
]),
);
Expand Down
Loading