Skip to content

Commit 9d35d84

Browse files
committed
Add documentation comments and downgrade metadata version
- Added detailed comments to improve code readability and maintainability in `extension.js` and `prefs.js`. - Downgraded metadata version from 4 to 3 in `metadata.json`.
1 parent 3177ea9 commit 9d35d84

File tree

3 files changed

+55
-1
lines changed

3 files changed

+55
-1
lines changed

extension.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
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+
114
import Gio from 'gi://Gio';
215
import GLib from 'gi://GLib';
316
import GObject from 'gi://GObject';
@@ -9,6 +22,11 @@ import * as PanelMenu from 'resource:///org/gnome/shell/ui/panelMenu.js';
922
import * as PopupMenu from 'resource:///org/gnome/shell/ui/popupMenu.js';
1023
import * 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+
*/
1230
const 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+
*/
234275
export default class MatrixExtension extends Extension {
235276
enable() {
236277
this._settings = this.getSettings();

metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "Matrix Status Monitor",
33
"description": "High-performance Matrix notification monitor for GNOME Shell.",
44
"uuid": "matrix-status@nurefexc.com",
5-
"version": 4,
5+
"version": 3,
66
"shell-version": ["45", "46", "47", "48", "49"],
77
"url": "https://github.com/nurefexc/matrix-status",
88
"gettext-domain": "matrix-status",

prefs.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,22 @@
1+
/*
2+
* Matrix Status Monitor – Preferences UI
3+
*
4+
* Here we define the Adwaita (libadwaita) interface for editing
5+
* GSettings keys: homeserver, token, sync interval, client type.
6+
*/
17
import { ExtensionPreferences } from 'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js';
28
import Adw from 'gi://Adw';
39
import Gio from 'gi://Gio';
410
import Gtk from 'gi://Gtk';
511
import GLib from 'gi://GLib';
612

13+
/**
14+
* Preferences window structure.
15+
* Layout:
16+
* 1) Matrix API (homeserver, access token)
17+
* 2) General settings (sync interval, client selector)
18+
* 3) Links/Info
19+
*/
720
export default class MatrixStatusPreferences extends ExtensionPreferences {
821
fillPreferencesWindow(window) {
922
const settings = this.getSettings();

0 commit comments

Comments
 (0)