mirror of
https://codeberg.org/cage/tinmop/
synced 2025-06-05 01:09:17 +02:00
- added voting to polls;
- fixed poll's rendering.
This commit is contained in:
@@ -207,6 +207,8 @@
|
|||||||
|
|
||||||
(define-key "V" #'open-message-link *thread-keymap*)
|
(define-key "V" #'open-message-link *thread-keymap*)
|
||||||
|
|
||||||
|
(define-key "P" #'poll-vote *thread-keymap*)
|
||||||
|
|
||||||
(define-key "C-c u" #'update-conversations *thread-keymap*)
|
(define-key "C-c u" #'update-conversations *thread-keymap*)
|
||||||
|
|
||||||
(define-key "C-c o" #'open-conversation *thread-keymap*)
|
(define-key "C-c o" #'open-conversation *thread-keymap*)
|
||||||
|
4
po/it.po
4
po/it.po
@@ -9,7 +9,7 @@ msgstr ""
|
|||||||
"Project-Id-Version: tinmop 0.0.1\n"
|
"Project-Id-Version: tinmop 0.0.1\n"
|
||||||
"Report-Msgid-Bugs-To: https://notabug.org/cage/tinmop/\n"
|
"Report-Msgid-Bugs-To: https://notabug.org/cage/tinmop/\n"
|
||||||
"POT-Creation-Date: 2020-05-31 12:44+0200\n"
|
"POT-Creation-Date: 2020-05-31 12:44+0200\n"
|
||||||
"PO-Revision-Date: 2020-05-31 12:46+0200\n"
|
"PO-Revision-Date: 2020-05-31 16:48+0200\n"
|
||||||
"Last-Translator: cage <cage@invalid.org>\n"
|
"Last-Translator: cage <cage@invalid.org>\n"
|
||||||
"Language-Team: Italian\n"
|
"Language-Team: Italian\n"
|
||||||
"Language: it\n"
|
"Language: it\n"
|
||||||
@@ -568,7 +568,7 @@ msgstr "Messaggi scaricati"
|
|||||||
|
|
||||||
#: src/ui-goodies.lisp:570
|
#: src/ui-goodies.lisp:570
|
||||||
msgid "Expanding thread"
|
msgid "Expanding thread"
|
||||||
msgstr "Espandi l'albero deimessaggi"
|
msgstr "Espandi l'albero dei messaggi"
|
||||||
|
|
||||||
#: src/ui-goodies.lisp:592
|
#: src/ui-goodies.lisp:592
|
||||||
msgid "Downloading tags messages."
|
msgid "Downloading tags messages."
|
||||||
|
@@ -598,6 +598,16 @@ returns nil if the credentials are invalid"
|
|||||||
(assert (stringp id))
|
(assert (stringp id))
|
||||||
(tooter:polls *client* id))
|
(tooter:polls *client* id))
|
||||||
|
|
||||||
|
(defun-w-lock poll-vote (poll-id choices)
|
||||||
|
*client-lock*
|
||||||
|
"Vote for a poll identified by `poll-id', choices is a list of
|
||||||
|
numerical indices identifying the option voting for"
|
||||||
|
(assert (every (lambda (a)
|
||||||
|
(or (numberp a)
|
||||||
|
(parse-integer a :radix 10)))
|
||||||
|
choices))
|
||||||
|
(tooter:poll-vote *client* poll-id choices))
|
||||||
|
|
||||||
(defun-w-lock get-notifications (&key
|
(defun-w-lock get-notifications (&key
|
||||||
(max-id nil)
|
(max-id nil)
|
||||||
(min-id nil)
|
(min-id nil)
|
||||||
|
@@ -241,7 +241,7 @@
|
|||||||
(max-title-w (find-max-line-length all-titles))
|
(max-title-w (find-max-line-length all-titles))
|
||||||
(max-bar-width (- width max-title-w 6))
|
(max-bar-width (- width max-title-w 6))
|
||||||
(bar-char (swconf:vote-vertical-bar)))
|
(bar-char (swconf:vote-vertical-bar)))
|
||||||
(let ((expiredp (db:row-poll-expired-p poll)))
|
(let ((expiredp (db:row-poll-expired-p poll)))
|
||||||
(with-output-to-string (stream)
|
(with-output-to-string (stream)
|
||||||
(loop for option in options do
|
(loop for option in options do
|
||||||
(let* ((title (left-padding (db:row-title option) max-title-w))
|
(let* ((title (left-padding (db:row-title option) max-title-w))
|
||||||
@@ -254,6 +254,7 @@
|
|||||||
(format stream "~a " title)
|
(format stream "~a " title)
|
||||||
(loop for i from 0 below bar-w do
|
(loop for i from 0 below bar-w do
|
||||||
(princ bar-char stream))
|
(princ bar-char stream))
|
||||||
(format stream " ~a~%" (left-padding vote (- max-bar-width bar-w)))))
|
(format stream " ~a~%" (left-padding vote (+ 4 ; size of vote percent: ' nnn%'
|
||||||
|
(- max-bar-width bar-w))))))
|
||||||
(when expiredp
|
(when expiredp
|
||||||
(format stream "~%~a~%" (_ "The poll has expired"))))))))
|
(format stream "~%~a~%" (_ "The poll has expired"))))))))
|
||||||
|
@@ -1161,6 +1161,7 @@
|
|||||||
:expand-thread-event
|
:expand-thread-event
|
||||||
:report-status-event
|
:report-status-event
|
||||||
:add-crypto-data-event
|
:add-crypto-data-event
|
||||||
|
:poll-vote-event
|
||||||
:function-event
|
:function-event
|
||||||
:dispatch-program-events
|
:dispatch-program-events
|
||||||
:add-pagination-status-event
|
:add-pagination-status-event
|
||||||
@@ -1217,6 +1218,7 @@
|
|||||||
:bookmark
|
:bookmark
|
||||||
:unbookmark
|
:unbookmark
|
||||||
:polls
|
:polls
|
||||||
|
:poll-vote
|
||||||
:get-notifications
|
:get-notifications
|
||||||
:delete-notification
|
:delete-notification
|
||||||
:all-mentions
|
:all-mentions
|
||||||
@@ -1965,7 +1967,8 @@
|
|||||||
:crypto-export-key
|
:crypto-export-key
|
||||||
:crypto-generate-key
|
:crypto-generate-key
|
||||||
:show-about-window
|
:show-about-window
|
||||||
:reset-timeline-pagination))
|
:reset-timeline-pagination
|
||||||
|
:poll-vote))
|
||||||
|
|
||||||
(defpackage :modules
|
(defpackage :modules
|
||||||
(:use
|
(:use
|
||||||
|
@@ -193,7 +193,7 @@
|
|||||||
(defclass user-input-string-event (ask-user-input-string-event)
|
(defclass user-input-string-event (ask-user-input-string-event)
|
||||||
()
|
()
|
||||||
(:documentation "When user provided a string as this event is
|
(:documentation "When user provided a string as this event is
|
||||||
generated. When processed it just wlii notify the condition variable
|
generated. When processed it just will notify the condition variable
|
||||||
of the slots `command-window:event-to-answer' in the object
|
of the slots `command-window:event-to-answer' in the object
|
||||||
`specials:*command-window*' so that the callee thread can restart
|
`specials:*command-window*' so that the callee thread can restart
|
||||||
the computation with the input."))
|
the computation with the input."))
|
||||||
@@ -811,6 +811,22 @@
|
|||||||
(folder folder)) object
|
(folder folder)) object
|
||||||
(db:add-to-pagination-status status-id folder timeline)))
|
(db:add-to-pagination-status status-id folder timeline)))
|
||||||
|
|
||||||
|
(defclass poll-vote-event (program-event)
|
||||||
|
((poll-id
|
||||||
|
:initform nil
|
||||||
|
:initarg :poll-id
|
||||||
|
:accessor poll-id)
|
||||||
|
(choices
|
||||||
|
:initform ()
|
||||||
|
:initarg :choices
|
||||||
|
:accessor choices)))
|
||||||
|
|
||||||
|
(defmethod process-event ((object poll-vote-event))
|
||||||
|
(with-accessors ((poll-id poll-id)
|
||||||
|
(choices choices)) object
|
||||||
|
(tui:with-notify-errors
|
||||||
|
(api-client:poll-vote poll-id choices))))
|
||||||
|
|
||||||
(defclass function-event (program-event) ())
|
(defclass function-event (program-event) ())
|
||||||
|
|
||||||
(defmethod process-event ((object function-event))
|
(defmethod process-event ((object function-event))
|
||||||
|
@@ -1245,3 +1245,45 @@ This command will remove those limits so that we can just jump to the last messa
|
|||||||
(folder (thread-window:timeline-folder specials:*thread-window*)))
|
(folder (thread-window:timeline-folder specials:*thread-window*)))
|
||||||
(with-blocking-notify-procedure ((_ "Clearing pagination data"))
|
(with-blocking-notify-procedure ((_ "Clearing pagination data"))
|
||||||
(db:remove-pagination-status folder timeline))))
|
(db:remove-pagination-status folder timeline))))
|
||||||
|
|
||||||
|
(defun poll-vote ()
|
||||||
|
"Change timeline"
|
||||||
|
(labels ((valid-indices-p (choices options)
|
||||||
|
(let ((max-index (length options)))
|
||||||
|
(every (lambda (a) (and (>= a 0)
|
||||||
|
(< a max-index)))
|
||||||
|
choices)))
|
||||||
|
(on-input-complete (choices)
|
||||||
|
(let ((choices-list (split-words choices)))
|
||||||
|
(if (or (null choices-list)
|
||||||
|
(notevery (lambda (a)
|
||||||
|
(let ((idx (parse-integer a :junk-allowed t)))
|
||||||
|
(and idx
|
||||||
|
(>= idx 0))))
|
||||||
|
choices-list))
|
||||||
|
(error-message
|
||||||
|
(_ "Invalid choices, usa a space separated list of positive integers."))
|
||||||
|
(db-utils:with-ready-database (:connect nil)
|
||||||
|
(when-let* ((fields (line-oriented-window:selected-row-fields
|
||||||
|
specials:*thread-window*))
|
||||||
|
(status-id (db:row-message-status-id fields))
|
||||||
|
(poll (db:find-poll-bound-to-status status-id))
|
||||||
|
(poll-id (db:row-id poll))
|
||||||
|
(event (make-instance 'poll-vote-event
|
||||||
|
:poll-id poll-id
|
||||||
|
:choices choices-list))
|
||||||
|
(actual-choices (mapcar (lambda (a)
|
||||||
|
(parse-integer a :junk-allowed t))
|
||||||
|
choices-list))
|
||||||
|
(options (db:all-poll-options poll-id)))
|
||||||
|
(if (not (valid-indices-p actual-choices options))
|
||||||
|
(error-message
|
||||||
|
(format nil
|
||||||
|
(_ "Invalid choices, index choice out of range (max ~a).")
|
||||||
|
(1- (length options))))
|
||||||
|
(with-blocking-notify-procedure ((_ "Voting... ")
|
||||||
|
(_ "Choice sent."))
|
||||||
|
(push-event event)))))))))
|
||||||
|
(ask-string-input #'on-input-complete
|
||||||
|
:prompt
|
||||||
|
(_ "Type the index (or space separated indices) of selected choices: "))))
|
||||||
|
Reference in New Issue
Block a user