Skip to content

Commit

Permalink
fix issue when video autoplay is enabled, it would not browse back to…
Browse files Browse the repository at this point in the history
… video lists

fix #338
  • Loading branch information
lamarios committed Nov 30, 2023
1 parent 3c4b99c commit f0b0f22
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 1 addition & 3 deletions lib/videos/states/video.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:copy_with_extension/copy_with_extension.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:invidious/downloads/models/downloaded_video.dart';
import 'package:invidious/router.dart';
import 'package:invidious/videos/models/base_video.dart';
import 'package:invidious/videos/models/dislike.dart';
import 'package:logging/logging.dart';
Expand Down Expand Up @@ -43,9 +44,6 @@ class VideoCubit extends Cubit<VideoState> {

getDownloadStatus();

if (settings.state.autoplayVideoOnLoad) {
playVideo(false);
}
} catch (err) {
var state = this.state.copyWith();
if (err is InvidiousServiceError) {
Expand Down
7 changes: 6 additions & 1 deletion lib/videos/views/screens/video.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,12 @@ class VideoScreen extends StatelessWidget {
create: (BuildContext context) =>
VideoCubit(VideoState(videoId: videoId), downloadManager, player, settings)),
],
child: BlocBuilder<VideoCubit, VideoState>(
child: BlocConsumer<VideoCubit, VideoState>(
listenWhen: (previous, current) => settings.state.autoplayVideoOnLoad && previous.video != current.video,
listener: (context, state) {
AutoRouter.of(context).pop();
context.read<VideoCubit>().playVideo(false);
},
builder: (context, _) {
var cubit = context.read<VideoCubit>();
var settings = context.read<SettingsCubit>();
Expand Down

0 comments on commit f0b0f22

Please sign in to comment.