forked from andyburke/autonomous.contact
		
	fix: try to improve topic indication and loading
This commit is contained in:
		
							parent
							
								
									4c1fa98418
								
							
						
					
					
						commit
						ac64473749
					
				
					 2 changed files with 13 additions and 17 deletions
				
			
		|  | @ -10,23 +10,20 @@ | |||
| 		} | ||||
| 	}); | ||||
| 
 | ||||
| 	function update_topic_indicators() { | ||||
| 		const topic_indicators = document.querySelectorAll("[data-topic-selector-for]"); | ||||
| 		for (const topic_indicator of topic_indicators) { | ||||
| 			topic_indicator.classList.remove("active"); | ||||
| 		} | ||||
| 	function update_topic_indicators(event) { | ||||
| 		document | ||||
| 			.querySelectorAll("[data-topic-selector-for]") | ||||
| 			.forEach((element) => element.classList.remove("active")); | ||||
| 
 | ||||
| 		const topic_id = document.body.dataset.topic; | ||||
| 		if (!topic_id) { | ||||
| 		const new_topic_id = event?.detail?.topic_id ?? document.body.dataset.topic; | ||||
| 
 | ||||
| 		if (!new_topic_id) { | ||||
| 			return; | ||||
| 		} | ||||
| 
 | ||||
| 		const active_topic_indicators = document.querySelectorAll( | ||||
| 			`[data-topic-selector-for="${topic_id}"]`, | ||||
| 		); | ||||
| 		for (const active_indicator of active_topic_indicators) { | ||||
| 			active_indicator.classList.add("active"); | ||||
| 		} | ||||
| 		document | ||||
| 			.querySelectorAll(`[data-topic-selector-for="${new_topic_id}"]`) | ||||
| 			.forEach((element) => element.classList.add("active")); | ||||
| 	} | ||||
| 
 | ||||
| 	document.addEventListener("topics_updated", update_topic_indicators); | ||||
|  |  | |||
|  | @ -129,11 +129,12 @@ | |||
| 		const topic_id = event?.detail?.topic_id ?? document.body.dataset.topic; | ||||
| 		if (!topic_id) return; | ||||
| 
 | ||||
| 		const topic_chat_content = document.getElementById("topic-chat-content"); | ||||
| 		topic_chat_content.innerHTML = ""; | ||||
| 
 | ||||
| 		const user = document.body.dataset.user ? JSON.parse(document.body.dataset.user) : null; | ||||
| 		if (!user) return; | ||||
| 
 | ||||
| 		const topic_chat_content = document.getElementById("topic-chat-content"); | ||||
| 
 | ||||
| 		if (topic_polling_request_abort_controller) { | ||||
| 			topic_polling_request_abort_controller.abort(); | ||||
| 			topic_polling_request_abort_controller = null; | ||||
|  | @ -149,8 +150,6 @@ | |||
| 
 | ||||
| 		const topic = await topic_response.json(); | ||||
| 
 | ||||
| 		topic_chat_content.innerHTML = ""; | ||||
| 
 | ||||
| 		const events_response = await api.fetch( | ||||
| 			`/api/topics/${topic_id}/events?type=chat&limit=100&sort=newest`, | ||||
| 		); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue