Function: forge--update-status

forge--update-status is a byte-compiled function defined in forge-github.el.

Signature

(forge--update-status ARG &rest ARGS)

Implementations

(forge--update-status (REPO forge-github-repository) TOPIC DATA BUMP INITIAL-PULL) in `forge-github.el'.

Undocumented

Source Code

;; Defined in ~/.emacs.d/elpa/forge-20260408.1922/forge-github.el
(cl-defmethod forge--update-status ((repo forge-github-repository)
                                    topic data bump initial-pull)
  (let-alist data
    (let ((updated (or .updatedAt .createdAt))
          (current-status (oref topic status)))
      (if (forge-discussion-p topic)
          ;; Discussions lack `isReadByViewer', so we have to use a
          ;; heuristic, which is even worse than what we use for other
          ;; topic types.  Except during the repository's initial pull,
          ;; all new discussions start out as `unread'.
          ;;
          ;; If we pull a discussion after the user mutated it, setting
          ;; the status to `unread' is highly undesirable (since they made
          ;; the mutation, they have already "read" it), yet that is what
          ;; we do here.  However, the callback used by the discussion
          ;; method of `forge--pull-topic', afterwards resets the status
          ;; to the previous value.
          ;;
          ;; Of course it is possible that we pull other changes by other
          ;; people at the same time, but we have no (reasonable) way of
          ;; knowing that.  So in that case too the status sadly doesn't
          ;; end up as `unread'.
          ;;
          ;; The callback kludge is not needed for all mutations.  Some
          ;; mutations (e.g., setting labels) do not cause `updated_at'
          ;; to be bumped; this second defect cancels out the first.
          (cond (initial-pull
                 (oset topic status 'done))
                ((null current-status)
                 (oset topic status 'unread))
                ((string> updated (oref topic updated))
                 (oset topic status 'unread)))
        (cond ((not .isReadByViewer)
               (oset topic status 'unread))
              (initial-pull
               (oset topic status 'done))
              ((null current-status)
               (oset topic status 'pending))
              ((string> updated (oref topic updated))
               (oset topic status 'pending))))
      (oset topic updated updated)
      (when bump
        (let* ((slot (cl-typecase topic
                       (forge-discussion 'discussions-until)
                       (forge-issue      'issues-until)
                       (forge-pullreq    'pullreqs-until)))
               (until (eieio-oref repo slot)))
          (when (or (not until) (string> updated until))
            (eieio-oset repo slot updated)))))))