mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-06-01 08:38:18 +08:00
feat: msg: set notice
Closes #821 Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -805,4 +805,6 @@ class Api {
|
|||||||
|
|
||||||
static const String liveSecondList =
|
static const String liveSecondList =
|
||||||
'${HttpString.liveBaseUrl}/xlive/app-interface/v2/second/getList';
|
'${HttpString.liveBaseUrl}/xlive/app-interface/v2/second/getList';
|
||||||
|
|
||||||
|
static const String msgSetNotice = '/x/msgfeed/notice';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -566,4 +566,32 @@ class MsgHttp {
|
|||||||
static String getDevId() {
|
static String getDevId() {
|
||||||
return const Uuid().v4();
|
return const Uuid().v4();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Future msgSetNotice({
|
||||||
|
required dynamic id,
|
||||||
|
required int noticeState,
|
||||||
|
}) async {
|
||||||
|
final csrf = Accounts.main.csrf;
|
||||||
|
var res = await Request().post(
|
||||||
|
Api.msgSetNotice,
|
||||||
|
data: {
|
||||||
|
'mobi_app': 'web',
|
||||||
|
'platform': 'web',
|
||||||
|
'tp': 0,
|
||||||
|
'id': id,
|
||||||
|
'notice_state': noticeState,
|
||||||
|
'build': 0,
|
||||||
|
'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']};
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,4 +67,23 @@ class LikeMeController extends CommonDataController<MsgFeedLikeMe, dynamic> {
|
|||||||
}
|
}
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> onSetNotice(
|
||||||
|
int? id, int index, bool isNotice, bool isLatest) async {
|
||||||
|
int noticeState = isNotice ? 1 : 0;
|
||||||
|
var res = await MsgHttp.msgSetNotice(id: id, noticeState: noticeState);
|
||||||
|
if (res['status']) {
|
||||||
|
Pair<List<LikeMeItems>, List<LikeMeItems>> pair =
|
||||||
|
(loadingState.value as Success).response;
|
||||||
|
if (isLatest) {
|
||||||
|
pair.first[index].noticeState = noticeState;
|
||||||
|
} else {
|
||||||
|
pair.second[index].noticeState = noticeState;
|
||||||
|
}
|
||||||
|
loadingState.refresh();
|
||||||
|
SmartDialog.showToast('操作成功');
|
||||||
|
} else {
|
||||||
|
SmartDialog.showToast(res['msg']);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,6 +77,10 @@ class _LikeMePageState extends State<LikeMePage> {
|
|||||||
(id) {
|
(id) {
|
||||||
_likeMeController.onRemove(id, index, true);
|
_likeMeController.onRemove(id, index, true);
|
||||||
},
|
},
|
||||||
|
(isNotice, id) {
|
||||||
|
_likeMeController.onSetNotice(
|
||||||
|
id, index, isNotice, true);
|
||||||
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
itemCount: latest.length,
|
itemCount: latest.length,
|
||||||
@@ -103,6 +107,10 @@ class _LikeMePageState extends State<LikeMePage> {
|
|||||||
(id) {
|
(id) {
|
||||||
_likeMeController.onRemove(id, index, false);
|
_likeMeController.onRemove(id, index, false);
|
||||||
},
|
},
|
||||||
|
(isNotice, id) {
|
||||||
|
_likeMeController.onSetNotice(
|
||||||
|
id, index, isNotice, false);
|
||||||
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
itemCount: total.length,
|
itemCount: total.length,
|
||||||
@@ -146,7 +154,12 @@ class _LikeMePageState extends State<LikeMePage> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildItem(ThemeData theme, LikeMeItems item, ValueChanged onRemove) {
|
Widget _buildItem(
|
||||||
|
ThemeData theme,
|
||||||
|
LikeMeItems item,
|
||||||
|
ValueChanged<int?> onRemove,
|
||||||
|
Function(bool isNotice, int? id) onSetNotice,
|
||||||
|
) {
|
||||||
return ListTile(
|
return ListTile(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
String? nativeUri = item.item?.nativeUri;
|
String? nativeUri = item.item?.nativeUri;
|
||||||
@@ -155,14 +168,62 @@ class _LikeMePageState extends State<LikeMePage> {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLongPress: () {
|
onLongPress: () {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) {
|
||||||
|
final isNotice = item.noticeState == 0;
|
||||||
|
return AlertDialog(
|
||||||
|
clipBehavior: Clip.hardEdge,
|
||||||
|
contentPadding: const EdgeInsets.symmetric(vertical: 12),
|
||||||
|
content: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
ListTile(
|
||||||
|
onTap: () {
|
||||||
|
Get.back();
|
||||||
showConfirmDialog(
|
showConfirmDialog(
|
||||||
context: context,
|
context: context,
|
||||||
title: '确定删除该通知?',
|
title: '删除',
|
||||||
|
content: '该条通知删除后,当有新点赞时会重新出现在列表,是否继续?',
|
||||||
onConfirm: () {
|
onConfirm: () {
|
||||||
onRemove(item.id);
|
onRemove(item.id);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
dense: true,
|
||||||
|
title: const Text(
|
||||||
|
'删除',
|
||||||
|
style: TextStyle(fontSize: 14),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
onTap: () {
|
||||||
|
Get.back();
|
||||||
|
if (isNotice) {
|
||||||
|
showConfirmDialog(
|
||||||
|
context: context,
|
||||||
|
title: '不再通知',
|
||||||
|
content: '这条内容的点赞将不再通知,但仍可在列表内查看,是否继续?',
|
||||||
|
onConfirm: () {
|
||||||
|
onSetNotice(isNotice, item.id);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
onSetNotice(isNotice, item.id);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
dense: true,
|
||||||
|
title: Text(
|
||||||
|
isNotice ? '不再通知' : '接收通知',
|
||||||
|
style: const TextStyle(fontSize: 14),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
leading: Column(
|
leading: Column(
|
||||||
children: [
|
children: [
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
@@ -238,14 +299,24 @@ class _LikeMePageState extends State<LikeMePage> {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
trailing: item.item?.image != null && item.item?.image != ""
|
trailing: Row(
|
||||||
? NetworkImgLayer(
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
if (item.item?.image?.isNotEmpty == true)
|
||||||
|
NetworkImgLayer(
|
||||||
width: 45,
|
width: 45,
|
||||||
height: 45,
|
height: 45,
|
||||||
type: 'cover',
|
type: 'cover',
|
||||||
src: item.item?.image,
|
src: item.item!.image,
|
||||||
)
|
),
|
||||||
: null,
|
if (item.noticeState == 1)
|
||||||
|
Icon(
|
||||||
|
size: 18,
|
||||||
|
Icons.notifications_off,
|
||||||
|
color: theme.colorScheme.outline,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -219,7 +219,7 @@ class RequestUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static ReplyInfo replyCast(res) {
|
static ReplyInfo replyCast(res) {
|
||||||
Map? emote = res['content']?['emote'];
|
Map? emote = res['content']['emote'];
|
||||||
emote?.forEach((key, value) {
|
emote?.forEach((key, value) {
|
||||||
value['size'] = value['meta']['size'];
|
value['size'] = value['meta']['size'];
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user