Skip to content

Commit 05af4fe

Browse files
rendyhdclaude
andcommitted
Fix Quick View window height not adjusting after filter change, bump to v2.0.0-beta.7
Pre-size viewer window to viewerDesiredHeight before show() so it appears at the correct size immediately instead of flashing at 460px. Also keep viewerDesiredHeight updated even when the window is hidden (background sync), and add a requestAnimationFrame safety net for post-paint height re-check. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent f09e8e3 commit 05af4fe

4 files changed

Lines changed: 42 additions & 16 deletions

File tree

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vikunja-quick-entry",
3-
"version": "2.0.0-beta.6",
3+
"version": "2.0.0-beta.7",
44
"description": "A lightweight system tray app with a global hotkey for quick task entry to Vikunja",
55
"main": "src/main.js",
66
"scripts": {

src/main.js

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,11 @@ function createViewerWindow() {
314314
function showViewer() {
315315
if (!viewerWindow) return;
316316

317-
viewerDesiredHeight = 460;
317+
// Pre-size window to desired height before showing to avoid stale-height flash
318+
const [currentWidth] = viewerWindow.getSize();
319+
isResettingViewerHeight = true;
320+
viewerWindow.setSize(currentWidth, viewerDesiredHeight);
321+
isResettingViewerHeight = false;
318322

319323
if (config && config.viewer_position) {
320324
// Use saved position, but ensure it's on-screen
@@ -699,21 +703,28 @@ function stopCacheRefresh() {
699703
isRefreshingCache = false;
700704
}
701705

706+
let networkPollTimer = null;
707+
702708
function setupNetworkListeners() {
703709
const { net } = require('electron');
704-
705-
net.on('online', () => {
706-
cacheRefreshBackoff = CACHE_REFRESH_BASE_INTERVAL;
707-
refreshTaskCache(); // immediate warm-up
708-
processPendingQueue(); // also flush pending actions
709-
});
710-
711-
net.on('offline', () => {
712-
if (cacheRefreshTimer) {
713-
clearTimeout(cacheRefreshTimer);
714-
cacheRefreshTimer = null;
710+
let wasOnline = net.isOnline();
711+
712+
networkPollTimer = setInterval(() => {
713+
const isNowOnline = net.isOnline();
714+
if (isNowOnline && !wasOnline) {
715+
// Came back online
716+
cacheRefreshBackoff = CACHE_REFRESH_BASE_INTERVAL;
717+
refreshTaskCache();
718+
processPendingQueue();
719+
} else if (!isNowOnline && wasOnline) {
720+
// Went offline
721+
if (cacheRefreshTimer) {
722+
clearTimeout(cacheRefreshTimer);
723+
cacheRefreshTimer = null;
724+
}
715725
}
716-
});
726+
wasOnline = isNowOnline;
727+
}, 5000);
717728
}
718729

719730
// --- IPC Handlers ---
@@ -867,6 +878,13 @@ ipcMain.handle('save-settings', async (_event, settings) => {
867878
// Update tray menu (enable "Show Quick Entry" / "Show Quick View")
868879
updateTrayMenu();
869880

881+
// Notify viewer to invalidate stale cache (filters may have changed)
882+
try {
883+
if (viewerWindow && !viewerWindow.isDestroyed()) {
884+
viewerWindow.webContents.send('sync-completed');
885+
}
886+
} catch { /* ignore */ }
887+
870888
if (isStandalone) {
871889
// No sync in standalone mode
872890
stopSyncTimer();
@@ -1110,6 +1128,7 @@ ipcMain.handle('set-viewer-height', (_event, height) => {
11101128
if (!viewerWindow || viewerWindow.isDestroyed()) return;
11111129
const clamped = Math.max(60, Math.min(460, Math.round(height)));
11121130
viewerDesiredHeight = clamped;
1131+
if (!viewerWindow.isVisible()) return;
11131132
const [currentWidth] = viewerWindow.getSize();
11141133
isResettingViewerHeight = true;
11151134
viewerWindow.setSize(currentWidth, clamped);
@@ -1203,6 +1222,10 @@ app.on('will-quit', () => {
12031222
globalShortcut.unregisterAll();
12041223
stopSyncTimer();
12051224
stopCacheRefresh();
1225+
if (networkPollTimer) {
1226+
clearInterval(networkPollTimer);
1227+
networkPollTimer = null;
1228+
}
12061229
});
12071230

12081231
app.on('window-all-closed', () => {

src/viewer/viewer.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,9 @@ window.viewerApi.onShowWindow(async () => {
624624
container.classList.remove('visible');
625625
void container.offsetHeight;
626626
container.classList.add('visible');
627+
628+
// Safety: re-check height after paint in case initial measurement was stale
629+
requestAnimationFrame(() => notifyHeight());
627630
});
628631

629632
// When background sync completes, refresh the task list if visible

0 commit comments

Comments
 (0)