@hhkaos/webmentions-widget 0.5.3 → 0.5.4

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.
Files changed (2) hide show
  1. package/bin/snapshot.js +16 -3
  2. package/package.json +1 -1
package/bin/snapshot.js CHANGED
@@ -165,12 +165,25 @@ async function main() {
165
165
 
166
166
  const before = getSnapshotMentions(existing).length;
167
167
 
168
- if (!collected.length && existing) {
169
- console.log(`No new mentions since #${sinceId}. Snapshot unchanged (${before}).`);
168
+ console.log(`Fetched ${collected.length} mention(s) for ${domain}${sinceId ? ` since #${sinceId}` : ''}.`);
169
+
170
+ if (!collected.length) {
171
+ if (args.full) {
172
+ // An authoritative refetch that came back empty is far more likely to be
173
+ // a wrong --domain than a genuinely empty account, so keep what we have.
174
+ console.log('Nothing returned for a full refresh; keeping the current snapshot.');
175
+ return;
176
+ }
177
+
178
+ console.log(`Snapshot unchanged (${before}).`);
170
179
  return;
171
180
  }
172
181
 
173
- const snapshot = mergeSnapshot(existing, collected);
182
+ // A full refetch is authoritative: replace rather than merge, so mentions
183
+ // collected under a domain we no longer query do not linger forever.
184
+ const snapshot = args.full
185
+ ? mergeSnapshot(null, collected)
186
+ : mergeSnapshot(existing, collected);
174
187
 
175
188
  if (snapshot.count === before) {
176
189
  console.log(`Snapshot unchanged (${before} mentions).`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hhkaos/webmentions-widget",
3
- "version": "0.5.3",
3
+ "version": "0.5.4",
4
4
  "description": "Framework-agnostic, dependency-free widget to fetch and render webmention.io mentions for the current page.",
5
5
  "type": "module",
6
6
  "license": "MIT",