Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ReleaseNotes.wiki
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
; Version 2.1.8 (Feb 3, 2026)
* Added 'X no. of comments on page' while viewing a page

; Version 2.1.7, Version 2.1.6 (Dec 19, 2025)
* Change logic to how an image gets uploaded

; Version 2.1.5 (Nov 24, 2025)
* Changed dutch i18n strings
* Fixed where if an error occured the i18n key instead of msg gets shown
Expand Down
5 changes: 3 additions & 2 deletions extension.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"Robin van der Wiel",
"Yvar Nanlohij"
],
"version": "2.1.7",
"version": "2.1.8",
"url": "https://www.archixl.nl",
"descriptionmsg": "sc-desc",
"license-name": "GPL-2.0+",
Expand Down Expand Up @@ -130,7 +130,8 @@
"sc-selection-generic-error",
"sc-show-screenshot-full-size",
"sc-broken-comments-below",
"sc-enabled-smartcomments"
"sc-enabled-smartcomments",
"sc-popup-msg"
]
}
},
Expand Down
3 changes: 1 addition & 2 deletions i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@
"sc-property-revision": "Revision",
"sc-property-position": "Position on page",
"sc-popup-title": "Replies",
"sc-popup-msg-single": "We found <strong>#X#</strong> comment in the current revision of this page. You can view it by enabling the comment mode.",
"sc-popup-msg-multiple": "We found <strong>#X#</strong> comments in the current revision of this page. You can view them by enabling the comment mode.",
"sc-popup-msg": "We found <strong>$1</strong> {{PLURAL:$1|comment|comments}} in the current revision of this page. You can view {{PLURAL:$1|it|them}} by enabling the comment mode.",
"sc-popup-enabled-highlighting-title": "Comments",
"sc-popup-enabled-highlighting-msg": "Make a text selection to create a comment",
"sc-popup-unlocalized-comments-title": "Whoops!",
Expand Down
3 changes: 1 addition & 2 deletions i18n/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@
"sc-property-revision": "Revisie",
"sc-property-position": "Positie op pagina",
"sc-popup-title": "Reacties",
"sc-popup-msg-single": "Er is <strong>#X#</strong> opmerking gevonden in de huidige revisie van deze pagina. Je kunt deze zien door de opmerkingenmodus in te schakelen.",
"sc-popup-msg-multiple": "Er zijn <strong>#X#</strong> opmerkingen gevonden in de huidige revisie van deze pagina. Je kunt ze zien door de opmerkingenmodus in te schakelen.",
"sc-popup-msg": "Er {{PLURAL:$1|is|zijn}} <strong>$1</strong> {{PLURAL:$1|opmerking|opmerkingen}} gevonden in de huidige revisie van deze pagina. Je kunt {{PLURAL:$1|deze|ze}} zien door de opmerkingenmodus in te schakelen.",
"sc-popup-enabled-highlighting-title": "Opmerkingen",
"sc-popup-enabled-highlighting-msg": "Selecteer een stukje tekst om er een opmerking over te plaatsen",
"sc-popup-unlocalized-comments-title": "Whoops!",
Expand Down
6 changes: 3 additions & 3 deletions resources/frontend/dist/smartcomments.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion resources/frontend/dist/smartcomments.min.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions resources/frontend/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,17 @@ mw.loader.using(["mediawiki.util"]).then(() => {
import("./store/appStateStore.js")
.then(({ useAppStateStore }) => {
const store = useAppStateStore();

// Check if we're on the SmartComments SpecialPage
const isSpecialPage = mw.config.get('wgCanonicalSpecialPageName') === 'SmartComments';

if (isSpecialPage) {
// SpecialPage mode: view-only, always enabled for comment viewing
store.initializeSpecialPageState();
} else {
// Regular page mode: full functionality with toggle
store.initializeState();

// Set initial state based on URL parameter
const initialIsEnabled = mw.util.getParamValue("scenabled") === "1";
if (initialIsEnabled) {
Expand Down
51 changes: 51 additions & 0 deletions resources/frontend/src/store/appStateStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ export const useAppStateStore = defineStore("appStore", {
);
}
}

// Notify user if there are comments on this page (even when mode is disabled)
this.notifyCommentsExist();
},

/**
Expand Down Expand Up @@ -141,6 +144,54 @@ export const useAppStateStore = defineStore("appStore", {
notifObj.close();
}
}
},

/**
* Show a notification if there are comments on the page.
* This runs regardless of whether comment mode is enabled.
* Only shown to users with the add-inlinecomments right.
* @returns {Promise<void>}
*/
async notifyCommentsExist() {
// Only show notification to users who can view/add comments
const userStore = useUserStore();
if (!userStore.canAddComments) {
return;
}

try {
const api = new mw.Api();
const data = await api.post({
action: "smartcomments",
method: "lista",
format: "json",
page: mw.config.get("wgPageName"),
status: "open",
});

const anchors = data.smartcomments?.anchors || [];
const count = anchors.length;

if (count > 0) {
const message = mw.message("sc-popup-msg", count).parse();

mw.notify($("<span>").html(message), {
autoHide: true,
autoHideSeconds: 5,
tag: "smartcomments-count-notification",
type: "info",
});

// Make the notification clickable to enable SmartComments
setTimeout(() => {
$(".mw-notification-tag-smartcomments-count-notification").css("cursor", "pointer").on("click", () => {
this.enableAppState();
});
}, 100);
}
} catch (err) {
mw.log.warn("SmartComments: Failed to check for existing comments:", err);
}
}
},
});
Loading