develop-polls #93
@@ -1,5 +1,4 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:developer';
|
|
||||||
|
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
import 'package:http/http.dart';
|
import 'package:http/http.dart';
|
||||||
@@ -8,22 +7,18 @@ import '../getPoll/getPollStateResponse.dart';
|
|||||||
import '../talkApi.dart';
|
import '../talkApi.dart';
|
||||||
import 'votePollParams.dart';
|
import 'votePollParams.dart';
|
||||||
|
|
||||||
@Deprecated('VotePoll is broken (known issues)')
|
@Deprecated('VotePoll is broken')
|
||||||
class VotePoll extends TalkApi {
|
class VotePoll extends TalkApi {
|
||||||
String token;
|
String token;
|
||||||
int pollId;
|
int pollId;
|
||||||
VotePoll({required this.token, required this.pollId, required VotePollParams params}) : super('v1/poll/$token/$pollId', params);
|
VotePoll({required this.token, required this.pollId, required VotePollParams params}) : super('v1/poll/$token/$pollId', params);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
GetPollStateResponse assemble(String raw) {
|
GetPollStateResponse assemble(String raw) => GetPollStateResponse.fromJson(jsonDecode(raw)['ocs']);
|
||||||
log(raw);
|
|
||||||
return GetPollStateResponse.fromJson(jsonDecode(raw)['ocs']);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
Pupsi marked this conversation as resolved
|
|||||||
Future<Response>? request(Uri uri, Object? body, Map<String, String>? headers) {
|
Future<Response>? request(Uri uri, Object? body, Map<String, String>? headers) {
|
||||||
if(body is VotePollParams) {
|
if(body is VotePollParams) {
|
||||||
log(body.toJson().toString());
|
|
||||||
return http.post(uri, headers: headers, body: body.toJson().toString());
|
return http.post(uri, headers: headers, body: body.toJson().toString());
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -5,10 +5,11 @@ import '../../../apiParams.dart';
|
|||||||
part 'votePollParams.g.dart';
|
part 'votePollParams.g.dart';
|
||||||
|
|
||||||
@JsonSerializable()
|
@JsonSerializable()
|
||||||
|
@Deprecated('VotePoll is broken')
|
||||||
class VotePollParams extends ApiParams {
|
class VotePollParams extends ApiParams {
|
||||||
List<int> optionIds;
|
List<int> optionIds;
|
||||||
|
|
||||||
VotePollParams({required this.optionIds});
|
VotePollParams({required this.optionIds});
|
||||||
factory VotePollParams.fromJson(Map<String, dynamic> json) => _$VotePollParamsFromJson(json);
|
factory VotePollParams.fromJson(Map<String, dynamic> json) => _$VotePollParamsFromJson(json);
|
||||||
Map<String, dynamic> toJson() => _$VotePollParamsToJson(this);
|
Map<String, dynamic> toJson() => _$VotePollParamsToJson(this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -304,7 +304,7 @@ class _ChatBubbleState extends State<ChatBubble> with SingleTickerProviderStateM
|
|||||||
var pollId = int.parse(message.originalData!['object']!.id);
|
var pollId = int.parse(message.originalData!['object']!.id);
|
||||||
var pollState = GetPollState(token: widget.bubbleData.token, pollId: pollId).run();
|
var pollState = GetPollState(token: widget.bubbleData.token, pollId: pollId).run();
|
||||||
showDialog(context: context, builder: (context) => AlertDialog(
|
showDialog(context: context, builder: (context) => AlertDialog(
|
||||||
title: Text(message.originalData!['object']!.name, textScaler: TextScaler.linear(0.9), overflow: TextOverflow.ellipsis),
|
title: Text(message.originalData!['object']!.name, overflow: TextOverflow.ellipsis),
|
||||||
|
Pupsi marked this conversation as resolved
Outdated
MineTec
commented
ist der scale an andern stellen auch so präsent? ist der scale an andern stellen auch so präsent?
|
|||||||
content: FutureBuilder(
|
content: FutureBuilder(
|
||||||
future: pollState,
|
future: pollState,
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
|
|||||||
@@ -22,8 +22,9 @@ class _PollOptionsListState extends State<PollOptionsList> {
|
|||||||
var optionId = widget.pollData.options.indexOf(option);
|
var optionId = widget.pollData.options.indexOf(option);
|
||||||
var votedSelf = widget.pollData.votedSelf.contains(optionId);
|
var votedSelf = widget.pollData.votedSelf.contains(optionId);
|
||||||
var portionsVisible = widget.pollData.votes is Map<String, dynamic>;
|
var portionsVisible = widget.pollData.votes is Map<String, dynamic>;
|
||||||
var votes = !portionsVisible ? 0
|
var votes = portionsVisible
|
||||||
|
Pupsi marked this conversation as resolved
Outdated
MineTec
commented
format ist komisch format ist komisch
|
|||||||
: (widget.pollData.votes['option-$optionId'] as num?) ?? 0;
|
? (widget.pollData.votes['option-$optionId'] as num?) ?? 0
|
||||||
|
: 0;
|
||||||
var numVoters = widget.pollData.numVoters ?? 0;
|
var numVoters = widget.pollData.numVoters ?? 0;
|
||||||
double portion = numVoters == 0 ? 0 : (votes / numVoters);
|
double portion = numVoters == 0 ? 0 : (votes / numVoters);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user
log?