Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handles upcoming videos #613

Merged
merged 2 commits into from
Oct 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[ ] I have updated the version and build number accordingly
- [ ] I have updated the version and build number accordingly

## Tests

These are things that are most likely to break when making changes unrelated changes

[ ] Can play video
[ ] New user experience, the set up wizard should show up if the user has no data
- [ ] Can play video
- [ ] New user experience, the set up wizard should show up if the user has no data

4 changes: 2 additions & 2 deletions lib/channels/models/channel.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:clipious/settings/models/db/server.dart';
import 'package:clipious/utils/models/sharelink.dart';
import 'package:clipious/videos/models/video_in_list.dart';
import 'package:clipious/videos/models/video.dart';
import 'package:json_annotation/json_annotation.dart';

import '../../utils/models/image_object.dart';
Expand All @@ -22,7 +22,7 @@ class Channel implements ShareLinks {
String description;

List<String>? allowedRegions;
List<VideoInList>? latestVideos;
List<Video>? latestVideos;

Channel(
this.author,
Expand Down
2 changes: 1 addition & 1 deletion lib/channels/models/channel.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions lib/channels/models/channel_videos.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import 'package:clipious/videos/models/video_in_list.dart';
import 'package:clipious/videos/models/video.dart';
import 'package:json_annotation/json_annotation.dart';

import '../../utils/models/item_with_continuation.dart';

part 'channel_videos.g.dart';

@JsonSerializable()
class VideosWithContinuation extends ItemtWithContinuation<VideoInList> {
List<VideoInList> videos;
class VideosWithContinuation extends ItemtWithContinuation<Video> {
List<Video> videos;

VideosWithContinuation(this.videos, String? continuation)
: super(continuation);
Expand All @@ -18,7 +18,7 @@ class VideosWithContinuation extends ItemtWithContinuation<VideoInList> {
Map<String, dynamic> toJson() => _$VideosWithContinuationToJson(this);

@override
List<VideoInList> getItems() {
List<Video> getItems() {
return videos;
}
}
2 changes: 1 addition & 1 deletion lib/channels/models/channel_videos.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 1 addition & 16 deletions lib/channels/views/components/info.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import 'package:url_launcher/url_launcher.dart';

import '../../../subscription_management/view/components/subscribe_button.dart';
import '../../../utils/models/image_object.dart';
import '../../../videos/models/video_in_list.dart';
import '../../../videos/views/components/video_in_list.dart';
import '../../../videos/views/components/video_thumbnail.dart';

Expand Down Expand Up @@ -85,22 +84,8 @@ class ChannelInfo extends StatelessWidget {
mainAxisSpacing: 5,
childAspectRatio: getGridAspectRatio(context),
children: channel.latestVideos?.map((e) {
VideoInList videoInList = VideoInList(
e.title,
e.videoId,
e.lengthSeconds,
0,
e.author,
channel.authorId,
channel.authorId,
0,
'',
e.videoThumbnails)
..deArrowThumbnailUrl = e.deArrowThumbnailUrl;
videoInList.filtered = e.filtered;
videoInList.matchedFilters = e.matchedFilters;
return VideoListItem(
video: videoInList,
video: e,
);
}).toList() ??
[]));
Expand Down
4 changes: 2 additions & 2 deletions lib/channels/views/components/videos.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import 'dart:async';

import 'package:clipious/videos/models/video.dart';
import 'package:flutter/material.dart';
import 'package:clipious/channels/models/channel_videos.dart';
import 'package:clipious/globals.dart';
import 'package:clipious/videos/models/video_in_list.dart';
import 'package:clipious/videos/views/components/video_list.dart';

import '../../../utils/models/paginated_list.dart';
Expand All @@ -25,7 +25,7 @@ class ChannelVideosView extends StatelessWidget {
child: Container(
color: colorScheme.surface,
child: VideoList(
paginatedVideoList: ContinuationList<VideoInList>(
paginatedVideoList: ContinuationList<Video>(
(continuation) => getVideos(channel.authorId, continuation)),
// tags: 'channel-video-list-${(key as ValueKey<String>).value}'
),
Expand Down
77 changes: 34 additions & 43 deletions lib/channels/views/tv/screens/channel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'dart:ui';

import 'package:auto_route/annotations.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:clipious/videos/models/video.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
Expand All @@ -15,7 +16,6 @@ import 'package:clipious/utils/views/components/placeholders.dart';
import 'package:clipious/utils/views/tv/components/tv_expandable_text.dart';
import 'package:clipious/utils/views/tv/components/tv_horizontal_item_list.dart';
import 'package:clipious/utils/views/tv/components/tv_overscan.dart';
import 'package:clipious/videos/models/video_in_list.dart';

import '../../../../playlists/models/playlist.dart';
import '../../../../playlists/views/components/playlist_in_list.dart';
Expand Down Expand Up @@ -181,26 +181,21 @@ class TvChannelScreen extends StatelessWidget {
TvHorizontalVideoList(
onItemFocus:
(video, index, focus) =>
tvCubit
.scrollTo(
tvCubit
.videosTitle,
focus),
tvCubit.scrollTo(
tvCubit.videosTitle,
focus),
paginatedVideoList: ContinuationList<
VideoInList>(
(continuation) =>
service
.getChannelVideos(
channel.channel
?.authorId ??
'',
continuation)
.then((value) {
tvCubit.setHasVideos(
value.videos
.isNotEmpty);
return value;
}))),
Video>((continuation) => service
.getChannelVideos(
channel.channel
?.authorId ??
'',
continuation)
.then((value) {
tvCubit.setHasVideos(value
.videos.isNotEmpty);
return value;
}))),
tv.hasShorts
? Padding(
key: tvCubit.shortTitle,
Expand All @@ -217,26 +212,21 @@ class TvChannelScreen extends StatelessWidget {
TvHorizontalVideoList(
onItemFocus:
(video, index, focus) =>
tvCubit
.scrollTo(
tvCubit
.shortTitle,
focus),
tvCubit.scrollTo(
tvCubit.shortTitle,
focus),
paginatedVideoList: ContinuationList<
VideoInList>(
(continuation) =>
service
.getChannelShorts(
channel.channel
?.authorId ??
'',
continuation)
.then((value) {
tvCubit.setHasShorts(
value.videos
.isNotEmpty);
return value;
}))),
Video>((continuation) => service
.getChannelShorts(
channel.channel
?.authorId ??
'',
continuation)
.then((value) {
tvCubit.setHasShorts(value
.videos.isNotEmpty);
return value;
}))),
tv.hasStreams
? Padding(
key: tvCubit.streamTitle,
Expand All @@ -251,13 +241,14 @@ class TvChannelScreen extends StatelessWidget {
)
: const SizedBox.shrink(),
TvHorizontalVideoList(
onItemFocus:
(video, index, focus) =>
tvCubit.scrollTo(
onItemFocus: (video, index,
focus) =>
tvCubit
.scrollTo(
tvCubit.streamTitle,
focus),
paginatedVideoList: ContinuationList<
VideoInList>(
Video>(
(continuation) => service
.getChannelStreams(
channel.channel
Expand Down
6 changes: 3 additions & 3 deletions lib/comments/states/comments.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:bloc/bloc.dart';
import 'package:clipious/videos/models/video.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:clipious/comments/models/video_comments.dart';
import 'package:clipious/videos/models/base_video.dart';

import '../../globals.dart';
import '../../settings/models/errors/invidious_service_error.dart';
Expand Down Expand Up @@ -66,7 +66,7 @@ class CommentsCubit extends Cubit<CommentsState> {
@freezed
class CommentsState with _$CommentsState {
const factory CommentsState(
{required BaseVideo video,
{required Video video,
@Default(true) bool loadingComments,
String? continuation,
@Default(false) bool continuationLoaded,
Expand All @@ -76,7 +76,7 @@ class CommentsState with _$CommentsState {
String? sortBy}) = _CommentsState;

static CommentsState init(
{required BaseVideo video,
{required Video video,
bool? loadingComments,
String? continuation,
bool? continuationLoaded,
Expand Down
31 changes: 23 additions & 8 deletions lib/comments/states/comments.freezed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ final _privateConstructorUsedError = UnsupportedError(

/// @nodoc
mixin _$CommentsState {
BaseVideo get video => throw _privateConstructorUsedError;
Video get video => throw _privateConstructorUsedError;
bool get loadingComments => throw _privateConstructorUsedError;
String? get continuation => throw _privateConstructorUsedError;
bool get continuationLoaded => throw _privateConstructorUsedError;
Expand All @@ -39,14 +39,16 @@ abstract class $CommentsStateCopyWith<$Res> {
_$CommentsStateCopyWithImpl<$Res, CommentsState>;
@useResult
$Res call(
{BaseVideo video,
{Video video,
bool loadingComments,
String? continuation,
bool continuationLoaded,
VideoComments comments,
String error,
String? source,
String? sortBy});

$VideoCopyWith<$Res> get video;
}

/// @nodoc
Expand Down Expand Up @@ -77,7 +79,7 @@ class _$CommentsStateCopyWithImpl<$Res, $Val extends CommentsState>
video: null == video
? _value.video
: video // ignore: cast_nullable_to_non_nullable
as BaseVideo,
as Video,
loadingComments: null == loadingComments
? _value.loadingComments
: loadingComments // ignore: cast_nullable_to_non_nullable
Expand Down Expand Up @@ -108,6 +110,16 @@ class _$CommentsStateCopyWithImpl<$Res, $Val extends CommentsState>
as String?,
) as $Val);
}

/// Create a copy of CommentsState
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$VideoCopyWith<$Res> get video {
return $VideoCopyWith<$Res>(_value.video, (value) {
return _then(_value.copyWith(video: value) as $Val);
});
}
}

/// @nodoc
Expand All @@ -119,14 +131,17 @@ abstract class _$$CommentsStateImplCopyWith<$Res>
@override
@useResult
$Res call(
{BaseVideo video,
{Video video,
bool loadingComments,
String? continuation,
bool continuationLoaded,
VideoComments comments,
String error,
String? source,
String? sortBy});

@override
$VideoCopyWith<$Res> get video;
}

/// @nodoc
Expand Down Expand Up @@ -155,7 +170,7 @@ class __$$CommentsStateImplCopyWithImpl<$Res>
video: null == video
? _value.video
: video // ignore: cast_nullable_to_non_nullable
as BaseVideo,
as Video,
loadingComments: null == loadingComments
? _value.loadingComments
: loadingComments // ignore: cast_nullable_to_non_nullable
Expand Down Expand Up @@ -202,7 +217,7 @@ class _$CommentsStateImpl implements _CommentsState {
this.sortBy});

@override
final BaseVideo video;
final Video video;
@override
@JsonKey()
final bool loadingComments;
Expand Down Expand Up @@ -260,7 +275,7 @@ class _$CommentsStateImpl implements _CommentsState {

abstract class _CommentsState implements CommentsState {
const factory _CommentsState(
{required final BaseVideo video,
{required final Video video,
final bool loadingComments,
final String? continuation,
final bool continuationLoaded,
Expand All @@ -270,7 +285,7 @@ abstract class _CommentsState implements CommentsState {
final String? sortBy}) = _$CommentsStateImpl;

@override
BaseVideo get video;
Video get video;
@override
bool get loadingComments;
@override
Expand Down
4 changes: 2 additions & 2 deletions lib/comments/views/components/comment.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:auto_route/auto_route.dart';
import 'package:clipious/videos/models/video.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
Expand All @@ -10,12 +11,11 @@ import 'package:clipious/videos/views/components/video_thumbnail.dart';

import '../../../player/states/player.dart';
import '../../../utils/models/image_object.dart';
import '../../../videos/models/base_video.dart';
import '../../models/comment.dart';

class SingleCommentView extends StatelessWidget {
final Comment comment;
final BaseVideo video;
final Video video;

const SingleCommentView(
{super.key, required this.comment, required this.video});
Expand Down
Loading
Loading