yuya373 / emacs-slack

slack client for emacs
1.11k stars 117 forks source link

slack-channel-select a bit slow for large number of channels #504

Open bsless opened 4 years ago

bsless commented 4 years ago

Hi, I wanted to start by thanking all the people working on this project. It's awesome, lately its performance really improved, and I'm very happy with it :). I noticed that slack-channel-select can be a bit slow to return its results, and been wandering if it's possible to create a local cache of the last state. In theory there's only a need to check channels with unread messages for updates.

What do you think?

yuya373 commented 4 years ago

How many channels do you have?

bsless commented 4 years ago

I get a 100 in the helm popup but there are certainly more. Where would be a good place to check how many channels are returned?

yuya373 commented 4 years ago

If you change slack-channel-select as follows,CHANNELS: n will be displayed in the message buffer.

--- a/slack-message-buffer.el
+++ b/slack-message-buffer.el
@@ -843,11 +843,11 @@
 (defun slack-channel-select ()
   (interactive)
   (let* ((team (slack-team-select))
-         (room (slack-room-select
-                (cl-loop for team in (list team)
-                         for channels = (slack-team-channels team)
-                         nconc channels)
-                team)))
+         (channels (cl-loop for team in (list team)
+                            for channels = (slack-team-channels team)
+                            nconc channels))
+         (room (and (message "CHANNELS: %S" (length channels))
+                    (slack-room-select channels team))))
     (slack-room-display room team)))

 (cl-defmethod slack-buffer-display-im ((this slack-user-profile-buffer))
bsless commented 4 years ago

5110 channels

dyroffk commented 3 years ago

I've been experiencing this also -- it noticeably slows getting up and running after slack-start and searching slack-message-embed-channel

As another data point, our slack team has 4500 channels coming back Turns out, 2836 of ours are z-visitor-NNNNN channels which were created once upon a time when our organization was using Drift for customer support and they all appear to be archived. (:is_archived t)

I suspect a lot of this would be alleviated by filtering out archived channels when querying Slack if possible

dchenbecker commented 3 years ago

42563 channels. I'm working on a PR right now to add a defcustom to allow filtering archived channels. Beyond that, what would be the options for a persisted cache of the channels that can be refreshed asynchronously? I'm barely proficient in Elisp, but eager to help :)