mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-04-20 11:08:03 +08:00
@@ -1,5 +1,6 @@
|
||||
import 'package:PiliPlus/common/widgets/dialog/dialog.dart';
|
||||
import 'package:PiliPlus/http/dynamics.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/http/msg.dart';
|
||||
import 'package:PiliPlus/models/dynamics/vote_model.dart';
|
||||
import 'package:PiliPlus/utils/accounts.dart';
|
||||
@@ -56,15 +57,16 @@ class CreateVoteController extends GetxController {
|
||||
|
||||
Future<void> queryData() async {
|
||||
final res = await DynamicsHttp.voteInfo(voteId);
|
||||
if (res.isSuccess) {
|
||||
if (res case Success(:final response)) {
|
||||
key = Utils.generateRandomString(6);
|
||||
final VoteInfo data = res.data;
|
||||
title.value = data.title!;
|
||||
desc.value = data.desc ?? '';
|
||||
type.value = data.options.first.imgUrl?.isNotEmpty == true ? 1 : 0;
|
||||
options.value = data.options;
|
||||
choiceCnt.value = data.choiceCnt!;
|
||||
endtime.value = DateTime.fromMillisecondsSinceEpoch(data.endTime! * 1000);
|
||||
title.value = response.title!;
|
||||
desc.value = response.desc ?? '';
|
||||
type.value = response.options.first.imgUrl?.isNotEmpty == true ? 1 : 0;
|
||||
options.value = response.options;
|
||||
choiceCnt.value = response.choiceCnt!;
|
||||
endtime.value = DateTime.fromMillisecondsSinceEpoch(
|
||||
response.endTime! * 1000,
|
||||
);
|
||||
canCreate.value = true;
|
||||
} else {
|
||||
showConfirmDialog(
|
||||
@@ -98,8 +100,8 @@ class CreateVoteController extends GetxController {
|
||||
final res = await (voteId == null
|
||||
? DynamicsHttp.createVote(voteInfo)
|
||||
: DynamicsHttp.updateVote(voteInfo));
|
||||
if (res.isSuccess) {
|
||||
voteInfo.voteId = res.data;
|
||||
if (res case Success(:final response)) {
|
||||
voteInfo.voteId = response;
|
||||
Get.back(result: voteInfo);
|
||||
} else {
|
||||
res.toast();
|
||||
@@ -112,9 +114,9 @@ class CreateVoteController extends GetxController {
|
||||
category: 'daily',
|
||||
biz: 'vote',
|
||||
);
|
||||
if (res.isSuccess) {
|
||||
if (res case Success(:final response)) {
|
||||
options
|
||||
..[index].imgUrl = res.data.imageUrl
|
||||
..[index].imgUrl = response.imageUrl
|
||||
..refresh();
|
||||
updateCanCreate();
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user