1+ /*
2+ * Matrix Status Monitor – GNOME Shell extension
3+ *
4+ * Goal: Lightweight navigation and notification layer for Matrix in the GNOME panel.
5+ * Style: Readability, maintainability, minimal dependencies.
6+ *
7+ * Note to contributors:
8+ * - Keep network calls (Soup.Session) and UI building (PopupMenu)
9+ * clearly separated.
10+ * - All user settings are in GSettings (schemas/...).
11+ * - Targeted shell versions: GNOME 45–49.
12+ */
13+
114import Gio from 'gi://Gio' ;
215import GLib from 'gi://GLib' ;
316import GObject from 'gi://GObject' ;
@@ -9,6 +22,11 @@ import * as PanelMenu from 'resource:///org/gnome/shell/ui/panelMenu.js';
922import * as PopupMenu from 'resource:///org/gnome/shell/ui/popupMenu.js' ;
1023import * as Main from 'resource:///org/gnome/shell/ui/main.js' ;
1124
25+ /**
26+ * Indicator displayed on the panel and dropdown menu handling.
27+ * - Icon: matrix-symbolic
28+ * - Menu: Room list + Client launcher (Element/Fractal)
29+ */
1230const MatrixIndicator = GObject . registerClass (
1331 class MatrixIndicator extends PanelMenu . Button {
1432 _init ( settings , extensionPath ) {
@@ -46,6 +64,13 @@ const MatrixIndicator = GObject.registerClass(
4664 return roomId ? `element://vector/webapp/#/room/${ roomId } ` : 'element://' ;
4765 }
4866
67+ /**
68+ * Generate Fractal URI for a given room.
69+ * Example: matrix:roomid/<encoded_room_id>?action=join&via=<domain>
70+ * - Remove '!' prefix from the start of roomId
71+ * - ':' → '%3A' encoding
72+ * - 'via' parameter for the room domain (better discoverability on the network)
73+ */
4974 _getFractalUrl ( roomId = null ) {
5075 if ( ! roomId ) return 'matrix:' ;
5176
@@ -135,6 +160,11 @@ const MatrixIndicator = GObject.registerClass(
135160 }
136161 }
137162
163+ /**
164+ * Synchronization with Matrix Client API (/_matrix/client/v3/sync).
165+ * - Minimal filter: room name, tags, encryption flag
166+ * - Goal: Fast, lightweight list building (not message display)
167+ */
138168 async refresh ( ) {
139169 let homeserver = this . _settings . get_string ( 'homeserver-url' ) . trim ( ) ;
140170 const token = this . _settings . get_string ( 'access-token' ) . trim ( ) ;
@@ -174,6 +204,11 @@ const MatrixIndicator = GObject.registerClass(
174204 }
175205 }
176206
207+ /**
208+ * Process sync response and update menu/data state.
209+ * - Intelligent filtering: only unread or favorite rooms
210+ * - Sorting: based on last event timestamp (desc)
211+ */
177212 _processSync ( data ) {
178213 let roomList = [ ] ;
179214 let totalUnread = 0 ;
@@ -231,6 +266,12 @@ const MatrixIndicator = GObject.registerClass(
231266 }
232267 } ) ;
233268
269+ /**
270+ * Main extension lifecycle management (enable/disable).
271+ * - Settings initialization
272+ * - Indicator creation and registration in the panel
273+ * - Timer (sync) management
274+ */
234275export default class MatrixExtension extends Extension {
235276 enable ( ) {
236277 this . _settings = this . getSettings ( ) ;
0 commit comments