mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-21 16:48:43 +00:00
opt: save reply (#1860)
* opt: save reply * opt: reply save switch * remove unneeded sort * clear sub replies [skip ci] --------- Co-authored-by: dom <githubaccount56556@proton.me>
This commit is contained in:
committed by
GitHub
parent
4ad422c3ea
commit
f825f87dc1
@@ -17,6 +17,7 @@ import 'package:PiliPlus/utils/extension/get_ext.dart';
|
||||
import 'package:PiliPlus/utils/extension/num_ext.dart';
|
||||
import 'package:PiliPlus/utils/extension/theme_ext.dart';
|
||||
import 'package:PiliPlus/utils/platform_utils.dart';
|
||||
import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
import 'package:flutter/material.dart' hide ListTile;
|
||||
import 'package:get/get.dart';
|
||||
@@ -160,14 +161,15 @@ class _MediaPageState extends CommonPageState<MinePage>
|
||||
),
|
||||
msgBadge(_mainController),
|
||||
],
|
||||
IconButton(
|
||||
iconSize: iconSize,
|
||||
padding: padding,
|
||||
style: style,
|
||||
tooltip: '评论记录',
|
||||
onPressed: () => Get.toNamed('/myReply'),
|
||||
icon: const Icon(Icons.message_outlined),
|
||||
),
|
||||
if (GStorage.reply != null)
|
||||
IconButton(
|
||||
iconSize: iconSize,
|
||||
padding: padding,
|
||||
style: style,
|
||||
tooltip: '评论记录',
|
||||
onPressed: () => Get.toNamed('/myReply'),
|
||||
icon: const Icon(Icons.message_outlined),
|
||||
),
|
||||
Obx(
|
||||
() {
|
||||
final anonymity = MineController.anonymity.value;
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'package:PiliPlus/common/widgets/view_sliver_safe_area.dart';
|
||||
import 'package:PiliPlus/grpc/bilibili/main/community/reply/v1.pb.dart';
|
||||
import 'package:PiliPlus/pages/video/reply/widgets/reply_item_grpc.dart';
|
||||
import 'package:PiliPlus/utils/app_scheme.dart';
|
||||
import 'package:PiliPlus/utils/id_utils.dart';
|
||||
import 'package:PiliPlus/utils/page_utils.dart';
|
||||
import 'package:PiliPlus/utils/reply_utils.dart';
|
||||
import 'package:PiliPlus/utils/storage.dart';
|
||||
@@ -26,11 +27,7 @@ class _MyReplyState extends State<MyReply> with DynMixin {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_replies =
|
||||
GStorage.reply.values
|
||||
.map((e) => ReplyInfo.create()..mergeFromProto3Json(e))
|
||||
.toList()
|
||||
..sort((a, b) => b.ctime.compareTo(a.ctime));
|
||||
_replies = GStorage.reply!.values.map(ReplyInfo.fromBuffer).toList();
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -46,7 +43,7 @@ class _MyReplyState extends State<MyReply> with DynMixin {
|
||||
context: context,
|
||||
title: 'Clear Local Storage?',
|
||||
onConfirm: () {
|
||||
GStorage.reply.clear();
|
||||
GStorage.reply!.clear();
|
||||
_replies.clear();
|
||||
setState(() {});
|
||||
},
|
||||
@@ -112,10 +109,14 @@ class _MyReplyState extends State<MyReply> with DynMixin {
|
||||
}
|
||||
|
||||
void _onCheckReply(ReplyInfo replyInfo) {
|
||||
final oid = replyInfo.oid.toInt();
|
||||
ReplyUtils.onCheckReply(
|
||||
replyInfo: replyInfo,
|
||||
biliSendCommAntifraud: Pref.biliSendCommAntifraud,
|
||||
sourceId: null,
|
||||
sourceId: switch (oid) {
|
||||
1 => IdUtils.av2bv(oid),
|
||||
_ => oid.toString(),
|
||||
},
|
||||
isManual: true,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -354,6 +354,13 @@ List<SettingsModel> get extraSettings => [
|
||||
setKey: SettingBoxKey.showDmChart,
|
||||
defaultVal: false,
|
||||
),
|
||||
const SwitchModel(
|
||||
title: '记录评论',
|
||||
leading: Icon(Icons.message_outlined),
|
||||
setKey: SettingBoxKey.saveReply,
|
||||
defaultVal: true,
|
||||
needReboot: true,
|
||||
),
|
||||
const SwitchModel(
|
||||
title: '发评反诈',
|
||||
subtitle: '发送评论后检查评论是否可见',
|
||||
|
||||
@@ -39,6 +39,7 @@ import 'package:flutter/foundation.dart' show kDebugMode;
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:protobuf/protobuf.dart';
|
||||
|
||||
class ReplyItemGrpc extends StatelessWidget {
|
||||
const ReplyItemGrpc({
|
||||
@@ -840,7 +841,7 @@ class ReplyItemGrpc extends StatelessWidget {
|
||||
final ownerMid = Int64(Accounts.main.mid);
|
||||
final theme = Theme.of(context);
|
||||
final errorColor = theme.colorScheme.error;
|
||||
final style = theme.textTheme.titleSmall;
|
||||
final style = theme.textTheme.titleSmall!;
|
||||
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(
|
||||
@@ -866,34 +867,56 @@ class ReplyItemGrpc extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
if (kDebugMode) ...[
|
||||
if (kDebugMode && GStorage.reply != null) ...[
|
||||
ListTile(
|
||||
onTap: () {
|
||||
Get.back();
|
||||
GStorage.reply.put(
|
||||
GStorage.reply!.put(
|
||||
item.id.toString(),
|
||||
(item.toProto3Json() as Map)
|
||||
..remove('replies')
|
||||
..remove('memberV2')
|
||||
..remove('trackInfo'),
|
||||
(item.deepCopy()
|
||||
..unknownFields.clear()
|
||||
..replies.clear()
|
||||
..clearMemberV2()
|
||||
..clearTrackInfo())
|
||||
.writeToBuffer(),
|
||||
);
|
||||
},
|
||||
title: Text(
|
||||
'save to local',
|
||||
style: style!.copyWith(color: theme.colorScheme.primary),
|
||||
style: style.copyWith(color: theme.colorScheme.primary),
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
onTap: () {
|
||||
Get.back();
|
||||
onDelete();
|
||||
GStorage.reply.delete(item.id.toString());
|
||||
GStorage.reply!.delete(item.id.toString());
|
||||
},
|
||||
title: Text(
|
||||
'remove from local',
|
||||
style: style.copyWith(color: theme.colorScheme.primary),
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
onTap: () {
|
||||
Get.back();
|
||||
final oid = item.oid.toInt();
|
||||
final data =
|
||||
(item.deepCopy()
|
||||
..unknownFields.clear()
|
||||
..replies.clear()
|
||||
..clearMemberV2()
|
||||
..clearTrackInfo())
|
||||
.writeToBuffer();
|
||||
GStorage.reply!.putAll({
|
||||
for (var i = oid; i < oid + 1000; i++) i.toString(): data,
|
||||
});
|
||||
},
|
||||
title: Text(
|
||||
'save to local (x1000)',
|
||||
style: style.copyWith(color: theme.colorScheme.primary),
|
||||
),
|
||||
),
|
||||
],
|
||||
if (ownerMid == upMid || ownerMid == item.member.mid)
|
||||
ListTile(
|
||||
@@ -959,7 +982,7 @@ class ReplyItemGrpc extends StatelessWidget {
|
||||
},
|
||||
minLeadingWidth: 0,
|
||||
leading: Icon(Icons.delete_outlined, color: errorColor, size: 19),
|
||||
title: Text('删除', style: style!.copyWith(color: errorColor)),
|
||||
title: Text('删除', style: style.copyWith(color: errorColor)),
|
||||
),
|
||||
if (ownerMid != Int64.ZERO)
|
||||
ListTile(
|
||||
@@ -985,7 +1008,7 @@ class ReplyItemGrpc extends StatelessWidget {
|
||||
},
|
||||
minLeadingWidth: 0,
|
||||
leading: Icon(Icons.error_outline, color: errorColor, size: 19),
|
||||
title: Text('举报', style: style!.copyWith(color: errorColor)),
|
||||
title: Text('举报', style: style.copyWith(color: errorColor)),
|
||||
),
|
||||
if (replyLevel == 1 && !isSubReply && ownerMid == upMid)
|
||||
ListTile(
|
||||
|
||||
Reference in New Issue
Block a user