nodebb-plugin-ezoic-infinite 1.5.46 → 1.5.48

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/library.js CHANGED
@@ -27,21 +27,13 @@ async function getAllGroups() {
27
27
  }
28
28
  const filtered = names.filter(name => !groups.isPrivilegeGroup(name));
29
29
  const data = await groups.getGroupsData(filtered);
30
- // Filter out nulls (groups deleted between the sorted-set read and getGroupsData)
31
- const valid = data.filter(g => g && g.name);
32
- valid.sort((a, b) => String(a.name).localeCompare(String(b.name), undefined, { sensitivity: 'base' }));
33
- return valid;
30
+ // Sort alphabetically for ACP usability
31
+ data.sort((a, b) => String(a.name).localeCompare(String(b.name), 'fr', { sensitivity: 'base' }));
32
+ return data;
34
33
  }
35
- let _settingsCache = null;
36
- let _settingsCacheAt = 0;
37
- const SETTINGS_TTL = 30000; // 30s
38
-
39
34
  async function getSettings() {
40
- const now = Date.now();
41
- if (_settingsCache && (now - _settingsCacheAt) < SETTINGS_TTL) return _settingsCache;
42
35
  const s = await meta.settings.get(SETTINGS_KEY);
43
- _settingsCacheAt = Date.now();
44
- _settingsCache = {
36
+ return {
45
37
  // Between-post ads (simple blocks) in category topic list
46
38
  enableBetweenAds: parseBool(s.enableBetweenAds, true),
47
39
  showFirstTopicAd: parseBool(s.showFirstTopicAd, false),
@@ -62,7 +54,6 @@ async function getSettings() {
62
54
 
63
55
  excludedGroups: normalizeExcludedGroups(s.excludedGroups),
64
56
  };
65
- return _settingsCache;
66
57
  }
67
58
 
68
59
  async function isUserExcluded(uid, excludedGroups) {
@@ -71,13 +62,6 @@ async function isUserExcluded(uid, excludedGroups) {
71
62
  return (userGroups[0] || []).some(g => excludedGroups.includes(g.name));
72
63
  }
73
64
 
74
- plugin.onSettingsSet = function (data) {
75
- // Invalider le cache dès que les settings de ce plugin sont sauvegardés via l'ACP
76
- if (data && data.hash === SETTINGS_KEY) {
77
- _settingsCache = null;
78
- }
79
- };
80
-
81
65
  plugin.addAdminNavigation = async (header) => {
82
66
  header.plugins = header.plugins || [];
83
67
  header.plugins.push({
@@ -105,7 +89,7 @@ plugin.init = async ({ router, middleware }) => {
105
89
  router.get('/admin/plugins/ezoic-infinite', middleware.admin.buildHeader, render);
106
90
  router.get('/api/admin/plugins/ezoic-infinite', render);
107
91
 
108
- router.get('/api/plugins/ezoic-infinite/config', async (req, res) => {
92
+ router.get('/api/plugins/ezoic-infinite/config', middleware.buildHeader, async (req, res) => {
109
93
  const settings = await getSettings();
110
94
  const excluded = await isUserExcluded(req.uid, settings.excludedGroups);
111
95
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-ezoic-infinite",
3
- "version": "1.5.46",
3
+ "version": "1.5.48",
4
4
  "description": "Production-ready Ezoic infinite ads integration for NodeBB 4.x",
5
5
  "main": "library.js",
6
6
  "license": "MIT",
package/plugin.json CHANGED
@@ -11,10 +11,6 @@
11
11
  {
12
12
  "hook": "filter:admin.header.build",
13
13
  "method": "addAdminNavigation"
14
- },
15
- {
16
- "hook": "action:settings.set",
17
- "method": "onSettingsSet"
18
14
  }
19
15
  ],
20
16
  "staticDirs": {
package/public/admin.js CHANGED
@@ -13,10 +13,11 @@
13
13
  e.preventDefault();
14
14
 
15
15
  Settings.save('ezoic-infinite', $form, function () {
16
+ // Toast vert (NodeBB core)
16
17
  if (alerts && typeof alerts.success === 'function') {
17
- alerts.success('[[admin/settings:saved]]');
18
+ alerts.success('Enregistré');
18
19
  } else if (window.app && typeof window.app.alertSuccess === 'function') {
19
- window.app.alertSuccess('[[admin/settings:saved]]');
20
+ window.app.alertSuccess('Enregistré');
20
21
  }
21
22
  });
22
23
  });