fix: for the home screen error when first time open.
Some checks are pending
Build and Deploy / build_windows (push) Waiting to run
Build and Deploy / build_android (push) Waiting to run
Build and Deploy / build_android_tv (push) Waiting to run
Build and Deploy / build_ipa (push) Waiting to run
Build and Deploy / build_linux (push) Waiting to run
Build and Deploy / build_macos (push) Waiting to run

This commit is contained in:
omkar 2025-01-12 00:49:47 +05:30
parent fbea109161
commit e772a2b815
9 changed files with 40 additions and 8 deletions

View file

@ -178,9 +178,11 @@ class StremioConnectionService extends BaseConnectionService {
try {
_logger.finer('Fetching catalog from URL: $url');
final httpBody = await http.get(Uri.parse(url));
return StrmioMeta.fromJson(jsonDecode(httpBody.body));
return StrmioMeta.fromJson(
jsonDecode(httpBody.body),
);
} catch (e, stack) {
_logger.severe('Error parsing catalog', e, stack);
_logger.severe('Error parsing catalog $url', e, stack);
rethrow;
}
},

View file

@ -70,8 +70,8 @@ class _StremioItemSeasonSelectorState extends State<StremioItemSeasonSelector>
final traktService = TraktService.instance;
try {
if (traktService!.isEnabled()) {
final result = await traktService.getProgress(widget.meta);
if (TraktService.isEnabled()) {
final result = await traktService!.getProgress(widget.meta);
for (final item in result) {
if (!_traktProgress.containsKey(item.season)) {

View file

@ -193,7 +193,7 @@ class _VideoViewerState extends State<VideoViewer> {
canCallOnce = true;
if (!TraktService.instance!.isEnabled() || traktProgress == null) {
if (!TraktService.isEnabled() || traktProgress == null) {
player.play();
return;
}

View file

@ -0,0 +1,12 @@
import 'package:flutter/material.dart';
class VideoViewerUi extends StatelessWidget {
const VideoViewerUi({
super.key,
});
@override
Widget build(BuildContext context) {
return Container();
}
}

View file

@ -291,6 +291,7 @@ class _CreateConnectionStepState extends State<CreateConnectionStep> {
final Map<String, String> _items = {
"Cinemeta": "https://v3-cinemeta.strem.io/manifest.json",
"Watchhub": "https://watchhub.strem.io/manifest.json",
"Subtitles": "https://opensubtitles-v3.strem.io/manifest.json",
};
void _removeAddon(int index) {

View file

@ -581,7 +581,7 @@ class TraktService {
return config;
}
bool isEnabled() {
static bool isEnabled() {
return AppEngine.engine.pb.authStore.record!
.getStringValue("trakt_token") !=
"";

View file

@ -35,7 +35,14 @@ class HomeTabPage extends StatefulWidget {
class _HomeTabPageState extends State<HomeTabPage> {
late final query = Query(
queryFn: () async {
await TraktService.ensureInitialized();
try {
if (TraktService.isEnabled() == true) {
await TraktService.ensureInitialized();
}
} catch (e, stack) {
print(e);
print(stack);
}
if (widget.defaultLibraries != null) {
return Future.value(

10
lib/utils/common.dart Normal file
View file

@ -0,0 +1,10 @@
extension FirstWhereOrNullExtension<T> on Iterable<T> {
T? firstWhereOrNull(bool Function(T) test) {
for (var element in this) {
if (test(element)) {
return element;
}
}
return null;
}
}

View file

@ -918,7 +918,7 @@ packages:
source: hosted
version: "4.0.0"
logging:
dependency: transitive
dependency: "direct main"
description:
name: logging
sha256: c8245ada5f1717ed44271ed1c26b8ce85ca3228fd2ffdb75468ab01979309d61