Skip to content

Commit eded8c4

Browse files
committed
refactor(app_review): simplify feedback model
- Rename InitialAppReviewFeedback to AppReviewFeedback - Remove NegativeFeedback class and related history - Replace with a single feedback field and optional feedbackDetails string - Update related tests and fixtures
1 parent a960fe8 commit eded8c4

File tree

12 files changed

+93
-240
lines changed

12 files changed

+93
-240
lines changed

lib/src/enums/initial_app_review_feedback.dart renamed to lib/src/enums/app_review_feedback.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import 'package:json_annotation/json_annotation.dart';
22

3-
/// {@template initial_app_review_feedback}
4-
/// Represents the user's response to the initial, private app review prompt
3+
/// {@template app_review_feedback}
4+
/// Represents the user's response to the private app review prompt
55
/// (e.g., "Are you enjoying the app?").
66
/// {@endtemplate}
77
@JsonEnum()
8-
enum InitialAppReviewFeedback {
8+
enum AppReviewFeedback {
99
/// The user indicated a positive experience.
1010
@JsonValue('positive')
1111
positive,

lib/src/enums/enums.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ export 'ad_type.dart';
33
export 'app_accent_theme.dart';
44
export 'app_base_theme.dart';
55
export 'app_font_weight.dart';
6+
export 'app_review_feedback.dart';
67
export 'app_text_scale_factor.dart';
78
export 'app_user_role.dart';
89
export 'banner_ad_shape.dart';
@@ -20,7 +21,6 @@ export 'feed_item_click_behavior.dart';
2021
export 'feed_item_density.dart';
2122
export 'feed_item_image_style.dart';
2223
export 'headline_report_reason.dart';
23-
export 'initial_app_review_feedback.dart';
2424
export 'push_notification_provider.dart';
2525
export 'push_notification_subscription_delivery_type.dart';
2626
export 'reaction_type.dart';

lib/src/fixtures/app_reviews.dart

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ List<AppReview> getAppReviewsFixturesData({
3939
AppReview(
4040
id: 'ar-pos-$i',
4141
userId: user.id,
42-
initialFeedback: InitialAppReviewFeedback.positive,
42+
feedback: AppReviewFeedback.positive,
4343
createdAt: createdAt,
4444
updatedAt: createdAt.add(const Duration(minutes: 1)),
4545
wasStoreReviewRequested: true,
@@ -52,15 +52,10 @@ List<AppReview> getAppReviewsFixturesData({
5252
AppReview(
5353
id: 'ar-neg-reason-$i',
5454
userId: user.id,
55-
initialFeedback: InitialAppReviewFeedback.negative,
55+
feedback: AppReviewFeedback.negative,
5656
createdAt: createdAt,
5757
updatedAt: createdAt,
58-
negativeFeedbackHistory: [
59-
NegativeFeedback(
60-
providedAt: createdAt,
61-
reason: reasons[i % reasons.length],
62-
),
63-
],
58+
feedbackDetails: reasons[i % reasons.length],
6459
),
6560
);
6661
}
@@ -70,7 +65,7 @@ List<AppReview> getAppReviewsFixturesData({
7065
AppReview(
7166
id: 'ar-neg-$i',
7267
userId: user.id,
73-
initialFeedback: InitialAppReviewFeedback.negative,
68+
feedback: AppReviewFeedback.negative,
7469
createdAt: createdAt,
7570
updatedAt: createdAt,
7671
),
@@ -90,7 +85,7 @@ List<AppReview> getAppReviewsFixturesData({
9085
AppReview(
9186
id: 'ar-multistage-final',
9287
userId: multiStageUser.id,
93-
initialFeedback: InitialAppReviewFeedback.positive,
88+
feedback: AppReviewFeedback.positive,
9489
// createdAt would be from the first interaction
9590
createdAt: firstReviewTime,
9691
// updatedAt is from the most recent interaction
@@ -99,9 +94,7 @@ List<AppReview> getAppReviewsFixturesData({
9994
// depending on business logic. Here we assume it's cleared on positive.
10095
wasStoreReviewRequested: true,
10196
// The history might be kept for analytics, even after a positive review.
102-
negativeFeedbackHistory: [
103-
NegativeFeedback(providedAt: firstReviewTime, reason: reasons[1]),
104-
],
97+
feedbackDetails: reasons[1],
10598
),
10699
);
107100

@@ -113,13 +106,10 @@ List<AppReview> getAppReviewsFixturesData({
113106
AppReview(
114107
id: 'ar-multi-neg',
115108
userId: persistentNegativeUser.id,
116-
initialFeedback: InitialAppReviewFeedback.negative,
109+
feedback: AppReviewFeedback.negative,
117110
createdAt: firstNegativeTime,
118111
updatedAt: secondNegativeTime,
119-
negativeFeedbackHistory: [
120-
NegativeFeedback(providedAt: firstNegativeTime, reason: reasons[2]),
121-
NegativeFeedback(providedAt: secondNegativeTime, reason: reasons[3]),
122-
],
112+
feedbackDetails: reasons[3],
123113
),
124114
);
125115

lib/src/models/user_generated_content/app_review.dart

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ part 'app_review.g.dart';
2929
///
3030
/// - **Layer 1 (Internal Prompt)**: A private, low-friction UI element within the
3131
/// app gauges user sentiment (e.g., "Are you enjoying the app?"). This acts as
32-
/// a crucial filter. The user's response is captured in the [initialFeedback]
32+
/// a crucial filter. The user's response is captured in the [feedback]
3333
/// field.
3434
///
3535
/// - **Layer 2 (Native OS Prompt)**: Only if a user provides a positive signal in
@@ -46,11 +46,11 @@ class AppReview extends Equatable {
4646
const AppReview({
4747
required this.id,
4848
required this.userId,
49-
required this.initialFeedback,
49+
required this.feedback,
5050
required this.createdAt,
5151
required this.updatedAt,
52-
this.negativeFeedbackHistory = const [],
5352
this.wasStoreReviewRequested = false,
53+
this.feedbackDetails,
5454
});
5555

5656
/// Creates an [AppReview] from JSON data.
@@ -63,8 +63,8 @@ class AppReview extends Equatable {
6363
/// The ID of the user providing the feedback.
6464
final String userId;
6565

66-
/// The user's answer to the initial, private feedback prompt.
67-
final InitialAppReviewFeedback initialFeedback;
66+
/// The user's answer to the private feedback prompt.
67+
final AppReviewFeedback feedback;
6868

6969
/// The timestamp when this review record was created (i.e., when the user
7070
/// answered the initial prompt).
@@ -78,19 +78,17 @@ class AppReview extends Equatable {
7878
/// A flag indicating whether a native OS store review has been requested for
7979
/// this user.
8080
///
81-
/// This is set to `true` after a user provides a `positive` [initialFeedback]
81+
/// This is set to `true` after a user provides a `positive` [feedback]
8282
/// and the application calls the native review API. It acts as a permanent
8383
/// marker, ensuring the corresponding `UserFeedDecoratorStatus` can be marked
8484
/// as completed to prevent ever showing the internal prompt again.
8585
@JsonKey(defaultValue: false)
8686
final bool wasStoreReviewRequested;
8787

88-
/// A historical log of all negative feedback instances from the user.
88+
/// Optional text details provided by the user, typically when giving
89+
/// negative feedback.
8990
///
90-
/// Each time a user responds negatively to the initial prompt, a new
91-
/// [NegativeFeedback] entry is added to this list. This preserves valuable
92-
/// historical data on user sentiment.
93-
final List<NegativeFeedback> negativeFeedbackHistory;
91+
final String? feedbackDetails;
9492

9593
/// Converts this [AppReview] instance to JSON data.
9694
Map<String, dynamic> toJson() => _$AppReviewToJson(this);
@@ -99,30 +97,29 @@ class AppReview extends Equatable {
9997
List<Object?> get props => [
10098
id,
10199
userId,
102-
initialFeedback,
100+
feedback,
103101
createdAt,
104102
updatedAt,
105103
wasStoreReviewRequested,
106-
negativeFeedbackHistory,
104+
feedbackDetails,
107105
];
108106

109107
/// Creates a copy of this [AppReview] with updated values.
110108
AppReview copyWith({
111-
InitialAppReviewFeedback? initialFeedback,
109+
AppReviewFeedback? feedback,
112110
DateTime? updatedAt,
113111
bool? wasStoreReviewRequested,
114-
List<NegativeFeedback>? negativeFeedbackHistory,
112+
String? feedbackDetails,
115113
}) {
116114
return AppReview(
117115
id: id,
118116
userId: userId,
119-
initialFeedback: initialFeedback ?? this.initialFeedback,
117+
feedback: feedback ?? this.feedback,
120118
createdAt: createdAt,
121119
updatedAt: updatedAt ?? this.updatedAt,
122120
wasStoreReviewRequested:
123121
wasStoreReviewRequested ?? this.wasStoreReviewRequested,
124-
negativeFeedbackHistory:
125-
negativeFeedbackHistory ?? this.negativeFeedbackHistory,
122+
feedbackDetails: feedbackDetails ?? this.feedbackDetails,
126123
);
127124
}
128125
}

lib/src/models/user_generated_content/app_review.g.dart

Lines changed: 33 additions & 42 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/src/models/user_generated_content/negative_feedback.dart

Lines changed: 0 additions & 36 deletions
This file was deleted.

lib/src/models/user_generated_content/negative_feedback.g.dart

Lines changed: 0 additions & 25 deletions
This file was deleted.
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
export 'app_review.dart';
22
export 'comment.dart';
33
export 'engagement.dart';
4-
export 'negative_feedback.dart';
54
export 'reaction.dart';
65
export 'report.dart';
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import 'package:core/src/enums/app_review_feedback.dart';
2+
import 'package:test/test.dart';
3+
4+
void main() {
5+
group('AppReviewFeedback', () {
6+
test('has correct string names', () {
7+
expect(AppReviewFeedback.positive.name, 'positive');
8+
expect(AppReviewFeedback.negative.name, 'negative');
9+
});
10+
11+
test('can be created from string names', () {
12+
expect(
13+
AppReviewFeedback.values.byName('positive'),
14+
AppReviewFeedback.positive,
15+
);
16+
expect(
17+
AppReviewFeedback.values.byName('negative'),
18+
AppReviewFeedback.negative,
19+
);
20+
});
21+
});
22+
}

0 commit comments

Comments
 (0)