feat(interaction): 支持游客点赞收藏评论
This commit is contained in:
1 parent
188811fde6
commit
a3d50eb935
18 files changed
+364
-121
No files matched your search
@@ -65,6 +65,11 @@ extension _PlayerViewActions on _PlayerPageState {
|
||||
) async {
|
||||
final wallet = logic.wallet;
|
||||
if (wallet == null) return;
|
||||
if (!context.read<AuthController>().isSignedIn &&
|
||||
!await ensureSignedIn(context)) {
|
||||
return;
|
||||
}
|
||||
if (!context.mounted) return;
|
||||
await showModalBottomSheet<bool>(
|
||||
context: context,
|
||||
backgroundColor: AppColors.transparent,
|
||||
@@ -81,7 +86,7 @@ extension _PlayerViewActions on _PlayerPageState {
|
||||
}
|
||||
|
||||
Future<bool> _unlockEpisode(BuildContext context, int index) async {
|
||||
if (!await ensureSignedIn(context) || !context.mounted) return false;
|
||||
if (!context.read<AuthController>().isSignedIn) return false;
|
||||
final ok = await logic.unlockEpisode(index);
|
||||
if (ok || !context.mounted) return ok;
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
@@ -119,27 +124,6 @@ extension _PlayerViewActions on _PlayerPageState {
|
||||
}
|
||||
return;
|
||||
}
|
||||
final signedIn = await ensureSignedIn(context);
|
||||
if (kDebugMode) {
|
||||
debugPrint(
|
||||
'[player-like] phase=auth-result '
|
||||
'episodeId=${episode.id} signedIn=$signedIn '
|
||||
'mounted=${context.mounted}',
|
||||
);
|
||||
}
|
||||
if (!signedIn || !context.mounted) return;
|
||||
final busyAfterAuth = interactions.isEpisodeBusy(episode.id);
|
||||
final likedAfterAuth = interactions.isEpisodeLiked(episode.id);
|
||||
if (busyAfterAuth || (likeOnly && likedAfterAuth)) {
|
||||
if (kDebugMode) {
|
||||
debugPrint(
|
||||
'[player-like] phase=toggle-skipped-after-auth '
|
||||
'episodeId=${episode.id} '
|
||||
'reason=${busyAfterAuth ? 'busy' : 'already-liked'}',
|
||||
);
|
||||
}
|
||||
return;
|
||||
}
|
||||
final result = await interactions.toggleEpisodeLike(episode.id);
|
||||
if (kDebugMode) {
|
||||
debugPrint(
|
||||
@@ -163,6 +147,10 @@ extension _PlayerViewActions on _PlayerPageState {
|
||||
return;
|
||||
}
|
||||
if (!context.mounted) return;
|
||||
if (result.errorCode == 200007) {
|
||||
await ensureSignedIn(context);
|
||||
return;
|
||||
}
|
||||
showCenteredToast(
|
||||
context,
|
||||
result.errorMessage ?? AppLocalizations.of(context)!.likeFailed,
|
||||
@@ -171,7 +159,6 @@ extension _PlayerViewActions on _PlayerPageState {
|
||||
|
||||
Future<void> _toggleSave(BuildContext context, Drama drama) async {
|
||||
final favorites = context.read<FavoriteController>();
|
||||
if (!await ensureSignedIn(context) || !context.mounted) return;
|
||||
unawaited(context.read<Haptics>().lightImpact());
|
||||
final wasSaved = favorites.isSaved(drama.id);
|
||||
final ok = await favorites.toggle(drama.id, card: drama);
|
||||
@@ -183,6 +170,10 @@ extension _PlayerViewActions on _PlayerPageState {
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (favorites.lastErrorCode == 200007) {
|
||||
await ensureSignedIn(context);
|
||||
return;
|
||||
}
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(AppLocalizations.of(context)!.favoriteToggleFailed),
|
||||
|
||||
Reference in new issue
Block a user