From f646034713d4d51287c93791203be3d28cbec231 Mon Sep 17 00:00:00 2001 From: Mohammed Mohsin <59914433+mdmohsin7@users.noreply.github.com> Date: Wed, 20 Nov 2024 12:36:05 +0530 Subject: [PATCH 1/5] show review option only if the app is enabled and other fixes --- app/lib/pages/apps/app_detail/app_detail.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/lib/pages/apps/app_detail/app_detail.dart b/app/lib/pages/apps/app_detail/app_detail.dart index 2af59028f7..852bbca447 100644 --- a/app/lib/pages/apps/app_detail/app_detail.dart +++ b/app/lib/pages/apps/app_detail/app_detail.dart @@ -480,7 +480,7 @@ class _AppDetailPageState extends State { Column( children: [ RatingBar.builder( - initialRating: 4.2, + initialRating: widget.app.ratingAvg ?? 0, minRating: 1, ignoreGestures: true, direction: Axis.horizontal, @@ -494,7 +494,7 @@ class _AppDetailPageState extends State { onRatingUpdate: (rating) {}, ), const SizedBox(height: 4), - Text("${widget.app.ratingCount}+ ratings"), + Text(widget.app.ratingCount <= 0 ? "no ratings" : "${widget.app.ratingCount}+ ratings"), ], ), ], @@ -508,7 +508,7 @@ class _AppDetailPageState extends State { ), ), ), - !widget.app.isOwner(SharedPreferencesUtil().uid) + !widget.app.isOwner(SharedPreferencesUtil().uid) && (widget.app.enabled || widget.app.userReview != null) ? AddReviewWidget(app: widget.app) : const SizedBox.shrink(), // isIntegration ? const SizedBox(height: 16) : const SizedBox.shrink(), From 615b4198e9afd98a337a239cf3851e56d45bd978 Mon Sep 17 00:00:00 2001 From: Mohammed Mohsin <59914433+mdmohsin7@users.noreply.github.com> Date: Wed, 20 Nov 2024 12:39:17 +0530 Subject: [PATCH 2/5] minor ui changes --- .../pages/apps/app_detail/widgets/app_owner_review_card.dart | 2 +- app/lib/pages/apps/app_detail/widgets/user_review_card.dart | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/lib/pages/apps/app_detail/widgets/app_owner_review_card.dart b/app/lib/pages/apps/app_detail/widgets/app_owner_review_card.dart index f711082b58..066d6b603b 100644 --- a/app/lib/pages/apps/app_detail/widgets/app_owner_review_card.dart +++ b/app/lib/pages/apps/app_detail/widgets/app_owner_review_card.dart @@ -84,7 +84,7 @@ class _AppOwnerReviewCardState extends State { Text( timeago.format(widget.review.ratedAt), style: const TextStyle( - color: Colors.white, + color: Colors.grey, fontSize: 12, ), ), diff --git a/app/lib/pages/apps/app_detail/widgets/user_review_card.dart b/app/lib/pages/apps/app_detail/widgets/user_review_card.dart index f27218ae9e..26cf38962f 100644 --- a/app/lib/pages/apps/app_detail/widgets/user_review_card.dart +++ b/app/lib/pages/apps/app_detail/widgets/user_review_card.dart @@ -45,7 +45,7 @@ class UserReviewCard extends StatelessWidget { Text( timeago.format(review.ratedAt), style: const TextStyle( - color: Colors.white, + color: Colors.grey, fontSize: 12, ), ), From 99dbca058aee925f072f0a70ce82bf2c971ce7c3 Mon Sep 17 00:00:00 2001 From: Mohammed Mohsin <59914433+mdmohsin7@users.noreply.github.com> Date: Wed, 20 Nov 2024 12:39:37 +0530 Subject: [PATCH 3/5] show owner card if owner --- app/lib/pages/apps/app_detail/reviews_list_page.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/lib/pages/apps/app_detail/reviews_list_page.dart b/app/lib/pages/apps/app_detail/reviews_list_page.dart index 00b9bdfaf9..13d94dcdda 100644 --- a/app/lib/pages/apps/app_detail/reviews_list_page.dart +++ b/app/lib/pages/apps/app_detail/reviews_list_page.dart @@ -113,7 +113,7 @@ class _ReviewsListPageState extends State { physics: const NeverScrollableScrollPhysics(), itemCount: filteredReviews.length, itemBuilder: (context, index) { - if (!widget.app.isOwner(SharedPreferencesUtil().uid)) { + if (widget.app.isOwner(SharedPreferencesUtil().uid)) { return AppOwnerReviewCard( review: filteredReviews[index], appId: widget.app.id, From 7ff90e768d822af102c8bb9303ec874a6433ff43 Mon Sep 17 00:00:00 2001 From: Mohammed Mohsin <59914433+mdmohsin7@users.noreply.github.com> Date: Wed, 20 Nov 2024 12:40:20 +0530 Subject: [PATCH 4/5] retain old fields when updating review --- backend/routers/apps.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/backend/routers/apps.py b/backend/routers/apps.py index 11a944d53f..c81eaf72a9 100644 --- a/backend/routers/apps.py +++ b/backend/routers/apps.py @@ -158,13 +158,16 @@ def update_app_review(app_id: str, data: dict, uid: str = Depends(auth.get_curre if app.private and app.uid != uid: raise HTTPException(status_code=403, detail='You are not authorized to review this app') - + old_review = get_specific_user_review(app_id, uid) + if not old_review: + raise HTTPException(status_code=404, detail='Review not found') review_data = { 'score': data['score'], 'review': data.get('review', ''), - 'username': data.get('username', ''), - 'response': data.get('response', ''), 'updated_at': datetime.now(timezone.utc).isoformat(), + 'rated_at': old_review['rated_at'], + 'username': old_review['username'], + 'response': old_review['response'], 'uid': uid } set_app_review(app_id, uid, review_data) @@ -178,8 +181,8 @@ def reply_to_review(app_id: str, data: dict, uid: str = Depends(auth.get_current if not app: raise HTTPException(status_code=404, detail='App not found') - if app.uid != uid: - raise HTTPException(status_code=403, detail='You are not authorized to reply to this app review') + # if app.uid != uid: + # raise HTTPException(status_code=403, detail='You are not authorized to reply to this app review') if app.private and app.uid != uid: raise HTTPException(status_code=403, detail='You are not authorized to reply to this app review') From 760421e9e39921e9f7f004d8c1bcd9587a1c70e0 Mon Sep 17 00:00:00 2001 From: Mohammed Mohsin <59914433+mdmohsin7@users.noreply.github.com> Date: Wed, 20 Nov 2024 12:41:50 +0530 Subject: [PATCH 5/5] uncomment different uid check --- backend/routers/apps.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/routers/apps.py b/backend/routers/apps.py index c81eaf72a9..6e2719c849 100644 --- a/backend/routers/apps.py +++ b/backend/routers/apps.py @@ -181,8 +181,8 @@ def reply_to_review(app_id: str, data: dict, uid: str = Depends(auth.get_current if not app: raise HTTPException(status_code=404, detail='App not found') - # if app.uid != uid: - # raise HTTPException(status_code=403, detail='You are not authorized to reply to this app review') + if app.uid != uid: + raise HTTPException(status_code=403, detail='You are not authorized to reply to this app review') if app.private and app.uid != uid: raise HTTPException(status_code=403, detail='You are not authorized to reply to this app review')