- Fix audit event names in CLI prune/clear commands from `cli.seo.*` to `cli.seo_meta.*`
- Refactor `_delete_attachment_file` to accept full attachment dict instead of storage_path string, using directory and stored_name fields with ATTACHMENTS_DIR
- Add `safe_next` validation for referer header in validation error redirect and media redirect
- Add `is_active` check in login router to reject deactivated accounts with "Account is deactivated" error
- Replace raw `request.headers.get("Referer")` with `redirect_back()` utility in bookmarks, polls, reactions, and votes routers
- Move `mark_conversation_read` call from `get_conversation_messages` to `messages_page` to avoid side effects during message retrieval
- Fix poll audit link to use `option.get("label")` instead of `option.get("text")`
- Add `VOTABLE` set validation in votes router to reject invalid target types with 400 response
- Strip control characters (0x00-0x20) from URLs in `_safe_url` instead of simple strip
- Add `__getattr__` fallback in services `__init__.py` for dynamic attribute access
39 lines
797 B
JavaScript
39 lines
797 B
JavaScript
// retoor <retoor@molodetz.nl>
|
|
|
|
export class Poller {
|
|
constructor(fn, intervalMs, options = {}) {
|
|
this._fn = fn;
|
|
this._interval = intervalMs;
|
|
this._pauseHidden = !!options.pauseHidden;
|
|
this._timer = null;
|
|
this._busy = false;
|
|
if (options.immediate !== false) this.tick();
|
|
this.start();
|
|
}
|
|
|
|
start() {
|
|
if (this._timer) return;
|
|
this._timer = window.setInterval(() => this.tick(), this._interval);
|
|
}
|
|
|
|
stop() {
|
|
if (this._timer) {
|
|
window.clearInterval(this._timer);
|
|
this._timer = null;
|
|
}
|
|
}
|
|
|
|
async tick() {
|
|
if (this._pauseHidden && document.hidden) return;
|
|
if (this._busy) return;
|
|
this._busy = true;
|
|
try {
|
|
await this._fn();
|
|
} catch (error) {
|
|
return;
|
|
} finally {
|
|
this._busy = false;
|
|
}
|
|
}
|
|
}
|