clicking on conversations in the search view opens the conversation view!
authorAndrew Sutherland <asutherland@asutherland.org>
Tue, 13 Jan 2009 04:15:55 -0800
changeset 18 6fd418a119c2359f5542ea91a204eae7d706b266
parent 17 5a832fd81f4173a9cdb61dd2b274ea43b407a981
child 19 e7fcdc0e50b226dd2222cd91c3a70d01dc2506d7
push id1
push userroot
push dateWed, 08 Apr 2009 01:46:05 +0000
clicking on conversations in the search view opens the conversation view!
client/cloda.js
client/messages.xml
--- a/client/cloda.js
+++ b/client/cloda.js
@@ -150,16 +150,17 @@ GlodaConvQuery.prototype = {
     var rows = result.rows, iRow, row, contact_id;
     for (iRow = 0; iRow < rows.length; iRow++) {
       row = rows[iRow];
       var message = row.doc;
       var conversation = conversations[message.conversation_id];
       if (conversation === undefined)
         conversation = conversations[message.conversation_id] = {
           __proto__: GlodaConversationProto,
+          id: message.conversation_id,
           oldest: message.timestamp, newest: message.timestamp,
           involves_contact_ids: {}, messages: []
         };
       conversation.messages.push(message);
       if (conversation.oldest > message.timestamp)
         conversation.oldest = message.timestamp;
       if (conversation.newest < message.timestamp)
         conversation.newest = message.timestamp;
@@ -191,28 +192,34 @@ GlodaConvQuery.prototype = {
     var rows = result.rows, iRow, row, contact;
     var contacts = {};
     for (iRow = 0; iRow < rows.length; iRow++) {
       row = rows[iRow];
       contact = row.doc;
       contacts[contact._id] = contact;
     }
 
+    function mapContactMap(aMap) {
+      var out = [];
+      for (var key in aMap)
+        out.push(contacts[key]);
+      return out;
+    }
     function mapContactList(aList) {
       var out = [];
       for (var i = 0; i < aList.length; i++) {
         out.push(contacts[aList[i]]);
       }
       return out;
     }
 
     // -- process the conversations
     var convList = [];
     for each (var conversation in this.conversations) {
-      conversation.involves = mapContactList(conversation.involves_contact_ids);
+      conversation.involves = mapContactMap(conversation.involves_contact_ids);
       convList.push(conversation);
 
       for (var iMsg = 0; iMsg < conversation.messages.length; iMsg++) {
         var message = conversation.messages[iMsg];
         message.__proto__ = GlodaMessageProto;
         message.from = contacts[message.from_contact_id];
         message.to = mapContactList(message.to_contact_ids);
         message.cc = mapContactList(message.cc_contact_ids);
--- a/client/messages.xml
+++ b/client/messages.xml
@@ -139,16 +139,22 @@
             var node = $("<div/>")[0];
             ElementXBL.prototype.addBinding.call(node, "messages.xml#reply");
             node.setMessage(message);
             replyNodes.appendChild(node);
           }
         },
       })
     ]]></xbl:implementation>
+    <xbl:handlers>
+      <xbl:handler event="click" phase="bubble" default-action="cancel"><![CDATA[
+        window.open(window.location.href.replace("index.xhtml",
+          "conversation.xhtml?id=" + this.conversation.id));
+      ]]></xbl:handler>
+    </xbl:handlers>
   </xbl:binding>
 
   <xbl:binding id="reply">
     <xbl:template>
       <div class="author">
         <span id="from" class="name"/>
         <span id="date" class="data"/>
       </div>