<html lang='en'>
<head>
<meta content='text/html; charset=utf-8' http-equiv='Content-Type'>
<title>
GitLab
</title>
</meta>
</head>
<style>
  img {
    max-width: 100%;
    height: auto;
  }
  p.details {
    font-style:italic;
    color:#777
  }
  .footer p {
    font-size:small;
    color:#777
  }
  pre.commit-message {
    white-space: pre-wrap;
  }
  .file-stats a {
    text-decoration: none;
  }
  .file-stats .new-file {
    color: #090;
  }
  .file-stats .deleted-file {
    color: #B00;
  }
</style>
<body>
<div class='content'>
<h3>Justin Mitchell pushed to branch master at <a href="https://projects.sucs.org/arthur/mw">Justin Mitchell / mw</a></h3>
<h4>
Commits:
</h4>
<ul>
<li>
<strong><a href="https://projects.sucs.org/arthur/mw/commit/ec3091a2759f1a6d13a4c87ed57b5e5510349cd9">ec3091a2</a></strong>
<div>
<span>by Justin Mitchell</span>
<i>at 2016-01-12T11:27:46Z</i>
</div>
<pre class='commit-message'>Factor out requests to refresh the wholist</pre>
</li>
<li>
<strong><a href="https://projects.sucs.org/arthur/mw/commit/97586a6ffcb0f2650402bd5f6eb727260455cdf7">97586a6f</a></strong>
<div>
<span>by Justin Mitchell</span>
<i>at 2016-01-12T11:50:14Z</i>
</div>
<pre class='commit-message'>found what broke autocomplete, fixes #6</pre>
</li>
</ul>
<h4>1 changed file:</h4>
<ul>
<li class='file-stats'>
<a href='#diff-0'>
src/client/who.c
</a>
</li>
</ul>
<h4>Changes:</h4>
<li id='diff-0'>
<a href='https://projects.sucs.org/arthur/mw/compare/c59917a3885d883cba0d279776fb40209956f181...97586a6ffcb0f2650402bd5f6eb727260455cdf7#diff-0'>
<strong>
src/client/who.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/src/client/who.c
</span><span style="color: #000000;background-color: #ddffdd">+++ b/src/client/who.c
</span><span style="color: #aaaaaa">@@ -46,6 +46,23 @@ static json_t * whoinfo = NULL;
</span> static time_t   whowhen = 0;
 static int      whotype = -1;
 #define WHOCACHE 120  /* cache who data for this many seconds */
<span style="color: #000000;background-color: #ddffdd">+#define NO_CALLBACK -1
+
+/* check if we need to refresh the wholist
+ * and request it if we do 
+ * report if we did
+ */
+static int refresh_wholist(int type)
+{
+       time_t now = time(0);
+       if (whoinfo == NULL || whowhen < (now - WHOCACHE)) {
+               whotype = type;
+               ipc_message_t * msg = ipcmsg_create(IPC_WHOLIST, user->posn);
+               ipcmsg_transmit(msg);
+               return 1;
+       }
+       return 0;
+}
</span> 
 void display_wholist(int mode)
 {
<span style="color: #aaaaaa">@@ -53,10 +70,7 @@ void display_wholist(int mode)
</span> 
        /* we dont have a recent cache of who list,
         * request one, and get called back when it arrives */
<span style="color: #000000;background-color: #ffdddd">-        if (whoinfo == NULL || whowhen < (now - WHOCACHE)) {
-               whotype = mode;
-               ipc_message_t * msg = ipcmsg_create(IPC_WHOLIST, user->posn);
-               ipcmsg_transmit(msg);
</span><span style="color: #000000;background-color: #ddffdd">+   if (refresh_wholist(mode)) {
</span>           return;
        }
 
<span style="color: #aaaaaa">@@ -104,8 +118,9 @@ void display_wholist(int mode)
</span> void update_wholist(ipc_message_t *msg)
 {
        /* there is an old one, clear it */
<span style="color: #000000;background-color: #ffdddd">-        if (whoinfo != NULL)
</span><span style="color: #000000;background-color: #ddffdd">+   if (whoinfo != NULL) {
</span>           json_decref(whoinfo);
<span style="color: #000000;background-color: #ddffdd">+        }
</span> 
        /* store the new one */
        whoinfo = json_init(msg);
<span style="color: #aaaaaa">@@ -122,14 +137,10 @@ char *part_who(const char *text, int status)
</span> {
        static int len = 0;
        static int index = 0; /* looking for the Nth answer */
<span style="color: #000000;background-color: #ffdddd">-        time_t now = time(NULL);
</span> 
        /* we dont have a recent cache of who list,
         * ask for an update, then do the best you can */
<span style="color: #000000;background-color: #ffdddd">-        if (whoinfo == NULL || whowhen < (now - WHOCACHE)) {
-               ipc_message_t * msg = ipcmsg_create(IPC_WHOLIST, user->posn);
-               ipcmsg_transmit(msg);
-       }
</span><span style="color: #000000;background-color: #ddffdd">+   refresh_wholist(NO_CALLBACK);
</span> 
        /* we dont even have stale info */
        if (whoinfo == NULL) return(NULL);
<span style="color: #aaaaaa">@@ -164,14 +175,10 @@ char *part_who_talk(const char *text, int status)
</span> {
        static int len = 0;
        static int index = 0; /* looking for the Nth answer */
<span style="color: #000000;background-color: #ffdddd">-        time_t now = time(NULL);
</span> 
        /* we dont have a recent cache of who list,
         * ask for an update, then do the best you can */
<span style="color: #000000;background-color: #ffdddd">-        if (whoinfo == NULL || whowhen < (now - WHOCACHE)) {
-               ipc_message_t * msg = ipcmsg_create(IPC_WHOLIST, user->posn);
-               ipcmsg_transmit(msg);
-       }
</span><span style="color: #000000;background-color: #ddffdd">+   refresh_wholist(NO_CALLBACK);
</span> 
        /* we dont even have stale info */
        if (whoinfo == NULL) return(NULL);
<span style="color: #aaaaaa">@@ -189,7 +196,7 @@ char *part_who_talk(const char *text, int status)
</span>           const char *name = json_getstring(entry, "name");
                json_t * perms = json_object_get(entry, "perms");
                const char *chatmode = NULL;
<span style="color: #000000;background-color: #ffdddd">-                if (perms != NULL) chatmode=json_getstring(entry, "chatmode");
</span><span style="color: #000000;background-color: #ddffdd">+           if (perms != NULL) chatmode=json_getstring(perms, "chatmode");
</span> 
                if (name == NULL) continue;
                if (chatmode == NULL) continue;
<span style="color: #aaaaaa">@@ -216,13 +223,9 @@ char *part_who_talk(const char *text, int status)
</span>  */
 json_t * grab_wholist(void)
 {
<span style="color: #000000;background-color: #ffdddd">-        time_t now = time(NULL);
</span>   /* we dont have a recent cache of who list,
         * ask for an update, then do the best you can */
<span style="color: #000000;background-color: #ffdddd">-        if (whoinfo == NULL || whowhen < (now - WHOCACHE)) {
-               ipc_message_t * msg = ipcmsg_create(IPC_WHOLIST, user->posn);
-               ipcmsg_transmit(msg);
-       }
</span><span style="color: #000000;background-color: #ddffdd">+   refresh_wholist(NO_CALLBACK);
</span> 
        if (whoinfo != NULL) json_incref(whoinfo);
        return whoinfo;
</code></pre>

<br>
</li>

</div>
<div class='footer' style='margin-top: 10px;'>
<p>

<br>
<a href="https://projects.sucs.org/arthur/mw/compare/c59917a3885d883cba0d279776fb40209956f181...97586a6ffcb0f2650402bd5f6eb727260455cdf7">View it on GitLab</a>.
<br>
You're receiving this email because of your account on projects.sucs.org.
If you'd like to receive fewer emails, you can adjust your notification settings.

</p>
</div>
</body>
</html>