From f238a32c5bbe3131efb7c53a6f89f9f217eac4e0 Mon Sep 17 00:00:00 2001 From: Skylar Hill Date: Thu, 8 Dec 2022 22:55:05 -0600 Subject: mastodon-tl--spoiler: Add error handling to /preferences api query mastodon.el currently breaks when trying to load a spoilered toot if the /preferences endpoint returns something unexpected, preventing mastodon-tl--buffer-spec from being set and not automatically enabling the major mode. This is particularly a problem on GoToSocial, which does not currently have the endpoint implemented and instead returns a 404 HTML page, causing a JSON parsing error. This PR adds a simple check which causes the API check in mastodon-tl--spoiler to return null if it errors, thus triggering the default behavior of hiding CW'd toots until opened. --- lisp/mastodon-tl.el | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lisp') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index e732420..41368e8 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -1044,8 +1044,12 @@ message is a link which unhides/hides the main body." 'invisible ;; check server setting to expand all spoilers: (unless (eq t - (mastodon-profile--get-preferences-pref - 'reading:expand:spoilers)) + ;; If something goes wrong reading prefs, + ;; just return nil so CWs show by default. + (condition-case nil + (mastodon-profile--get-preferences-pref + 'reading:expand:spoilers) + (error nil))) t) 'mastodon-content-warning-body t)))) -- cgit v1.2.3