mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-20 00:56:31 +08:00
feat: setMsgDnd
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -831,4 +831,7 @@ class Api {
|
|||||||
static const String spaceOpus = '/x/polymer/web-dynamic/v1/opus/feed/space';
|
static const String spaceOpus = '/x/polymer/web-dynamic/v1/opus/feed/space';
|
||||||
|
|
||||||
static const String articleList = '/x/article/list/web/articles';
|
static const String articleList = '/x/article/list/web/articles';
|
||||||
|
|
||||||
|
static const String setMsgDnd =
|
||||||
|
'${HttpString.tUrl}/link_setting/v1/link_setting/set_msg_dnd';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -581,4 +581,30 @@ class MsgHttp {
|
|||||||
return {'status': false, 'msg': res.data['message']};
|
return {'status': false, 'msg': res.data['message']};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Future setMsgDnd({
|
||||||
|
required uid,
|
||||||
|
required int setting,
|
||||||
|
required dndUid,
|
||||||
|
}) async {
|
||||||
|
final csrf = Accounts.main.csrf;
|
||||||
|
var res = await Request().post(
|
||||||
|
Api.setMsgDnd,
|
||||||
|
data: {
|
||||||
|
'uid': uid,
|
||||||
|
'setting': setting,
|
||||||
|
'dnd_uid': dndUid,
|
||||||
|
'build': 0,
|
||||||
|
'mobi_app': 'web',
|
||||||
|
'csrf_token': csrf,
|
||||||
|
'csrf': csrf,
|
||||||
|
},
|
||||||
|
options: Options(contentType: Headers.formUrlEncodedContentType),
|
||||||
|
);
|
||||||
|
if (res.data['code'] == 0) {
|
||||||
|
return {'status': true};
|
||||||
|
} else {
|
||||||
|
return {'status': false, 'msg': res.data['message']};
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import 'package:PiliPlus/grpc/im.dart';
|
|||||||
import 'package:PiliPlus/http/loading_state.dart';
|
import 'package:PiliPlus/http/loading_state.dart';
|
||||||
import 'package:PiliPlus/http/msg.dart';
|
import 'package:PiliPlus/http/msg.dart';
|
||||||
import 'package:PiliPlus/pages/common/common_list_controller.dart';
|
import 'package:PiliPlus/pages/common/common_list_controller.dart';
|
||||||
|
import 'package:PiliPlus/utils/storage.dart';
|
||||||
|
import 'package:fixnum/fixnum.dart';
|
||||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
|
|
||||||
abstract class CommonWhisperController<R>
|
abstract class CommonWhisperController<R>
|
||||||
@@ -40,6 +42,22 @@ abstract class CommonWhisperController<R>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> onSetMute(int index, bool isMuted, Int64 talkerUid) async {
|
||||||
|
var res = await MsgHttp.setMsgDnd(
|
||||||
|
uid: Accounts.main.mid,
|
||||||
|
setting: isMuted ? 0 : 1,
|
||||||
|
dndUid: talkerUid,
|
||||||
|
);
|
||||||
|
if (res['status']) {
|
||||||
|
loadingState
|
||||||
|
..value.data![index].isMuted = !isMuted
|
||||||
|
..refresh();
|
||||||
|
SmartDialog.showToast('操作成功');
|
||||||
|
} else {
|
||||||
|
SmartDialog.showToast(res['msg']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> onClearUnread() async {
|
Future<void> onClearUnread() async {
|
||||||
final res = await ImGrpc.clearUnread(pageType: sessionPageType);
|
final res = await ImGrpc.clearUnread(pageType: sessionPageType);
|
||||||
if (res.isSuccess) {
|
if (res.isSuccess) {
|
||||||
|
|||||||
@@ -321,12 +321,14 @@ class _LikeMePageState extends State<LikeMePage> {
|
|||||||
height: 45,
|
height: 45,
|
||||||
src: item.item!.image,
|
src: item.item!.image,
|
||||||
),
|
),
|
||||||
if (item.noticeState == 1)
|
if (item.noticeState == 1) ...[
|
||||||
|
if (item.item?.image?.isNotEmpty == true) const SizedBox(width: 4),
|
||||||
Icon(
|
Icon(
|
||||||
size: 18,
|
size: 18,
|
||||||
Icons.notifications_off,
|
Icons.notifications_off,
|
||||||
color: theme.colorScheme.outline,
|
color: theme.colorScheme.outline,
|
||||||
),
|
),
|
||||||
|
],
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ class _NavigationbarSetPageState extends State<NavigationBarSetPage> {
|
|||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
defaultNavTabs = defaultNavigationBars;
|
defaultNavTabs = defaultNavigationBars;
|
||||||
navBarSort =
|
navBarSort = List<int>.from(GStorage.setting
|
||||||
GStorage.setting.get(SettingBoxKey.navBarSort, defaultValue: [0, 1, 2]);
|
.get(SettingBoxKey.navBarSort, defaultValue: [0, 1, 2]));
|
||||||
// 对 tabData 进行排序
|
// 对 tabData 进行排序
|
||||||
defaultNavTabs.sort((a, b) {
|
defaultNavTabs.sort((a, b) {
|
||||||
int indexA = navBarSort.indexOf(a['id']);
|
int indexA = navBarSort.indexOf(a['id']);
|
||||||
|
|||||||
@@ -108,6 +108,8 @@ class _WhisperPageState extends State<WhisperPage> {
|
|||||||
item: response[index],
|
item: response[index],
|
||||||
onSetTop: (isTop, id) =>
|
onSetTop: (isTop, id) =>
|
||||||
_controller.onSetTop(index, isTop, id),
|
_controller.onSetTop(index, isTop, id),
|
||||||
|
onSetMute: (isMuted, talkerUid) =>
|
||||||
|
_controller.onSetMute(index, isMuted, talkerUid),
|
||||||
onRemove: (talkerId) => _controller.onRemove(index, talkerId),
|
onRemove: (talkerId) => _controller.onRemove(index, talkerId),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import 'package:PiliPlus/models/common/badge_type.dart';
|
|||||||
import 'package:PiliPlus/pages/whisper_secondary/view.dart';
|
import 'package:PiliPlus/pages/whisper_secondary/view.dart';
|
||||||
import 'package:PiliPlus/utils/extension.dart';
|
import 'package:PiliPlus/utils/extension.dart';
|
||||||
import 'package:PiliPlus/utils/utils.dart';
|
import 'package:PiliPlus/utils/utils.dart';
|
||||||
|
import 'package:fixnum/fixnum.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
@@ -17,11 +18,13 @@ class WhisperSessionItem extends StatelessWidget {
|
|||||||
super.key,
|
super.key,
|
||||||
required this.item,
|
required this.item,
|
||||||
required this.onSetTop,
|
required this.onSetTop,
|
||||||
|
required this.onSetMute,
|
||||||
required this.onRemove,
|
required this.onRemove,
|
||||||
});
|
});
|
||||||
|
|
||||||
final Session item;
|
final Session item;
|
||||||
final Function(bool isTop, SessionId id) onSetTop;
|
final Function(bool isTop, SessionId id) onSetTop;
|
||||||
|
final Function(bool isMuted, Int64 talkerUid) onSetMute;
|
||||||
final ValueChanged<int?> onRemove;
|
final ValueChanged<int?> onRemove;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -42,33 +45,39 @@ class WhisperSessionItem extends StatelessWidget {
|
|||||||
return AlertDialog(
|
return AlertDialog(
|
||||||
clipBehavior: Clip.hardEdge,
|
clipBehavior: Clip.hardEdge,
|
||||||
contentPadding: const EdgeInsets.symmetric(vertical: 12),
|
contentPadding: const EdgeInsets.symmetric(vertical: 12),
|
||||||
content: Column(
|
content: DefaultTextStyle(
|
||||||
mainAxisSize: MainAxisSize.min,
|
style: const TextStyle(fontSize: 14),
|
||||||
children: [
|
child: Column(
|
||||||
ListTile(
|
mainAxisSize: MainAxisSize.min,
|
||||||
dense: true,
|
children: [
|
||||||
onTap: () {
|
|
||||||
Get.back();
|
|
||||||
onSetTop(item.isPinned, item.id);
|
|
||||||
},
|
|
||||||
title: Text(
|
|
||||||
item.isPinned ? '移除置顶' : '置顶',
|
|
||||||
style: const TextStyle(fontSize: 14),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (item.id.privateId.hasTalkerUid())
|
|
||||||
ListTile(
|
ListTile(
|
||||||
dense: true,
|
dense: true,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Get.back();
|
Get.back();
|
||||||
onRemove(item.id.privateId.talkerUid.toInt());
|
onSetTop(item.isPinned, item.id);
|
||||||
},
|
},
|
||||||
title: const Text(
|
title: Text(item.isPinned ? '移除置顶' : '置顶'),
|
||||||
'删除',
|
|
||||||
style: TextStyle(fontSize: 14),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
if (item.id.privateId.hasTalkerUid())
|
||||||
|
ListTile(
|
||||||
|
dense: true,
|
||||||
|
onTap: () {
|
||||||
|
Get.back();
|
||||||
|
onSetMute(item.isMuted, item.id.privateId.talkerUid);
|
||||||
|
},
|
||||||
|
title: Text('${item.isMuted ? '关闭' : '开启'}免打扰'),
|
||||||
|
),
|
||||||
|
if (item.id.privateId.hasTalkerUid())
|
||||||
|
ListTile(
|
||||||
|
dense: true,
|
||||||
|
onTap: () {
|
||||||
|
Get.back();
|
||||||
|
onRemove(item.id.privateId.talkerUid.toInt());
|
||||||
|
},
|
||||||
|
title: const Text('删除'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@@ -216,16 +225,28 @@ class WhisperSessionItem extends StatelessWidget {
|
|||||||
style: theme.textTheme.labelMedium!
|
style: theme.textTheme.labelMedium!
|
||||||
.copyWith(color: theme.colorScheme.outline),
|
.copyWith(color: theme.colorScheme.outline),
|
||||||
),
|
),
|
||||||
trailing: item.hasTimestamp()
|
trailing: Row(
|
||||||
? Text(
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
if (item.isMuted) ...[
|
||||||
|
Icon(
|
||||||
|
size: 16,
|
||||||
|
Icons.notifications_off,
|
||||||
|
color: theme.colorScheme.outline,
|
||||||
|
),
|
||||||
|
if (item.hasTimestamp()) const SizedBox(width: 4),
|
||||||
|
],
|
||||||
|
if (item.hasTimestamp())
|
||||||
|
Text(
|
||||||
Utils.dateFormat((item.timestamp ~/ 1000000).toInt(),
|
Utils.dateFormat((item.timestamp ~/ 1000000).toInt(),
|
||||||
formatType: "day"),
|
formatType: "day"),
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
color: theme.colorScheme.outline,
|
color: theme.colorScheme.outline,
|
||||||
),
|
),
|
||||||
)
|
),
|
||||||
: null,
|
],
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,6 +97,8 @@ class _WhisperSecPageState extends State<WhisperSecPage> {
|
|||||||
item: response[index],
|
item: response[index],
|
||||||
onSetTop: (isTop, talkerId) =>
|
onSetTop: (isTop, talkerId) =>
|
||||||
_controller.onSetTop(index, isTop, talkerId),
|
_controller.onSetTop(index, isTop, talkerId),
|
||||||
|
onSetMute: (isMuted, talkerUid) =>
|
||||||
|
_controller.onSetMute(index, isMuted, talkerUid),
|
||||||
onRemove: (talkerId) => _controller.onRemove(index, talkerId),
|
onRemove: (talkerId) => _controller.onRemove(index, talkerId),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user