1
0
mirror of https://codeberg.org/cage/tinmop/ synced 2024-12-16 23:08:34 +01:00

- [gemini]

- added command to refresh all gemlogs;
  - added scheduled refresh of all gemlogs;
  - fixed sorting of gemlog posts.
This commit is contained in:
cage 2021-01-10 13:01:03 +01:00
parent f09b0f4aa3
commit 44b6c62e44
6 changed files with 51 additions and 21 deletions

View File

@ -145,7 +145,9 @@
(define-key "M-c" #'open-chats-list-window)
(define-key "M-g s" #'gemini-open-gemlog-window)
(define-key "M-g s o" #'gemini-open-gemlog-window)
(define-key "M-g s r" #'gemlog-refresh-all)
;; focus

View File

@ -2947,6 +2947,8 @@ than `days-in-the-past' days (default: `(swconf:config-purge-cache-days-offset)'
(gen-access-message-row post-link :post-link)
(gen-access-message-row post-seenp :seenp)
(defun gemlog-entries (gemlog-url &key (unseen-only nil) (seen-only nil))
(assert (not (and unseen-only
seen-only)))
@ -2972,18 +2974,22 @@ than `days-in-the-past' days (default: `(swconf:config-purge-cache-days-offset)'
unordered-rows))
(t
unordered-rows))))
(num:multisort actual-rows (list (num:gen-multisort-test string>
(num:multisort actual-rows (list (num:gen-multisort-test (lambda (a b)
(if (and (db-nil-p a)
(db-nil-p b))
a
(db-nil-p a)))
(lambda (a b)
(if (and (db-nil-p a)
(db-nil-p b))
b
(db-nil-p b)))
(lambda (a)
(db-getf a :seenp)))
(num:gen-multisort-test string>
string<
(lambda (a)
(row-post-date a)))
(num:gen-multisort-test (lambda (a b)
(declare (ignore a))
(db-nil-p b))
(lambda (a b)
(declare (ignore b))
(db-nil-p a))
(lambda (a)
(db-getf a :seenp)))))))
(row-post-date a)))))))
(defun delete-gemlog-entry (gemlog-url)
(query (delete-from +table-gemlog-entries+ (where (:= :url gemlog-url)))))

View File

@ -966,6 +966,7 @@
:row-post-date
:row-post-title
:row-post-link
:row-post-seenp
:gemlog-entries
:delete-gemlog-entry))
@ -1351,6 +1352,7 @@
:gemini-gemlog-subscribe-event
:gemlog-cancel-subscription-event
:gemlog-show-event
:gemlog-refresh-all-event
:get-chat-messages-event
:get-chats-event
:chat-show-event
@ -2391,6 +2393,7 @@
:gemlogs-subscription-go-down
:close-gemlog-window
:show-gemlog-to-screen
:gemlog-refresh-all
:gemlog-cancel-subscription
:send-to-pipe
:send-message-to-pipe))

View File

@ -1199,11 +1199,13 @@
(encoded-date (db-utils:encode-datetime-string date))
(title (text-utils:strcat (format-time encoded-date date-format)
" "
(db:row-post-title entry))))
(db:row-post-title entry)))
(seenp (db:row-post-seenp entry)))
(format stream
"~a~%"
(_ "~a ~:[(not opened)~;(opened)~]~%")
(gemini-parser:make-gemini-link link
title))))))
title)
seenp)))))
(url (iri:iri-parse gemlog-url))
(parsed (gemini-parser:parse-gemini-file gemini-page))
(links (gemini-parser:sexp->links parsed
@ -1220,6 +1222,13 @@
keybindings:*gemini-message-keymap*)
(windows:draw specials:*message-window*))))
(defclass gemlog-refresh-all-event (program-event) ())
(defmethod process-event ((object gemlog-refresh-all-event))
(let ((all-subscribed-gemlogs (mapcar #'db:row-url (db:gemini-all-subscriptions))))
(loop for subscription in all-subscribed-gemlogs do
(gemini-subscription:refresh subscription))))
;;;; pleroma
(defclass get-chat-messages-event (program-event)

View File

@ -17,9 +17,11 @@
(in-package :scheduled-events)
(define-constant +refresh-all-chats-data-frequency+ 10000 :test #'=)
(define-constant +refresh-all-chats-data-frequency+ 10000 :test #'=)
(define-constant +refresh-all-chats-messages-frequency+ 50 :test #'=)
(define-constant +refresh-all-chats-messages-frequency+ 50 :test #'=)
(define-constant +refresh-gemlog-subscriptions-frequency+ 50000 :test #'=)
(defun triggedp (ticks frequency)
(= (rem ticks frequency)
@ -30,12 +32,16 @@
(when (triggedp ticks ,frequency)
,@body-if-triggered)))
(gen-scheduler-function (refresh-refresh-all-chats-data
(gen-scheduler-function (refresh-all-chats-data
+refresh-all-chats-data-frequency+)
(ui:notify (_ "Updating all chats."))
(ui:update-all-chats-data))
(gen-scheduler-function (refresh-refresh-all-chats-messages
(gen-scheduler-function (refresh-gemlog-subscriptions
+refresh-gemlog-subscriptions-frequency+)
(ui:gemlog-refresh-all))
(gen-scheduler-function (refresh-all-chats-messages
+refresh-all-chats-messages-frequency+)
(when (message-window:display-chat-p *message-window*)
(ui:update-all-chats-messages)
@ -44,5 +50,6 @@
(program-events:push-event show-event))))
(defun run-scheduled-events (ticks)
(refresh-refresh-all-chats-messages ticks)
(refresh-refresh-all-chats-data ticks))
(refresh-all-chats-messages ticks)
(refresh-all-chats-data ticks)
(refresh-gemlog-subscriptions ticks))

View File

@ -1256,7 +1256,7 @@ certificate).
(with-blocking-notify-procedure ((format nil (_ "Canceling subscription for ~s") gemlog-id))
(program-events:push-event event)))))
(defun show-gemlog-to-screen ()
(defun show-gemlog-to-screen ()
(with-selected-gemlog-id (fields gemlog-id)
(when-let* ((entries (db:gemlog-entries gemlog-id))
(event (make-instance 'program-events:gemlog-show-event
@ -1267,6 +1267,9 @@ certificate).
(program-events:push-event event)
(focus-to-message-window))))
(defun gemlog-refresh-all ()
(with-blocking-notify-procedure ((_ "updating gemlog's subscriptions"))
(program-events:push-event (make-instance 'program-events:gemlog-refresh-all-event))))
(defun prompt-for-username (prompt complete-function event
notify-starting-message