Browse Source

feat: save the ongoing poll on each judgment received

The resumed poll may be buggy ;
something about how we handle users
master
Dominique Merle 2 years ago
parent
commit
cf71ef4cce
  1. 2
      addons/majority_judgment/MajorityJudgmentPoll.gd
  2. 13
      addons/majority_judgment/nodes/MajorityJudgmentLinearResultsControl.gd
  3. 4
      gui/MainMenu.tscn

2
addons/majority_judgment/MajorityJudgmentPoll.gd

@ -128,7 +128,7 @@ func add_judgment(judgment:MajorityJudgmentJudgment) -> void:
func get_judgments() -> Array:
assert(judgments, "Poll has no judgments.")
# assert(judgments, "Poll has no judgments.")
return judgments

13
addons/majority_judgment/nodes/MajorityJudgmentLinearResultsControl.gd

@ -60,14 +60,11 @@ func set_poll(__poll:MajorityJudgmentPoll):
poll = __poll
craft_nodes()
update_scene()
App.save_ongoing_poll()
self.providers = App.get_providers()
for provider in self.providers:
start_provider(provider)
# var provider = MajorityJudgmentDemoProvider.new()
# var provider = MajorityJudgmentTwitchChatProvider.new()
# start_provider(provider)
func close_poll():
@ -234,7 +231,9 @@ func get_or_create_participant(identifier:String) -> MajorityJudgmentParticipant
if not known_participants.has(identifier):
known_participants[identifier] = MajorityJudgmentParticipant.make(identifier)
return known_participants[identifier]
var __save_mutex := Mutex.new() # perhaps overzealous
func __on_judgment_emitted(author_identifier, grade_index, candidate_index):
# Data comes from userland, best be careful here
@ -253,12 +252,16 @@ func __on_judgment_emitted(author_identifier, grade_index, candidate_index):
# printerr("Ignoring candidate %s since it's out of range." % [char(candidate_index)])
return
__save_mutex.lock()
var j = MajorityJudgmentJudgment.new()
j.set_participant(get_or_create_participant(author_identifier))
j.set_grade(poll.grading.grades[grade_index])
j.set_candidate(poll.candidates[candidate_index])
poll.add_judgment(j)
App.save_ongoing_poll()
__save_mutex.unlock()
update_scene()

4
gui/MainMenu.tscn

@ -25,9 +25,9 @@ __meta__ = {
[node name="VBoxContainer" type="VBoxContainer" parent="CenterContainer"]
margin_left = 218.0
margin_top = 290.0
margin_top = 260.0
margin_right = 382.0
margin_bottom = 510.0
margin_bottom = 540.0
[node name="ResumePollButton" type="Button" parent="CenterContainer/VBoxContainer"]
margin_right = 164.0

Loading…
Cancel
Save