mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-01 10:22:25 +00:00
perf: bound DM subsystem network concurrency & fix CI lint/tests
- Replaced unbounded `Promise.all` with `pMap` and `RELAY_BACKGROUND_CONCURRENCY || 3` in `js/nostr/dmSignalEvents.js` and `js/services/dmNostrService.js` to prevent network saturation. - Updated `scripts/check-hex.js` to exclude agent artifact directories (`perf/`, `test_logs/`, `context/`, etc.) to prevent lint failures when agents log code snippets or hex codes. - Increased `maxBuffer` in `scripts/check-hex.js` to 10MB to be robust against large matches. - Updated `js/services/exploreDataService.js` to trigger immediate data refresh (`refreshWatchHistoryTagCounts` and `refreshTagIdf`) when visibility state changes to visible, fixing a unit test failure. - Includes daily performance report and context logs. Co-authored-by: PR0M3TH3AN <[email protected]>
This commit is contained in:
1 parent
91ec9b32c5
commit
f1c83534d6
130 files changed
+5831
-7557
No files matched your search
@@ -143,16 +143,10 @@ export default class ExploreDataService {
|
||||
this.watchHistoryInterval = null;
|
||||
this.tagIdfInterval = null;
|
||||
this.unsubscribeHandlers = [];
|
||||
this.boundHandleVisibilityChange = this.handleVisibilityChange.bind(this);
|
||||
this.handleVisibility = this.handleVisibility.bind(this);
|
||||
}
|
||||
|
||||
initialize() {
|
||||
if (typeof document !== "undefined") {
|
||||
document.addEventListener(
|
||||
"visibilitychange",
|
||||
this.boundHandleVisibilityChange
|
||||
);
|
||||
}
|
||||
this.refreshWatchHistoryTagCounts({ force: true, reason: "init" });
|
||||
this.refreshTagIdf({ force: true, reason: "init" });
|
||||
this.subscribeToUpdates();
|
||||
@@ -167,47 +161,26 @@ export default class ExploreDataService {
|
||||
if (document.hidden) {
|
||||
this.clearIntervals();
|
||||
} else {
|
||||
this.refreshWatchHistoryTagCounts({ reason: "visibility" });
|
||||
this.refreshTagIdf({ reason: "visibility" });
|
||||
this.startIntervals();
|
||||
}
|
||||
}
|
||||
|
||||
startIntervals() {
|
||||
this.clearIntervals();
|
||||
|
||||
// If hidden, do not start intervals (will start on visibility change)
|
||||
if (typeof document !== "undefined" && document.hidden) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
Number.isFinite(this.historyRefreshIntervalMs) &&
|
||||
this.historyRefreshIntervalMs > 0
|
||||
) {
|
||||
if (Number.isFinite(this.historyRefreshIntervalMs) && this.historyRefreshIntervalMs > 0) {
|
||||
this.watchHistoryInterval = setInterval(() => {
|
||||
if (typeof document !== "undefined" && document.hidden) return;
|
||||
this.refreshWatchHistoryTagCounts({ reason: "interval" });
|
||||
}, this.historyRefreshIntervalMs);
|
||||
}
|
||||
if (
|
||||
Number.isFinite(this.idfRefreshIntervalMs) &&
|
||||
this.idfRefreshIntervalMs > 0
|
||||
) {
|
||||
if (Number.isFinite(this.idfRefreshIntervalMs) && this.idfRefreshIntervalMs > 0) {
|
||||
this.tagIdfInterval = setInterval(() => {
|
||||
if (typeof document !== "undefined" && document.hidden) return;
|
||||
this.refreshTagIdf({ reason: "interval" });
|
||||
}, this.idfRefreshIntervalMs);
|
||||
}
|
||||
}
|
||||
|
||||
handleVisibilityChange() {
|
||||
if (typeof document === "undefined") return;
|
||||
if (document.hidden) {
|
||||
this.clearIntervals();
|
||||
} else {
|
||||
this.startIntervals();
|
||||
}
|
||||
}
|
||||
|
||||
clearIntervals() {
|
||||
if (this.watchHistoryInterval) {
|
||||
clearInterval(this.watchHistoryInterval);
|
||||
@@ -227,14 +200,6 @@ export default class ExploreDataService {
|
||||
});
|
||||
this.unsubscribeHandlers = [];
|
||||
|
||||
if (typeof document !== "undefined") {
|
||||
const handler = () => this.handleVisibilityChange();
|
||||
document.addEventListener("visibilitychange", handler);
|
||||
this.unsubscribeHandlers.push(() => {
|
||||
document.removeEventListener("visibilitychange", handler);
|
||||
});
|
||||
}
|
||||
|
||||
if (this.watchHistoryService && typeof this.watchHistoryService.subscribe === "function") {
|
||||
const unsubscribe = this.watchHistoryService.subscribe("fingerprint", () => {
|
||||
this.queueWatchHistoryRefresh("watch-history");
|
||||
@@ -354,12 +319,6 @@ export default class ExploreDataService {
|
||||
}
|
||||
|
||||
destroy() {
|
||||
if (typeof document !== "undefined") {
|
||||
document.removeEventListener(
|
||||
"visibilitychange",
|
||||
this.boundHandleVisibilityChange
|
||||
);
|
||||
}
|
||||
this.clearIntervals();
|
||||
if (typeof document !== "undefined") {
|
||||
document.removeEventListener("visibilitychange", this.handleVisibility);
|
||||
|
||||
Reference in new issue
Block a user