mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
mod: insert dyn
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -1,9 +1,5 @@
|
||||
import 'package:PiliPlus/http/dynamics.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/http/msg.dart';
|
||||
import 'package:PiliPlus/models/dynamics/result.dart';
|
||||
import 'package:PiliPlus/pages/common/common_publish_page.dart';
|
||||
import 'package:PiliPlus/pages/dynamics/tab/controller.dart';
|
||||
import 'package:PiliPlus/pages/dynamics/view.dart';
|
||||
import 'package:PiliPlus/pages/emote/controller.dart';
|
||||
import 'package:PiliPlus/pages/emote/view.dart';
|
||||
@@ -492,31 +488,10 @@ class _CreateDynPanelState extends CommonPublishPageState<CreateDynPanel> {
|
||||
if (result['status']) {
|
||||
Get.back();
|
||||
SmartDialog.showToast('发布成功');
|
||||
try {
|
||||
// insert
|
||||
dynamic id = result['data']['dyn_id'];
|
||||
if (id != null) {
|
||||
await Future.delayed(const Duration(milliseconds: 200));
|
||||
dynamic res = await DynamicsHttp.dynamicDetail(id: id);
|
||||
if (res['status']) {
|
||||
final ctr = Get.find<DynamicsTabController>(tag: 'all');
|
||||
List list = ctr.loadingState.value is Success
|
||||
? (ctr.loadingState.value as Success).response
|
||||
: <DynamicItemModel>[];
|
||||
list.insert(0, res['data']);
|
||||
ctr.loadingState.value = LoadingState.success(list);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
debugPrint('create dyn $e');
|
||||
}
|
||||
if (GStorage.enableCreateDynAntifraud) {
|
||||
try {
|
||||
Utils.checkCreatedDyn(result['data']['dyn_id'], editController.text);
|
||||
} catch (e) {
|
||||
SmartDialog.showToast(e.toString());
|
||||
}
|
||||
}
|
||||
Future.wait([
|
||||
Utils.insertCreatedDyn(result),
|
||||
Utils.checkCreatedDyn(result, editController.text)
|
||||
]);
|
||||
} else {
|
||||
SmartDialog.showToast(result['msg']);
|
||||
debugPrint('failed to publish: ${result['msg']}');
|
||||
|
||||
@@ -386,13 +386,10 @@ class _RepostPanelState extends CommonPublishPageState<RepostPanel> {
|
||||
Get.back();
|
||||
SmartDialog.showToast('转发成功');
|
||||
widget.callback?.call();
|
||||
if (GStorage.enableCreateDynAntifraud) {
|
||||
try {
|
||||
Utils.checkCreatedDyn(result['data']['dyn_id'], editController.text);
|
||||
} catch (e) {
|
||||
SmartDialog.showToast(e.toString());
|
||||
}
|
||||
}
|
||||
Future.wait([
|
||||
Utils.insertCreatedDyn(result),
|
||||
Utils.checkCreatedDyn(result, editController.text)
|
||||
]);
|
||||
} else {
|
||||
SmartDialog.showToast(result['msg']);
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import 'package:PiliPlus/models/common/search_type.dart';
|
||||
import 'package:PiliPlus/models/dynamics/result.dart';
|
||||
import 'package:PiliPlus/models/live/item.dart';
|
||||
import 'package:PiliPlus/models/user/fav_folder.dart';
|
||||
import 'package:PiliPlus/pages/dynamics/tab/controller.dart';
|
||||
import 'package:PiliPlus/pages/later/controller.dart';
|
||||
import 'package:PiliPlus/pages/video/detail/introduction/widgets/fav_panel.dart';
|
||||
import 'package:PiliPlus/pages/video/detail/introduction/widgets/group_panel.dart';
|
||||
@@ -46,17 +47,44 @@ class Utils {
|
||||
|
||||
static const channel = MethodChannel("PiliPlus");
|
||||
|
||||
static void checkCreatedDyn(id, dynText) async {
|
||||
if (id != null) {
|
||||
dynamic res = await DynamicsHttp.dynamicDetail(id: id, clearCookie: true);
|
||||
showDialog(
|
||||
context: Get.context!,
|
||||
builder: (context) => AlertDialog(
|
||||
title: Text('动态检查结果'),
|
||||
content: SelectableText(
|
||||
'${res['status'] ? '无账号状态下找到了你的动态,动态正常!' : '你的动态被shadow ban(仅自己可见)!'} \n\n动态内容: $dynText'),
|
||||
),
|
||||
);
|
||||
static Future insertCreatedDyn(result) async {
|
||||
try {
|
||||
dynamic id = result['data']['dyn_id'];
|
||||
if (id != null) {
|
||||
await Future.delayed(const Duration(milliseconds: 200));
|
||||
dynamic res = await DynamicsHttp.dynamicDetail(id: id);
|
||||
if (res['status']) {
|
||||
final ctr = Get.find<DynamicsTabController>(tag: 'all');
|
||||
List list = ctr.loadingState.value is Success
|
||||
? (ctr.loadingState.value as Success).response
|
||||
: <DynamicItemModel>[];
|
||||
list.insert(0, res['data']);
|
||||
ctr.loadingState.value = LoadingState.success(list);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
debugPrint('create dyn $e');
|
||||
}
|
||||
}
|
||||
|
||||
static Future checkCreatedDyn(result, dynText) async {
|
||||
if (GStorage.enableCreateDynAntifraud) {
|
||||
try {
|
||||
dynamic id = result['data']['dyn_id'];
|
||||
if (id != null) {
|
||||
await Future.delayed(const Duration(milliseconds: 200));
|
||||
dynamic res =
|
||||
await DynamicsHttp.dynamicDetail(id: id, clearCookie: true);
|
||||
showDialog(
|
||||
context: Get.context!,
|
||||
builder: (context) => AlertDialog(
|
||||
title: Text('动态检查结果'),
|
||||
content: SelectableText(
|
||||
'${res['status'] ? '无账号状态下找到了你的动态,动态正常!' : '你的动态被shadow ban(仅自己可见)!'} \n\n动态内容: $dynText'),
|
||||
),
|
||||
);
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user