chore: persist activity feed history and improve build versioning
This commit is contained in:
1 parent
e72af4f877
commit
cb8447224f
2 files changed
+44
-10
No files matched your search
@@ -893,6 +893,33 @@
|
||||
}
|
||||
|
||||
// --- WebSocket Activity Feed ---
|
||||
const MAX_ACTIVITY_HISTORY = 100;
|
||||
|
||||
function saveActivityHistory(time, htmlData) {
|
||||
try {
|
||||
let history = JSON.parse(localStorage.getItem('activityHistory') || '[]');
|
||||
history.push({ time, data: htmlData });
|
||||
if (history.length > MAX_ACTIVITY_HISTORY) history = history.slice(-MAX_ACTIVITY_HISTORY);
|
||||
localStorage.setItem('activityHistory', JSON.stringify(history));
|
||||
} catch(e) {}
|
||||
}
|
||||
|
||||
function loadActivityHistory() {
|
||||
try {
|
||||
const feed = document.getElementById('activity-feed');
|
||||
let history = JSON.parse(localStorage.getItem('activityHistory') || '[]');
|
||||
history.forEach(item => {
|
||||
const div = document.createElement('div');
|
||||
div.className = 'feed-entry';
|
||||
div.innerHTML = `<span class="time">[${item.time}]</span> ${item.data}`;
|
||||
feed.appendChild(div);
|
||||
});
|
||||
if (history.length > 0) {
|
||||
feed.scrollTop = feed.scrollHeight;
|
||||
}
|
||||
} catch(e) {}
|
||||
}
|
||||
|
||||
function setupWS() {
|
||||
const protocol = location.protocol === 'https:' ? 'wss:' : 'ws:';
|
||||
const ws = new WebSocket(`${protocol}//${location.host}/ws?client=ui`);
|
||||
@@ -908,6 +935,8 @@
|
||||
div.innerHTML = `<span class="time">[${time}]</span> ${data.data}`;
|
||||
feed.appendChild(div);
|
||||
|
||||
saveActivityHistory(time, data.data);
|
||||
|
||||
// Auto-scroll logic
|
||||
const isScrolledToBottom = feed.scrollHeight - feed.clientHeight <= feed.scrollTop + 20;
|
||||
if (isScrolledToBottom) {
|
||||
@@ -967,6 +996,7 @@
|
||||
loadGraph();
|
||||
loadTasks();
|
||||
loadStickyNotes();
|
||||
loadActivityHistory();
|
||||
setupWS();
|
||||
|
||||
// Listen to theme toggle changes to update graph font colors
|
||||
|
||||
Reference in new issue
Block a user