mirror of
				https://gitlab.com/animath/si/plateforme.git
				synced 2025-10-31 22:24:30 +01:00 
			
		
		
		
	Store last visited channel in local storage
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
		| @@ -33,8 +33,7 @@ function selectChannel(channel_id) { | ||||
|     } | ||||
|  | ||||
|     selected_channel_id = channel_id | ||||
|  | ||||
|     window.history.replaceState({}, null, `#channel-${channel['id']}`) | ||||
|     localStorage.setItem('chat.last-channel-id', channel_id) | ||||
|  | ||||
|     let channelTitle = document.getElementById('channel-title') | ||||
|     channelTitle.innerText = channel['name'] | ||||
| @@ -74,13 +73,9 @@ function setChannels(new_channels) { | ||||
|         addChannel(channel, categoryLists) | ||||
|  | ||||
|     if (new_channels && (!selected_channel_id || !channels[selected_channel_id])) { | ||||
|         if (window.location.hash) { | ||||
|             let channel_id = parseInt(window.location.hash.substring(9)) | ||||
|             if (channels[channel_id]) | ||||
|                 selectChannel(channel_id) | ||||
|             else | ||||
|                 selectChannel(Object.keys(channels)[0]) | ||||
|         } | ||||
|         let last_channel_id = parseInt(localStorage.getItem('chat.last-channel-id')) | ||||
|         if (last_channel_id && channels[last_channel_id]) | ||||
|             selectChannel(last_channel_id) | ||||
|         else | ||||
|             selectChannel(Object.keys(channels)[0]) | ||||
|     } | ||||
| @@ -387,12 +382,12 @@ function toggleFullscreen() { | ||||
|     if (!chatContainer.getAttribute('data-fullscreen')) { | ||||
|         chatContainer.setAttribute('data-fullscreen', 'true') | ||||
|         chatContainer.classList.add('position-absolute', 'top-0', 'start-0', 'vh-100', 'z-3') | ||||
|         window.history.replaceState({}, null, `?fullscreen=1#channel-${selected_channel_id}`) | ||||
|         window.history.replaceState({}, null, `?fullscreen=1`) | ||||
|     } | ||||
|     else { | ||||
|         chatContainer.removeAttribute('data-fullscreen') | ||||
|         chatContainer.classList.remove('position-absolute', 'top-0', 'start-0', 'vh-100', 'z-3') | ||||
|         window.history.replaceState({}, null, `?fullscreen=0#channel-${selected_channel_id}`) | ||||
|         window.history.replaceState({}, null, `?fullscreen=0`) | ||||
|     } | ||||
| } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user