Fix: clicking on history item now shows diff for that revision
- Modified ui.js displayHistory() to pass previous revision to click handler - Added showHistoryItemDiff() method in app.js to generate and display diff - Diff compares selected revision with previous revision (Option A) - First revision shows message instead of diff (no previous to compare)
This commit is contained in:
parent
13f37be9c2
commit
c15b759378
2 changed files with 37 additions and 2 deletions
9
ui/ui.js
9
ui/ui.js
|
|
@ -254,14 +254,19 @@ class UIManager {
|
|||
this.showView(this.historyView);
|
||||
|
||||
// Add click handlers to history items
|
||||
this.historyContent.querySelectorAll('.history-item').forEach(item => {
|
||||
this.historyContent.querySelectorAll('.history-item').forEach((item, index) => {
|
||||
item.addEventListener('click', () => {
|
||||
// Remove active class from all items
|
||||
this.historyContent.querySelectorAll('.history-item').forEach(i => i.classList.remove('active'));
|
||||
// Add active class to clicked item
|
||||
item.classList.add('active');
|
||||
const revision = item.dataset.revision;
|
||||
window.app.loadFileAtRevision(this.currentFile, revision);
|
||||
|
||||
// Get the previous revision if it exists
|
||||
const previousRevision = index < history.length - 1 ? history[index + 1].revision : null;
|
||||
|
||||
// Show diff between current and previous revision
|
||||
window.app.showHistoryItemDiff(this.currentFile, revision, previousRevision);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue