From 9887ba207990d371072c0de9856e4a3c0079f9cb Mon Sep 17 00:00:00 2001 From: ketmar Date: Mon, 8 Nov 2021 08:39:44 +0000 Subject: [PATCH] use db data version checks to avoid some unnecessary updates (mostly tray anim and folder rescan) FossilOrigin-Name: fca16348ffdfb3b17f86c485f29c3ca02409e517259709cd392ccfb5f80df7e7 --- chiroptera.d | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/chiroptera.d b/chiroptera.d index 893cc71..2d907fa 100644 --- a/chiroptera.d +++ b/chiroptera.d @@ -226,6 +226,7 @@ class FolderInfo { } __gshared FolderInfo[] folderList; +__gshared uint folderDataVersion = uint.max; //FIXME: make this faster @@ -235,6 +236,8 @@ bool rescanFolders () { import std.conv : to; bool res = false; + if (folderList.length != 0 && dbView.getDataVersion() == folderDataVersion) return false; // nothing to do here + bool needsort = false; foreach (FolderInfo fi; folderList) fi.seen = false; @@ -365,6 +368,8 @@ bool rescanFolders () { } setupTrayAnimation(); + folderDataVersion = dbView.getDataVersion(); + //conwriteln("ver=", folderDataVersion); return res; } @@ -380,6 +385,7 @@ shared static this () { evTrayAnimationStep = new TrayAnimationStepEvent(); } __gshared int trayAnimationIndex = 0; // 0: no animation __gshared int trayAnimationDir = 1; // direction +__gshared uint trayAnimDataVersion = uint.max; // ////////////////////////////////////////////////////////////////////////// // @@ -441,10 +447,19 @@ void setupTrayAnimation () { LIMIT 1 ;`); + if (trayicon is null) return; // no tray icon + + immutable uint dver = dbView.getDataVersion(); + //conwriteln("TRAY: dver=", dver, "; trv=", trayAnimDataVersion); + if (dver == trayAnimDataVersion) return; + trayAnimDataVersion = dver; + foreach (auto row; stmtGetUnread.st.range) { + //conwriteln("TRAY: start anim!"); trayStartAnimation(); return; } + //conwriteln("TRAY: stop anim!"); trayStopAnimation(); } @@ -1610,6 +1625,7 @@ final class MainPaneWindow : SubWindow { uint msglistCurrUId = 0; bool saveMsgListPositions = false; MonoTime lastStateSaveTime; + //uint viewDataVersion; this () { super(null, 0, 0, screenWidth, screenHeight); @@ -1617,8 +1633,16 @@ final class MainPaneWindow : SubWindow { add(); loadSavedState(); lastStateSaveTime = MonoTime.currTime; + //viewDataVersion = dbView.getDataVersion()-1; } + /* + bool isViewChanged () const nothrow @trusted @nogc { + pragma(inline, true); + return (viewDataVersion == dbView.getDataVersion()); + } + */ + void updateViewsIfTid (uint tid) { if (tid && lastDecodedTid == tid) { switchToFolderTid(lastDecodedTid, forced:true); -- 2.11.4.GIT