pmtiles-swarm 0.5.5 โ†’ 0.5.6

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/CHANGELOG.md CHANGED
@@ -7,6 +7,19 @@
7
7
  ### ๐Ÿž Bug fixes
8
8
  - _...Add new stuff here..._
9
9
 
10
+ ## 0.5.6
11
+ ### ๐Ÿž Bug fixes
12
+ - **The Pieces and Peers tabs redraw themselves.** A detail pane is filled once, the first time
13
+ it is opened โ€” right for the panes describing an archive, whose name and source and trackers
14
+ do not change, and wrong for the two describing what is happening *now*. Pieces arrived and
15
+ peers came and went behind a picture taken when the tab was opened, and the only way to see
16
+ the current one was to close the panel and open it again, or reload the page. Those two now
17
+ follow the same three-second tick as the archive table. The rest stay lazy, since redrawing a
18
+ pane nobody is watching is requests every tick for nothing โ€” which is why they load on demand
19
+ in the first place. Only while visible, and never queued behind a redraw still in flight: a
20
+ piece map of a large archive is a real request, and three seconds is not long enough to assume
21
+ the last one finished.
22
+
10
23
  ## 0.5.5
11
24
  ### ๐Ÿž Bug fixes
12
25
  - **An archive could retire itself from head-warming and never say so.** The test for "already
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmtiles-swarm",
3
- "version": "0.5.5",
3
+ "version": "0.5.6",
4
4
  "description": "BitTorrent distribution for PMTiles map archives: create torrents, watch folders, publish and subscribe to RSS feeds, and seed through qBittorrent or an embedded client",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -729,6 +729,21 @@
729
729
  // before the node has said whether its engine applies one.
730
730
  let incompleteMarker = null;
731
731
  let activeTab = 'general';
732
+ /**
733
+ * Panes worth redrawing while they are open.
734
+ *
735
+ * A detail pane is filled once, the first time it is shown, which is
736
+ * right for the ones describing an archive: its name, its source, its
737
+ * trackers. It is wrong for these two, which describe what is happening
738
+ * *now* โ€” pieces arriving and peers coming and going โ€” and which sat
739
+ * frozen until the reader thought to close the panel and open it again.
740
+ *
741
+ * The rest stay as they are. Refreshing a pane nobody is watching is
742
+ * four requests a tick for nothing, which is why they are loaded lazily
743
+ * in the first place.
744
+ */
745
+ const LIVE_PANES = new Set(['pieces', 'peers']);
746
+ let refreshingPane = false;
732
747
 
733
748
  // What the header switch shows, so a click knows what it is toggling to.
734
749
  let speedState = null;
@@ -894,6 +909,7 @@
894
909
  ` ยท <b>${status.archives}</b> archives`;
895
910
  archives = list;
896
911
  renderRows();
912
+ refreshOpenPane();
897
913
  } catch (error) {
898
914
  $('status').textContent = `disconnected: ${error.message}`;
899
915
  }
@@ -1072,6 +1088,29 @@
1072
1088
  ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c],
1073
1089
  );
1074
1090
 
1091
+ /**
1092
+ * Redraws the open detail pane, when it is one that changes by itself.
1093
+ *
1094
+ * Guarded against overlapping, because a piece map of a large archive is
1095
+ * a real request and a slow one must not have a queue of its successors
1096
+ * behind it.
1097
+ * @returns {void}
1098
+ */
1099
+ function refreshOpenPane() {
1100
+ if (refreshingPane || !selected || !LIVE_PANES.has(activeTab)) return;
1101
+ const pane = document.querySelector(`[data-pane="${activeTab}"]`);
1102
+ // Only while it is on screen: a hidden pane is one the reader moved
1103
+ // away from, and the panel may have been replaced since.
1104
+ if (!pane || pane.hidden) return;
1105
+
1106
+ refreshingPane = true;
1107
+ Promise.resolve(fillPane(activeTab, selected))
1108
+ .catch(() => {})
1109
+ .finally(() => {
1110
+ refreshingPane = false;
1111
+ });
1112
+ }
1113
+
1075
1114
  /**
1076
1115
  * Fills one detail tab, the first time it is opened.
1077
1116
  * @param {string} name - Which pane.