mirror of
https://github.com/venera-app/venera.git
synced 2025-09-27 07:47:24 +00:00
like a comic
This commit is contained in:
@@ -136,6 +136,7 @@ class ComicSourceParser {
|
||||
final favoriteData = _loadFavoriteData();
|
||||
final commentsLoader = _parseCommentsLoader();
|
||||
final sendCommentFunc = _parseSendCommentFunc();
|
||||
final likeFunc = _parseLikeFunc();
|
||||
|
||||
var source = ComicSource(
|
||||
_name!,
|
||||
@@ -158,6 +159,7 @@ class ComicSourceParser {
|
||||
version ?? "1.0.0",
|
||||
commentsLoader,
|
||||
sendCommentFunc,
|
||||
likeFunc,
|
||||
);
|
||||
|
||||
await source.loadData();
|
||||
@@ -654,4 +656,21 @@ class ComicSourceParser {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
LikeOrUnlikeComicFunc? _parseLikeFunc() {
|
||||
if (!_checkExists("comic.likeOrUnlikeComic")) {
|
||||
return null;
|
||||
}
|
||||
return (id, isLiking) async {
|
||||
try {
|
||||
await JsEngine().runCode("""
|
||||
ComicSource.sources.$_key.comic.likeOrUnlikeComic(${jsonEncode(id)}, ${jsonEncode(isLiking)})
|
||||
""");
|
||||
return const Res(true);
|
||||
} catch (e, s) {
|
||||
Log.error("Network", "$e\n$s");
|
||||
return Res.error(e.toString());
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user