mirror of
https://github.com/madari-media/madari-oss.git
synced 2026-01-11 22:40:23 +00:00
fix: catalog fixes
This commit is contained in:
parent
3f8f9449ea
commit
4b95941e4a
6 changed files with 120 additions and 48 deletions
|
|
@ -2,6 +2,7 @@ import 'package:cached_query_flutter/cached_query_flutter.dart';
|
|||
import 'package:cached_storage/cached_storage.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:madari_client/features/settings/service/selected_profile.dart';
|
||||
import 'package:media_kit/media_kit.dart';
|
||||
import 'package:universal_platform/universal_platform.dart';
|
||||
import 'package:window_manager/window_manager.dart';
|
||||
|
|
@ -17,6 +18,8 @@ Future startupApp() async {
|
|||
|
||||
await AppPocketBaseService.ensureInitialized();
|
||||
|
||||
await SelectedProfileService.instance.initialize();
|
||||
|
||||
if (UniversalPlatform.isDesktop) {
|
||||
await windowManager.ensureInitialized();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -133,16 +133,54 @@ class StremioManifestCatalog {
|
|||
String id;
|
||||
String? name;
|
||||
final List<StremioManifestCatalogExtra>? extra;
|
||||
final List<String>? extraRequired;
|
||||
final List<String>? extraSupported;
|
||||
@JsonKey(name: "extraRequired")
|
||||
final List<String>? extraRequired_;
|
||||
@JsonKey(name: "extraSupported")
|
||||
final List<String>? extraSupported_;
|
||||
|
||||
List<String>? get extraRequired {
|
||||
final List<String> returnValue = extraRequired_ ?? [];
|
||||
|
||||
if (extra == null) {
|
||||
return extraRequired_;
|
||||
}
|
||||
|
||||
for (final i in extra!) {
|
||||
final result = returnValue.contains(i.name);
|
||||
|
||||
if (i.isRequired == true && !result) {
|
||||
returnValue.add(i.name);
|
||||
}
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
List<String>? get extraSupported {
|
||||
final List<String> returnValue = extraSupported_ ?? [];
|
||||
|
||||
if (extra == null) {
|
||||
return extraSupported_;
|
||||
}
|
||||
|
||||
for (final i in extra!) {
|
||||
final result = returnValue.contains(i.name);
|
||||
|
||||
if (!result) {
|
||||
returnValue.add(i.name);
|
||||
}
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
StremioManifestCatalog({
|
||||
required this.id,
|
||||
required this.type,
|
||||
this.extra,
|
||||
this.name,
|
||||
this.extraRequired,
|
||||
this.extraSupported,
|
||||
this.extraRequired_,
|
||||
this.extraSupported_,
|
||||
});
|
||||
|
||||
factory StremioManifestCatalog.fromRecord(RecordModel record) =>
|
||||
|
|
@ -151,17 +189,26 @@ class StremioManifestCatalog {
|
|||
factory StremioManifestCatalog.fromJson(Map<String, dynamic> json) =>
|
||||
_$StremioManifestCatalogFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$StremioManifestCatalogToJson(this);
|
||||
Map<String, dynamic> toJson() {
|
||||
final result = _$StremioManifestCatalogToJson(this);
|
||||
|
||||
result["extraRequired"] = extraRequired;
|
||||
result["extraSupported"] = extraSupported;
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@JsonSerializable()
|
||||
class StremioManifestCatalogExtra {
|
||||
final String name;
|
||||
final List<dynamic>? options;
|
||||
final bool? isRequired;
|
||||
|
||||
StremioManifestCatalogExtra({
|
||||
required this.name,
|
||||
required this.options,
|
||||
this.isRequired,
|
||||
});
|
||||
|
||||
factory StremioManifestCatalogExtra.fromJson(Map<String, dynamic> json) {
|
||||
|
|
|
|||
|
|
@ -296,15 +296,6 @@ class StremioAddonService {
|
|||
return [];
|
||||
}
|
||||
|
||||
if (page != null && catalog.extraSupported?.contains("skip") == true) {
|
||||
items.add(
|
||||
ConnectionFilterItem(
|
||||
title: "skip",
|
||||
value: page * perPage,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (page != null && catalog.extraSupported?.contains("region") == true) {
|
||||
final region = AppPocketBaseService.instance.pb.authStore.record!
|
||||
.getStringValue("region");
|
||||
|
|
@ -370,6 +361,22 @@ class StremioAddonService {
|
|||
}
|
||||
}
|
||||
|
||||
final isSearch = items.firstWhereOrNull((item) {
|
||||
return item.title == "search";
|
||||
}) !=
|
||||
null;
|
||||
|
||||
if (page != null &&
|
||||
catalog.extraSupported?.contains("skip") == true &&
|
||||
!isSearch) {
|
||||
items.add(
|
||||
ConnectionFilterItem(
|
||||
title: "skip",
|
||||
value: page * perPage,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
final httpBody = await http.get(Uri.parse(url));
|
||||
_logger.info("getting catalog from $url");
|
||||
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ class LayoutManagerState extends State<LayoutManager> {
|
|||
try {
|
||||
_logger.info('Loading layouts');
|
||||
final query = Query(
|
||||
key: "home_layout_${SelectedProfileService.instance.selectedProfileId}",
|
||||
key: "home_layout_${SelectedProfileService.instance.selectedProfileId}${widget.hasSearch}",
|
||||
config: QueryConfig(
|
||||
ignoreCacheDuration: refresh,
|
||||
cacheDuration: const Duration(hours: 8),
|
||||
|
|
@ -117,39 +117,40 @@ class LayoutManagerState extends State<LayoutManager> {
|
|||
const SearchBox(
|
||||
hintText: 'Search...',
|
||||
),
|
||||
Expanded(
|
||||
child: CustomScrollView(
|
||||
controller: _scrollController,
|
||||
slivers: [
|
||||
SliverList(
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(context, index) {
|
||||
final layout = _filteredLayouts[index];
|
||||
if (!widget.hasSearch || search.trim() != "")
|
||||
Expanded(
|
||||
child: CustomScrollView(
|
||||
controller: _scrollController,
|
||||
slivers: [
|
||||
SliverList(
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(context, index) {
|
||||
final layout = _filteredLayouts[index];
|
||||
|
||||
if (widget.hasSearch) {
|
||||
if (!(layout.pluginId == "stremio_catalog" &&
|
||||
layout.type == "catalog_grid")) {
|
||||
return const SizedBox.shrink();
|
||||
if (widget.hasSearch) {
|
||||
if (!(layout.pluginId == "stremio_catalog" &&
|
||||
layout.type == "catalog_grid")) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return PluginWidget(
|
||||
key: ValueKey(
|
||||
'${layout.id}_${layout.pluginId}_${layout.type}_${search.trim()}',
|
||||
),
|
||||
layout: layout,
|
||||
pluginContext: PluginContext(
|
||||
index: index,
|
||||
hasSearch: widget.hasSearch,
|
||||
),
|
||||
);
|
||||
},
|
||||
childCount: _filteredLayouts.length,
|
||||
return PluginWidget(
|
||||
key: ValueKey(
|
||||
'${layout.id}_${layout.pluginId}_${layout.type}_${search.trim()}',
|
||||
),
|
||||
layout: layout,
|
||||
pluginContext: PluginContext(
|
||||
index: index,
|
||||
hasSearch: widget.hasSearch,
|
||||
),
|
||||
);
|
||||
},
|
||||
childCount: _filteredLayouts.length,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import 'package:flex_color_picker/flex_color_picker.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:madari_client/features/pocketbase/service/pocketbase.service.dart';
|
||||
import 'package:madari_client/features/streamio_addons/extension/query_extension.dart';
|
||||
|
||||
|
|
@ -16,10 +17,23 @@ class StremioCatalogPlugin extends PluginBase {
|
|||
|
||||
@override
|
||||
Map<String, WidgetFactory> get widgetFactories => {
|
||||
'catalog_grid': (config, pluginContext) => CatalogGrid(
|
||||
config: config,
|
||||
pluginContext: pluginContext,
|
||||
),
|
||||
'catalog_grid': (config, pluginContext) {
|
||||
if (pluginContext.hasSearch) {
|
||||
if (config["can_search"]) {
|
||||
return CatalogGrid(
|
||||
config: config,
|
||||
pluginContext: pluginContext,
|
||||
);
|
||||
}
|
||||
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
|
||||
return CatalogGrid(
|
||||
config: config,
|
||||
pluginContext: pluginContext,
|
||||
);
|
||||
},
|
||||
'catalog_grid_big': (config, pluginContext) => CatalogGrid(
|
||||
config: config,
|
||||
isWide: true,
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ class _CatalogGridState extends State<CatalogGrid> implements Refreshable {
|
|||
|
||||
List<ConnectionFilterItem> items = [];
|
||||
|
||||
if (state.search.trim() != "") {
|
||||
if (state.search.trim() != "" && widget.pluginContext.hasSearch) {
|
||||
items.add(
|
||||
ConnectionFilterItem(
|
||||
title: "search",
|
||||
|
|
|
|||
Loading…
Reference in a new issue