MCPcopy Create free account
hub / github.com/OpenAnonymity/oa-chat / MessageNavigation

Class MessageNavigation

chat/components/MessageNavigation.js:2–389  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1// Message Navigation Component
2import { renderMathContent } from '../services/mathRendering.js';
3
4export default class MessageNavigation {
5 constructor(app) {
6 this.app = app;
7 this.currentMessageIndex = 0;
8 this.messages = [];
9 this.container = null;
10 this.isVisible = false;
11 this.hideTimeout = null;
12 this.isNavigating = false; // Flag to prevent scroll handler from overriding click navigation
13 this.clickedIndex = null; // Tracks user-clicked bar, null = use viewport-based detection
14 this.awaitingScrollEnd = false; // True while waiting for programmatic scroll to finish
15 this.scrollEndTimer = null;
16
17 this.init();
18 }
19
20 init() {
21 this.createNavigationUI();
22 this.setupEventListeners();
23 }
24
25 createNavigationUI() {
26 // Create navigation container
27 const nav = document.createElement('div');
28 nav.id = 'message-navigation';
29 nav.className = 'message-navigation hidden';
30 nav.innerHTML = `
31 <button id="prev-message-btn" class="nav-btn" aria-label="Previous message" title="Previous message (↑)">
32 <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor">
33 <path stroke-linecap="round" stroke-linejoin="round" d="M4.5 15.75l7.5-7.5 7.5 7.5" />
34 </svg>
35 </button>
36 <div id="message-indicators" class="message-indicators"></div>
37 <button id="next-message-btn" class="nav-btn" aria-label="Next message" title="Next message (↓)">
38 <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor">
39 <path stroke-linecap="round" stroke-linejoin="round" d="M19.5 8.25l-7.5 7.5-7.5-7.5" />
40 </svg>
41 </button>
42 `;
43
44 // Add to chat area
45 const chatArea = document.getElementById('chat-area');
46 if (chatArea) {
47 chatArea.appendChild(nav);
48 this.container = nav;
49 }
50 }
51
52 setupEventListeners() {
53 const prevBtn = document.getElementById('prev-message-btn');
54 const nextBtn = document.getElementById('next-message-btn');
55
56 if (prevBtn) {
57 prevBtn.addEventListener('click', () => this.navigateToPrevious());
58 }
59
60 if (nextBtn) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected