mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-06-01 16:48:16 +08:00
opt check reply state
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -162,6 +162,7 @@ class GrpcReq {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
|
int? code;
|
||||||
String msg = response.headers.value('Grpc-Status-Details-Bin') ?? '';
|
String msg = response.headers.value('Grpc-Status-Details-Bin') ?? '';
|
||||||
if (msg.isNotEmpty) {
|
if (msg.isNotEmpty) {
|
||||||
while (msg.length % 4 != 0) {
|
while (msg.length % 4 != 0) {
|
||||||
@@ -170,6 +171,7 @@ class GrpcReq {
|
|||||||
final msgBytes = base64Decode(msg);
|
final msgBytes = base64Decode(msg);
|
||||||
try {
|
try {
|
||||||
final grpcMsg = Status.fromBuffer(msgBytes);
|
final grpcMsg = Status.fromBuffer(msgBytes);
|
||||||
|
code = grpcMsg.details.firstOrNull?.status.code;
|
||||||
// UNKNOWN : -400 : msg
|
// UNKNOWN : -400 : msg
|
||||||
final errMsg = grpcMsg.details
|
final errMsg = grpcMsg.details
|
||||||
.map((e) => e.status.message)
|
.map((e) => e.status.message)
|
||||||
@@ -181,7 +183,7 @@ class GrpcReq {
|
|||||||
msg = utf8.decode(msgBytes, allowMalformed: true);
|
msg = utf8.decode(msgBytes, allowMalformed: true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Error(msg);
|
return Error(msg, code: code);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return Error(e.toString());
|
return Error(e.toString());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,8 +53,9 @@ class Success<T> extends LoadingState<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class Error extends LoadingState<Never> {
|
class Error extends LoadingState<Never> {
|
||||||
|
final int? code;
|
||||||
final String? errMsg;
|
final String? errMsg;
|
||||||
const Error(this.errMsg);
|
const Error(this.errMsg, {this.code});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool operator ==(Object other) {
|
bool operator ==(Object other) {
|
||||||
|
|||||||
@@ -131,8 +131,9 @@ abstract class ReplyController<R> extends CommonListController<R, ReplyInfo> {
|
|||||||
int? replyType,
|
int? replyType,
|
||||||
}) {
|
}) {
|
||||||
if (loadingState.value case Error error) {
|
if (loadingState.value case Error error) {
|
||||||
if (error.errMsg?.contains('关闭评论区') == true) {
|
final errMsg = error.errMsg;
|
||||||
SmartDialog.showToast(error.errMsg!);
|
if (errMsg != null && (error.code == 12061 || error.code == 12002)) {
|
||||||
|
SmartDialog.showToast(errMsg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user