Queue Management

The alert queue manages the order in which alerts are displayed. Alerts are presented one at a time — the queue holds pending alerts until the current one finishes.

Inspecting the Queue

const length = SBCanvas.queue.getLength();
console.log(`${length} alerts waiting`);

const next = SBCanvas.queue.peek();
if (next) {
  console.log(`Next: ${next.type} from ${next.username}`);
}

Clearing the Queue

SBCanvas.queue.clear();

// Clear only follow alerts (keep tips, subs, etc.)
SBCanvas.queue.clear({ type: 'follow' });

Hold and Resume

Pause alert presentation without clearing the queue:
SBCanvas.holdQueue(30);   // pause for 30 seconds
SBCanvas.resumeQueue();   // resume immediately

Configuration

const config = SBCanvas.queue.getConfig();

SBCanvas.queue.setConfig({
  maxSize: 50,
  defaultPriority: 5,
  throttle: 1000
});
Config FieldTypeDescription
maxSizenumberMax alerts in queue (oldest dropped when full)
defaultPrioritynumberDefault priority for new alerts (0-10)
throttlenumberMinimum ms between alert presentations
prioritiesobjectPriority map by activity type

Example: Queue Badge

SBCanvas.ready(() => {
  const badge = document.getElementById('queue-badge');

  SBCanvas.setInterval(() => {
    const len = SBCanvas.queue.getLength();
    badge.textContent = len > 0 ? len : '';
    badge.style.display = len > 0 ? 'block' : 'none';
  }, 1000);
});

Example: Moderator Queue Controls

SBCanvas.panel.register({
  actions: [
    { name: 'pause', label: 'Pause Alerts' },
    { name: 'resume', label: 'Resume Alerts' },
    { name: 'clear', label: 'Clear Queue', confirm: true },
    { name: 'skip', label: 'Skip Current' }
  ]
});

SBCanvas.panel.onAction('pause', () => SBCanvas.holdQueue(300));
SBCanvas.panel.onAction('resume', () => SBCanvas.resumeQueue());
SBCanvas.panel.onAction('clear', () => SBCanvas.queue.clear());

API Reference

MethodReturnsDescription
queue.getLength()numberNumber of queued alerts
queue.peek()object | nullView next alert without removing
queue.setPriority(type, level)voidSet priority (0-10) for an activity type
queue.clear(filter?)voidClear queue, optionally filter by {type}
queue.getConfig()objectGet current queue configuration
queue.setConfig(config)voidUpdate queue configuration