auto-git:
[change] renderer.js
This commit is contained in:
53
renderer.js
53
renderer.js
@@ -317,37 +317,44 @@ folders.forEach(folderObj => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function updateContentList(folderObj) {
|
async function updateContentList(folderObj) {
|
||||||
// (1) Commits Today (global, egal welcher Ordner)
|
// 1. Commits Today (global)
|
||||||
const stats = await window.electronAPI.getDailyCommitStats();
|
const stats = await window.electronAPI.getDailyCommitStats();
|
||||||
const today = new Date().toISOString().slice(0, 10);
|
const today = new Date().toISOString().slice(0, 10);
|
||||||
const commitsToday = stats[today] || 0;
|
const commitsToday = stats[today] || 0;
|
||||||
|
|
||||||
// (2) Lines until next Rewrite (ordnerabhängig!)
|
// 2. Globale Werte
|
||||||
const threshold = folderObj.intelligentCommitThreshold ?? 10;
|
const intelligentCommitThreshold = window.intelligentCommitThreshold || 50;
|
||||||
const linesChanged = folderObj.linesChanged || 0;
|
const minutesCommitThreshold = window.minutesCommitThreshold || 20;
|
||||||
const linesUntilNextRewrite = Math.max(0, threshold - linesChanged);
|
|
||||||
|
|
||||||
// (3) Time until next Rewrite (ordnerabhängig!)
|
// 3. Lines until next Rewrite
|
||||||
// -> firstCandidateBirthday ist ms-Timestamp oder null
|
const linesChanged = folderObj?.linesChanged || 0;
|
||||||
// -> minutesCommitThreshold ist global (z.B. window.minutesCommitThreshold)
|
const linesUntilRewrite = Math.max(0, intelligentCommitThreshold - linesChanged);
|
||||||
let timeUntilNextRewrite = '00:00';
|
|
||||||
if (folderObj.firstCandidateBirthday && window.minutesCommitThreshold) {
|
// 4. Time until next Rewrite
|
||||||
const end = folderObj.firstCandidateBirthday + window.minutesCommitThreshold * 60 * 1000;
|
let countdown = "00:00";
|
||||||
const left = Math.max(0, end - Date.now());
|
if (folderObj?.firstCandidateBirthday) {
|
||||||
timeUntilNextRewrite = formatCountdown(left);
|
const msThreshold = minutesCommitThreshold * 60 * 1000;
|
||||||
|
const endTime = new Date(folderObj.firstCandidateBirthday).getTime() + msThreshold;
|
||||||
|
const msLeft = Math.max(0, endTime - Date.now());
|
||||||
|
countdown = formatCountdown(msLeft);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ContentList updaten – passe an dein HTML an!
|
// 5. Schreibe Werte ins UI
|
||||||
const lines = [
|
document.getElementById('contentList').innerHTML = `
|
||||||
`Commits Today: ${commitsToday}`,
|
<div>Commits Today: <b>${commitsToday}</b></div>
|
||||||
`Lines until next Rewrite: ${linesUntilNextRewrite}`,
|
<div>Lines until next Rewrite: <b>${linesUntilRewrite}</b></div>
|
||||||
`Time until next Rewrite: ${timeUntilNextRewrite}`
|
<div>Time until next Rewrite: <b>${countdown}</b></div>
|
||||||
];
|
`;
|
||||||
|
|
||||||
// Beispiel: Schreibe in dein DIV mit id="contentList"
|
|
||||||
document.getElementById('contentList').innerHTML = lines.map(l => `<div>${l}</div>`).join('');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Helfer für mm:ss
|
||||||
|
function formatCountdown(ms) {
|
||||||
|
if (!ms || ms < 0) return "00:00";
|
||||||
|
const totalSec = Math.floor(ms / 1000);
|
||||||
|
const min = Math.floor(totalSec / 60).toString().padStart(2, "0");
|
||||||
|
const sec = (totalSec % 60).toString().padStart(2, "0");
|
||||||
|
return `${min}:${sec}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const folderTitleDrop = document.getElementById('folderTitleDrop');
|
const folderTitleDrop = document.getElementById('folderTitleDrop');
|
||||||
@@ -575,7 +582,7 @@ folders.forEach(folderObj => {
|
|||||||
await renderSidebar();
|
await renderSidebar();
|
||||||
const initial = await window.electronAPI.getSelected();
|
const initial = await window.electronAPI.getSelected();
|
||||||
if (initial) await renderContent(initial);
|
if (initial) await renderContent(initial);
|
||||||
updateContentList(window.initial);
|
updateContentList(window.initial); //11111111
|
||||||
|
|
||||||
addBtn.addEventListener('click', async () => {
|
addBtn.addEventListener('click', async () => {
|
||||||
await window.electronAPI.addFolder();
|
await window.electronAPI.addFolder();
|
||||||
|
|||||||
Reference in New Issue
Block a user