From 17b225bd40c415a8748c1bcc1af07d8aef7ddbf3 Mon Sep 17 00:00:00 2001 From: ketmar Date: Mon, 9 Apr 2018 18:31:33 +0000 Subject: [PATCH] cosmetic fixes FossilOrigin-Name: 110c945692844511261af782357c8c7b2be8398729d047ab8eef9eccc8c86034 --- bioacid.d | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/bioacid.d b/bioacid.d index 9edd5cb..21a0379 100644 --- a/bioacid.d +++ b/bioacid.d @@ -916,19 +916,10 @@ public: bool mIAmConnecting = false; bool mIAmOnline = false; bool forceOnline = true; // set to `false` to stop autoreconnecting - //bool restoreOnline = false; // will be set to `true` if we need to reconnect - //bool doRefreshNicks = false; public: @property bool isConnecting () const nothrow @safe @nogc => mIAmConnecting; - @property ContactStatus status () const nothrow @safe @nogc { - if (!toxpk.isValidKey) return ContactStatus.Offline; - if (mIAmConnecting) return ContactStatus.Connecting; - if (!mIAmOnline) return ContactStatus.Offline; - return mStatus; - } - @property bool isOnline () const nothrow @safe @nogc { if (!toxpk.isValidKey) return false; if (mIAmConnecting) return false; @@ -936,22 +927,24 @@ public: return true; } + @property ContactStatus status () const nothrow @safe @nogc { + if (!toxpk.isValidKey) return ContactStatus.Offline; + if (mIAmConnecting) return ContactStatus.Connecting; + if (!mIAmOnline) return ContactStatus.Offline; + return mStatus; + } + @property void status (ContactStatus v) { if (!toxpk.isValidKey) return; conwriteln("changing status to ", v, " (old: ", mStatus, ")"); if (v == ContactStatus.Connecting) v = ContactStatus.Online; - if (v == ContactStatus.Offline) { - forceOnline = false; - } else { - forceOnline = true; - } + forceOnline = (v != ContactStatus.Offline); if (mStatus == ContactStatus.Offline) { if (v != ContactStatus.Offline) mIAmConnecting = true; } toxCoreSetStatus(toxpk, v); mStatus = v; glconPostScreenRepaint(); - fixTrayIcon(); } @@ -1030,8 +1023,9 @@ private: mIAmConnecting = false; mIAmOnline = false; if (forceOnline) { - status = mStatus; - mIAmConnecting = true; + auto oldst = mStatus; + mStatus = ContactStatus.Offline; + status = oldst; } foreach (Contact ct; contacts.byValue) ct.status = ContactStatus.Offline; glconPostScreenRepaint(); @@ -1072,15 +1066,18 @@ private: void toxFriendStatus (in ref PubKey fpk, ContactStatus cst) { if (auto ct = fpk in contacts) { + if (ct.kfd) return; if (ct.status != cst) { + conwriteln("status for friend <", ct.info.nick, "> changed to ", cst); auto ls = toxCoreLastSeen(toxpk, fpk); if (ls != SysTime.min) { auto lsu = cast(uint)ls.toUnixTime(); - if (ct.info.lastonlinetime != lsu) { ct.info.lastonlinetime = lsu; ct.markDirty(); glconPostScreenRepaint(); } + if (ct.info.lastonlinetime != lsu) { ct.info.lastonlinetime = lsu; ct.markDirty(); } } - conwriteln("status for friend <", ct.info.nick, "> changed to ", cst); - ct.status = (!ct.kfd ? cst : ContactStatus.Offline); - //if (ct.status != ContactStatus.Offline && ct.status != ContactStatus.Connecting) ct.processResendQueue(); + ct.status = cst; + // if it is online, and it is not a friend, turn it into a friend + if (ct.online && !ct.friend) ct.kind = ContactInfo.Kind.Friend; + if (ct.online) ct.processResendQueue(); // why not? glconPostScreenRepaint(); } } -- 2.11.4.GIT