kidd / org-gcal.el

Org sync with Google Calendar. (active maintained project as of 2019-11-06)
439 stars 47 forks source link

Decrypt prompt disappears before I can type in the password #252

Open cashpw opened 3 months ago

cashpw commented 3 months ago

Problem:

The decrypt password prompt disappears before I can type in the password (1-2 seconds). The only output in *Messages* is:

Decrypting /<omitted>/.config/emacs/.local/cache/oauth2-auto.plist...0%

Solutions:

  1. ~Figure out why it's disappearing and fix the root issue~

    I've tried for ~3 hours and don't want to put more time into it.

  2. Get and cache the access token outside of the =deferred= block!

(after!
  org-gcal

  (defun cashpw/org-gcal--get-access-token (&rest r)
    "Call `org-gcal--get-access-token' for the first calendar in the list."
    (org-gcal--get-access-token (car (car org-gcal-file-alist))))

  (advice-add 'org-gcal-sync :before #'cashpw/org-gcal--get-access-token)

  (defvar org-gcal--access-token nil
    "Set if a sync function is running.")

  (defun org-gcal--sync-unlock ()
    "Deactivate sync lock in case of failed sync."
    (interactive)
    (setq
     org-gcal--sync-lock nil
     org-gcal--access-token nil))

  (defun org-gcal--get-access-token (calendar-id)
    "Return the access token for CALENDAR-ID."
    (if org-gcal--access-token
        org-gcal--access-token
      (setq org-gcal--access-token
      (aio-wait-for (oauth2-auto-access-token calendar-id 'org-gcal))))))