outsourced lots of api calls to api folder
centered error message when failed loading video feed display server url on settings page
This commit is contained in:
@ -1,10 +1,6 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../api/actor_api.dart';
|
||||
import '../api/api.dart';
|
||||
import '../log/log.dart';
|
||||
import '../screen_loading.dart';
|
||||
import '../types/actor.dart';
|
||||
|
||||
@ -19,16 +15,6 @@ class AddActorDialog extends StatefulWidget {
|
||||
class _AddActorDialogState extends State<AddActorDialog> {
|
||||
late Future<List<Actor>> actors = loadAllActors();
|
||||
|
||||
Future<void> addActorToVideo(int actorId) async {
|
||||
final data = await API.query("actor", "addActorToVideo",
|
||||
{'ActorId': actorId, 'MovieId': widget.movieId});
|
||||
|
||||
final d = jsonDecode(data);
|
||||
if (d["result"] != "success") {
|
||||
Log.w("couldn't add actor to video");
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@ -52,7 +38,7 @@ class _AddActorDialogState extends State<AddActorDialog> {
|
||||
.map((e) => ListTile(
|
||||
title: Text(e.name),
|
||||
onTap: () async {
|
||||
await addActorToVideo(e.actorId);
|
||||
await addActorToVideo(e.actorId, widget.movieId);
|
||||
Navigator.pop(context, e);
|
||||
},
|
||||
))
|
||||
|
@ -1,9 +1,6 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../api/api.dart';
|
||||
import '../log/log.dart';
|
||||
import '../api/tag_api.dart';
|
||||
import '../screen_loading.dart';
|
||||
import '../types/tag.dart';
|
||||
|
||||
@ -18,24 +15,6 @@ class AddTagDialog extends StatefulWidget {
|
||||
class _AddTagDialogState extends State<AddTagDialog> {
|
||||
late Future<List<Tag>> tags = loadAllTags();
|
||||
|
||||
Future<List<Tag>> loadAllTags() async {
|
||||
final data = await API.query("tags", "getAllTags", {});
|
||||
|
||||
final d = (jsonDecode(data) ?? []) as List<dynamic>;
|
||||
final tags = d.map((e) => Tag.fromJson(e)).toList(growable: false);
|
||||
return tags;
|
||||
}
|
||||
|
||||
Future<void> addTagToVideo(int tagId) async {
|
||||
final data = await API
|
||||
.query("tags", "addTag", {'TagId': tagId, 'MovieId': widget.movieId});
|
||||
|
||||
final d = jsonDecode(data);
|
||||
if (d["result"] != "success") {
|
||||
Log.w("couldn't add actor to video");
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@ -60,7 +39,7 @@ class _AddTagDialogState extends State<AddTagDialog> {
|
||||
(e) => ListTile(
|
||||
title: Text(e.tagName),
|
||||
onTap: () async {
|
||||
await addTagToVideo(e.tagId);
|
||||
await addTagToVideo(e.tagId, widget.movieId);
|
||||
Navigator.pop(context, e);
|
||||
},
|
||||
),
|
||||
|
Reference in New Issue
Block a user