Skip to content

Commit

Permalink
Optimize the toast message when canceling favorites
Browse files Browse the repository at this point in the history
优化取消收藏时的文案
  • Loading branch information
jiangtian616 committed Dec 8, 2023
1 parent f9f5983 commit f8e343a
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 9 deletions.
4 changes: 3 additions & 1 deletion changelog/v7.4.8+147.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
- 修复在部分场景下,自动阅读模式无法滚动到末尾的bug
- 优化取消收藏时的文案

------------------------------------------------------------------------------------------

- Fix the bug that auto reading mode cannot scroll to the end in some scenes
- Fix the bug that auto reading mode cannot scroll to the end in some scenes
- Optimize the toast message when canceling favorites
2 changes: 2 additions & 0 deletions lib/src/l18n/en_US.dart
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ class en_US {
'failToGetThumbnails': "Fail To Get Thumbnails",
'favoriteGallerySuccess': "Favorite Gallery Success",
'favoriteGalleryFailed': "Favorite Gallery Failed",
'removeFavoriteSuccess': "Remove Favorite Success",
'removeFavoriteFailed': "Remove Favorite Failed",
'ratingSuccess': 'Rating Success',
'ratingFailed': 'Rating Failed',
'voteTagFailed': 'Vote Tag Failed',
Expand Down
2 changes: 2 additions & 0 deletions lib/src/l18n/ko_KR.dart
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ class ko_KR {
'failToGetThumbnails': "섬네일 가져오기 실패",
'favoriteGallerySuccess': "즐겨찾기 저장 성공",
'favoriteGalleryFailed': "즐겨찾기 저장 실패",
'removeFavoriteSuccess': "Remove Favorite Success",
'removeFavoriteFailed': "Remove Favorite Failed",
'ratingSuccess': '평가 성공',
'ratingFailed': '평가 실패',
'voteTagFailed': '태그 투표 실패',
Expand Down
2 changes: 2 additions & 0 deletions lib/src/l18n/pt_BR.dart
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ class pt_BR {
'failToGetThumbnails': "Falha ao obter miniaturas",
'favoriteGallerySuccess': "Favorite Gallery Success",
'favoriteGalleryFailed': "Falha na galeria Favorita",
'removeFavoriteSuccess': "Remove Favorite Success",
'removeFavoriteFailed': "Remove Favorite Failed",
'ratingSuccess': 'Rating Success',
'ratingFailed': 'Falha na avaliação',
'voteTagFailed': 'Falha na tag de votação',
Expand Down
4 changes: 3 additions & 1 deletion lib/src/l18n/zh_CN.dart
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ class zh_CN {
'refreshGalleryDetailsFailed': '刷新画廊详情失败',
'failToGetThumbnails': "获取画廊缩略图数据失败",
'favoriteGallerySuccess': "收藏画廊成功",
'favoriteGalleryFailed': "收藏画廊错误",
'favoriteGalleryFailed': "收藏画廊失败",
'removeFavoriteSuccess': "取消收藏成功",
'removeFavoriteFailed': "取消收藏失败",
'ratingSuccess': '评分成功',
'ratingFailed': '评分失败',
'voteTagFailed': '投票标签失败',
Expand Down
4 changes: 3 additions & 1 deletion lib/src/l18n/zh_TW.dart
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ class zh_TW {
'refreshGalleryDetailsFailed': '重整畫廊詳情失敗',
'failToGetThumbnails': "獲取畫廊快取圖數據失敗",
'favoriteGallerySuccess': "收藏畫廊成功",
'favoriteGalleryFailed': "收藏畫廊錯誤",
'favoriteGalleryFailed': "收藏畫廊失敗",
'removeFavoriteSuccess': "取消收藏成功",
'removeFavoriteFailed': "取消收藏失敗",
'ratingSuccess': '評分成功',
'ratingFailed': '評分失敗',
'voteTagFailed': '投票標籤失敗',
Expand Down
16 changes: 10 additions & 6 deletions lib/src/pages/details/details_page_logic.dart
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,9 @@ class DetailsPageLogic extends GetxController with LoginRequiredMixin, Scroll2To
state.favoriteState = LoadingState.loading;
updateSafely([addFavoriteStateId]);

bool isRemoveFavorite = favIndex == state.gallery?.favoriteTagIndex;
try {
if (favIndex == state.gallery?.favoriteTagIndex) {
if (isRemoveFavorite) {
await EHRequest.requestRemoveFavorite(state.gallery!.gid, state.gallery!.token);
FavoriteSetting.decrementFavByIndex(favIndex);
state.gallery!
Expand All @@ -336,14 +337,14 @@ class DetailsPageLogic extends GetxController with LoginRequiredMixin, Scroll2To

FavoriteSetting.save();
} on DioError catch (e) {
Log.error('favoriteGalleryFailed'.tr, e.message);
snack('favoriteGalleryFailed'.tr, e.message, longDuration: true);
Log.error(isRemoveFavorite ? 'removeFavoriteFailed'.tr : 'favoriteGalleryFailed'.tr, e.message);
snack(isRemoveFavorite ? 'removeFavoriteFailed'.tr : 'favoriteGalleryFailed'.tr, e.message, longDuration: true);
state.favoriteState = LoadingState.error;
updateSafely([addFavoriteStateId]);
return;
} on EHException catch (e) {
Log.error('favoriteGalleryFailed'.tr, e.message);
snack('favoriteGalleryFailed'.tr, e.message, longDuration: true);
Log.error(isRemoveFavorite ? 'removeFavoriteFailed'.tr : 'favoriteGalleryFailed'.tr, e.message);
snack(isRemoveFavorite ? 'removeFavoriteFailed'.tr : 'favoriteGalleryFailed'.tr, e.message, longDuration: true);
state.favoriteState = LoadingState.error;
updateSafely([addFavoriteStateId]);
return;
Expand All @@ -356,7 +357,10 @@ class DetailsPageLogic extends GetxController with LoginRequiredMixin, Scroll2To

updateGlobalGalleryStatus();

toast('favoriteGallerySuccess'.tr, isCenter: false);
toast(
isRemoveFavorite ? 'removeFavoriteSuccess'.tr : 'favoriteGallerySuccess'.tr,
isCenter: false,
);
}

Future<void> handleTapRating() async {
Expand Down

0 comments on commit f8e343a

Please sign in to comment.