feat(bridge,ui): sort channels by last activity
- Add last_post_at field to Channel model (Rust) - Sort channels by last_post_at descending in dashboard (Emacs)
This commit is contained in:
@@ -85,9 +85,12 @@ pub struct Channel {
|
||||
pub id: ChannelId,
|
||||
pub team_id: TeamId,
|
||||
#[serde(rename = "type")]
|
||||
pub channel_type: String, // "O" (Open), "P" (Private), "D" (Direct), "G" (Group)
|
||||
pub channel_type: String,
|
||||
pub display_name: String,
|
||||
pub name: String,
|
||||
/// Timestamp of the last post in this channel (milliseconds since epoch).
|
||||
#[serde(default)]
|
||||
pub last_post_at: i64,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
@@ -103,7 +106,6 @@ pub struct Post {
|
||||
#[serde(default)]
|
||||
pub file_ids: Vec<String>,
|
||||
/// Populated by the bridge after resolving user_id via /users/ids.
|
||||
/// Skipped during deserialization from Mattermost API.
|
||||
#[serde(default, skip_deserializing)]
|
||||
pub user_display_name: String,
|
||||
}
|
||||
|
||||
@@ -97,11 +97,20 @@
|
||||
'mm-channel-name label
|
||||
'mouse-face 'highlight))))
|
||||
|
||||
(defun mattermost--sort-channels-by-activity (channels)
|
||||
"Sort CHANNELS by last_post_at descending (most recent first)."
|
||||
(sort channels
|
||||
(lambda (a b)
|
||||
(> (or (plist-get a :last_post_at) 0)
|
||||
(or (plist-get b :last_post_at) 0)))))
|
||||
|
||||
(defun mattermost--render-dashboard (server-id channels teams)
|
||||
"Render CHANNELS grouped by TEAMS for SERVER-ID."
|
||||
(let ((buf (get-buffer-create "*Mattermost Dashboard*"))
|
||||
(by-team (make-hash-table :test 'equal))
|
||||
(dms nil))
|
||||
;; Сортируем каналы по активности
|
||||
(setq channels (mattermost--sort-channels-by-activity channels))
|
||||
(dolist (ch channels)
|
||||
(let ((type (plist-get ch :type)))
|
||||
(if (member type '("D" "G"))
|
||||
@@ -124,6 +133,7 @@
|
||||
(when chs
|
||||
(puthash tid t rendered)
|
||||
(mattermost--insert-team-header (plist-get team :display_name))
|
||||
;; Каналы уже отсортированы, просто реверсим для правильного порядка
|
||||
(dolist (ch (nreverse chs))
|
||||
(mattermost--insert-channel-line ch))
|
||||
(insert "\n"))))
|
||||
|
||||
Reference in New Issue
Block a user