mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-22 01:56:47 +08:00
@@ -24,14 +24,15 @@ abstract class CommonWhisperController<R>
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> onSetTop(int index, bool isTop, SessionId sessionId) async {
|
||||
Future<void> onSetTop(
|
||||
Session item, int index, bool isTop, SessionId sessionId) async {
|
||||
var res = isTop
|
||||
? await ImGrpc.unpinSession(sessionId: sessionId)
|
||||
: await ImGrpc.pinSession(sessionId: sessionId);
|
||||
|
||||
if (res.isSuccess) {
|
||||
List<Session> list = loadingState.value.data!;
|
||||
list[index].isPinned = isTop ? false : true;
|
||||
item.isPinned = isTop ? false : true;
|
||||
if (!isTop) {
|
||||
list.insert(0, list.removeAt(index));
|
||||
}
|
||||
@@ -42,16 +43,15 @@ abstract class CommonWhisperController<R>
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> onSetMute(int index, bool isMuted, Int64 talkerUid) async {
|
||||
Future<void> onSetMute(Session item, 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();
|
||||
item.isMuted = !isMuted;
|
||||
loadingState.refresh();
|
||||
SmartDialog.showToast('操作成功');
|
||||
} else {
|
||||
SmartDialog.showToast(res['msg']);
|
||||
|
||||
@@ -11,9 +11,9 @@ abstract class MultiSelectController<R, T extends MultiSelectData>
|
||||
late final RxInt checkedCount = 0.obs;
|
||||
late final allSelected = false.obs;
|
||||
|
||||
void onSelect(int index, [bool disableSelect = true]) {
|
||||
void onSelect(T item, [bool disableSelect = true]) {
|
||||
List<T> list = loadingState.value.data!;
|
||||
list[index].checked = !(list[index].checked ?? false);
|
||||
item.checked = !(item.checked ?? false);
|
||||
checkedCount.value = list.where((item) => item.checked == true).length;
|
||||
loadingState.refresh();
|
||||
if (disableSelect) {
|
||||
|
||||
@@ -107,7 +107,6 @@ abstract class ReplyController<R> extends CommonListController<R, ReplyInfo> {
|
||||
BuildContext context, {
|
||||
int? oid,
|
||||
ReplyInfo? replyItem,
|
||||
int index = 0,
|
||||
int? replyType,
|
||||
}) {
|
||||
assert(replyItem != null || (oid != null && replyType != null));
|
||||
@@ -168,7 +167,7 @@ abstract class ReplyController<R> extends CommonListController<R, ReplyInfo> {
|
||||
if (oid != null) {
|
||||
list.insert(hasUpTop ? 1 : 0, replyInfo);
|
||||
} else {
|
||||
list[index]
|
||||
replyItem!
|
||||
..count += 1
|
||||
..replies.add(replyInfo);
|
||||
}
|
||||
@@ -188,12 +187,12 @@ abstract class ReplyController<R> extends CommonListController<R, ReplyInfo> {
|
||||
);
|
||||
}
|
||||
|
||||
void onRemove(int index, int? subIndex) {
|
||||
void onRemove(int index, ReplyInfo item, int? subIndex) {
|
||||
List<ReplyInfo> list = loadingState.value.data!;
|
||||
if (subIndex == null) {
|
||||
list.removeAt(index);
|
||||
} else {
|
||||
list[index]
|
||||
item
|
||||
..count -= 1
|
||||
..replies.removeAt(subIndex);
|
||||
}
|
||||
@@ -212,21 +211,21 @@ abstract class ReplyController<R> extends CommonListController<R, ReplyInfo> {
|
||||
}
|
||||
|
||||
Future<void> onToggleTop(
|
||||
ReplyInfo item,
|
||||
int index,
|
||||
oid,
|
||||
int type,
|
||||
bool isUpTop,
|
||||
int rpid,
|
||||
) async {
|
||||
bool isUpTop = item.replyControl.isUpTop;
|
||||
final res = await ReplyHttp.replyTop(
|
||||
oid: oid,
|
||||
type: type,
|
||||
rpid: rpid,
|
||||
rpid: item.id,
|
||||
isUpTop: isUpTop,
|
||||
);
|
||||
if (res['status']) {
|
||||
List<ReplyInfo> list = loadingState.value.data!;
|
||||
list[index].replyControl.isUpTop = !isUpTop;
|
||||
item.replyControl.isUpTop = !isUpTop;
|
||||
if (!isUpTop && index != 0) {
|
||||
list[0].replyControl.isUpTop = false;
|
||||
final item = list.removeAt(index);
|
||||
|
||||
Reference in New Issue
Block a user