aboutsummaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/mastodon-tl.el53
1 files changed, 26 insertions, 27 deletions
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index 9f21bf9..dbeacab 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -1398,19 +1398,20 @@ Optionally get it for BUFFER."
(or buffer (current-buffer))))))
(defun mastodon-tl--set-buffer-spec (buffer endpoint update-function
- &optional link-header)
+ &optional link-header update-params)
"Set `mastodon-tl--buffer-spec' for the current buffer.
-
BUFFER is buffer name, ENDPOINT is buffer's enpoint,
UPDATE-FUNCTION is its update function.
-LINK-HEADER is the http Link header if present."
+LINK-HEADER is the http Link header if present.
+UPDATE-PARAMS is any http parameters needed for the update function."
(setq mastodon-tl--buffer-spec
`(account ,(cons mastodon-active-user
mastodon-instance-url)
buffer-name ,buffer
endpoint ,endpoint
update-function ,update-function
- link-header ,link-header)))
+ link-header ,link-header
+ update-params ,update-params)))
(defun mastodon-tl--more-json (endpoint id)
"Return JSON for timeline ENDPOINT before ID."
@@ -1420,10 +1421,11 @@ LINK-HEADER is the http Link header if present."
(defun mastodon-tl--more-json-async (endpoint id &optional params callback &rest cbargs)
"Return JSON for timeline ENDPOINT before ID.
-Then run CALLBACK with arguments CBARGS
-PARAMS is used to send 'local=true' for local timeline."
+Then run CALLBACK with arguments CBARGS.
+PARAMS is used to send any parameters needed to correctly update
+the current view."
(let* ((args `(("max_id" . ,(mastodon-tl--as-string id))))
- (args (if params (push params args) args))
+ (args (if params (push (car args) params) args))
(url (mastodon-http--api endpoint)))
(apply 'mastodon-http--get-json-async url args callback cbargs)))
@@ -1431,9 +1433,10 @@ PARAMS is used to send 'local=true' for local timeline."
;; Look into the JSON returned here by Local
(defun mastodon-tl--updated-json (endpoint id &optional params)
"Return JSON for timeline ENDPOINT since ID.
-PARAMS are any parameters to send with the request."
+PARAMS is used to send any parameters needed to correctly update
+the current view."
(let* ((args `(("since_id" . ,(mastodon-tl--as-string id))))
- (args (if params (push params args) args))
+ (args (if params (push (car args) params) args))
(url (mastodon-http--api endpoint)))
(mastodon-http--get-json url args)))
@@ -2604,9 +2607,7 @@ when showing followers or accounts followed."
(mastodon-tl--more-json-async
(mastodon-tl--get-endpoint)
(mastodon-tl--oldest-id)
- ;; local has same endpoint as federated:
- (when (string= (mastodon-tl--buffer-name) "*mastodon-local*")
- '("local" . "true"))
+ (mastodon-tl--get-buffer-property 'update-params)
'mastodon-tl--more* (current-buffer) (point))))
(defun mastodon-tl--more* (response buffer point-before &optional headers)
@@ -2811,8 +2812,7 @@ This location is defined by a non-nil value of
(funcall update-function thread-id)
;; update other timelines:
(let* ((id (mastodon-tl--newest-id))
- (params (when (string= (mastodon-tl--buffer-name) "*mastodon-local*")
- '("local" . "true")))
+ (params (mastodon-tl--get-buffer-property 'update-params))
(json (mastodon-tl--updated-json endpoint id params)))
(if json
(let ((inhibit-read-only t))
@@ -2833,17 +2833,17 @@ This location is defined by a non-nil value of
UPDATE-FUNCTION is used to recieve more toots.
HEADERS means to also collect the response headers. Used for paginating
favourites and bookmarks.
-PARAMS is any parameters to send with the request, currently only
-used to send 'local=true' for local timeline."
+PARAMS is any parameters to send with the request."
(let ((url (mastodon-http--api endpoint))
(buffer (concat "*mastodon-" buffer-name "*")))
(if headers
(mastodon-http--get-response-async
- url params 'mastodon-tl--init* buffer endpoint update-function headers)
+ url params 'mastodon-tl--init* buffer endpoint update-function headers params)
(mastodon-http--get-json-async
- url params 'mastodon-tl--init* buffer endpoint update-function))))
+ url params 'mastodon-tl--init* buffer endpoint update-function nil params))))
-(defun mastodon-tl--init* (response buffer endpoint update-function &optional headers)
+(defun mastodon-tl--init* (response buffer endpoint update-function
+ &optional headers update-params)
"Initialize BUFFER with timeline targeted by ENDPOINT.
UPDATE-FUNCTION is used to recieve more toots.
RESPONSE is the data returned from the server by
@@ -2863,7 +2863,8 @@ JSON and http headers, without it just the JSON."
(mastodon-tl--set-buffer-spec buffer
endpoint
update-function
- link-header)
+ link-header
+ update-params)
(setq
;; Initialize with a minimal interval; we re-scan at least once
;; every 5 minutes to catch any timestamps we may have missed
@@ -2875,7 +2876,8 @@ JSON and http headers, without it just the JSON."
(mastodon-tl--set-buffer-spec buffer
endpoint
update-function
- link-header)
+ link-header
+ update-params)
(setq mastodon-tl--timestamp-update-timer
(when mastodon-tl--enable-relative-timestamps
(run-at-time (time-to-seconds
@@ -2899,11 +2901,8 @@ Optional arg NOTE-TYPE means only get that type of note."
(mastodon-notifications--filter-types-list note-type)))
(args (when note-type (mastodon-http--build-array-params-alist
"exclude_types[]" exclude-types)))
- ;; (query-string (when note-type
- ;; (mastodon-http--build-params-string args)))
- ;; add note-type exclusions to endpoint so it works in `mastodon-tl--buffer-spec'
- ;; that way `mastodon-tl--more' works seamlessly too:
- ;; (endpoint (if note-type (concat endpoint "?" query-string) endpoint))
+ ;; NB: we now store 'update-params separately in `mastodon-tl--buffer-spec'
+ ;; and -http.el handles all conversion of params alists into query strings.
(url (mastodon-http--api endpoint))
(buffer (concat "*mastodon-" buffer-name "*"))
(json (mastodon-http--get-json url args)))
@@ -2922,7 +2921,7 @@ Optional arg NOTE-TYPE means only get that type of note."
(funcall update-function json))
(mastodon-mode)
(with-current-buffer buffer
- (mastodon-tl--set-buffer-spec buffer endpoint update-function)
+ (mastodon-tl--set-buffer-spec buffer endpoint update-function nil args)
(setq mastodon-tl--timestamp-update-timer
(when mastodon-tl--enable-relative-timestamps
(run-at-time (time-to-seconds