                   onkeyup: (e) ->
                       chilledaction 'searchentities', e.currentTarget.value, 7
                       action 'conversationquery', e.currentTarget.value, 7
-              inputSetValue '.search-input', convsettings.searchQuery
 
       ul ->
           convsettings.selectedEntities.forEach (r) ->
               cid = r?.id?.chat_id
               li class: 'selected', ->
-                  if purl = r.properties.photo_url ? entity[cid].photo_url
+                  if purl = r.properties?.photo_url ? entity[cid]?.photo_url
                       img src:photoUrlProtocolFix purl
                   else
                       img src:"images/photo.jpg"


unique = (obj) -> obj.id.chat_id or obj.id.gaia_id

photoUrlProtocolFix = (url) -> return "http:" + url if url?.indexOf('//') == 0

inputSetValue = (sel, val) ->
    setTimeout ->
        el = document.querySelector sel
        el.value = val if el != null
    , 1
    null

module.exports = view (models) ->
    {convsettings, entity} = models

              cid = r?.id?.chat_id
              if unique(r) in selected_ids then return
              li ->
                  if purl = r.properties?.photo_url ? entity[cid]?.photo_url
                      img src:photoUrlProtocolFix purl
                  else
                      img src:"images/photo.jpg"
