diff --git a/lib/http/common.dart b/lib/http/common.dart index d711a7e7..fac65dbf 100644 --- a/lib/http/common.dart +++ b/lib/http/common.dart @@ -2,14 +2,19 @@ import 'index.dart'; class CommonHttp { static Future unReadDynamic() async { - var res = await Request().get(Api.getUnreadDynamic, - data: {'alltype_offset': 0, 'video_offset': '', 'article_offset': 0}); + var res = await Request().get(Api.getUnreadDynamic, data: { + 'alltype_offset': 0, + 'video_offset': 0, + 'article_offset': 0, + }); if (res.data['code'] == 0) { - return {'status': true, 'data': res.data['data']['dyn_basic_infos']}; + return { + 'status': true, + 'data': res.data['data']['update_info']['item']['count'] + }; } else { return { 'status': false, - 'data': [], 'msg': res.data['message'], }; } diff --git a/lib/pages/main/controller.dart b/lib/pages/main/controller.dart index fdb732f4..4de5df69 100644 --- a/lib/pages/main/controller.dart +++ b/lib/pages/main/controller.dart @@ -1,9 +1,11 @@ import 'dart:async'; import 'package:PiliPalaX/grpc/grpc_repo.dart'; +import 'package:PiliPalaX/http/common.dart'; import 'package:PiliPalaX/pages/dynamics/view.dart'; import 'package:PiliPalaX/pages/home/view.dart'; import 'package:PiliPalaX/pages/media/view.dart'; +import 'package:PiliPalaX/utils/global_data.dart'; import 'package:get/get.dart'; import 'package:flutter/material.dart'; import 'package:hive/hive.dart'; @@ -57,11 +59,19 @@ class MainController extends GetxController { if (!userLogin.value || dynIndex == -1) { return; } - await GrpcRepo.dynRed().then((res) { - if (res['status']) { - setCount(res['data']); - } - }); + if (GlobalData().grpcReply) { + await GrpcRepo.dynRed().then((res) { + if (res['status']) { + setCount(res['data']); + } + }); + } else { + await CommonHttp.unReadDynamic().then((res) { + if (res['status']) { + setCount(res['data']); + } + }); + } } void setCount([int count = 0]) async { diff --git a/lib/pages/video/detail/reply_reply/controller.dart b/lib/pages/video/detail/reply_reply/controller.dart index a8bbbb1b..a04c132f 100644 --- a/lib/pages/video/detail/reply_reply/controller.dart +++ b/lib/pages/video/detail/reply_reply/controller.dart @@ -51,7 +51,8 @@ class VideoReplyReplyController extends CommonController @override Future queryData([bool isRefresh = true]) async { - if (!isDialogue && + if (GlobalData().grpcReply && + !isDialogue && currentPage == 1 && !hasRoot && firstFloor == null &&