Browse Source

Improve handling of user states. Add functionality to disable contact button when the person cannot be added as a contact.

pull/151/head
Evan Theurer 11 years ago
parent
commit
12db32cc80
  1. 15
      static/js/directives/chat.js
  2. 4
      static/partials/chatroom.html

15
static/js/directives/chat.js

@ -205,6 +205,7 @@ define(['jquery', 'underscore', 'text!partials/chat.html', 'text!partials/chatro @@ -205,6 +205,7 @@ define(['jquery', 'underscore', 'text!partials/chat.html', 'text!partials/chatro
}
subscope = controller.rooms[id] = scope.$new();
translation.inject(subscope);
subscope.contact = {};
subscope.id = id;
subscope.isgroupchat = !!settings.group;
subscope.index = index;
@ -217,9 +218,15 @@ define(['jquery', 'underscore', 'text!partials/chat.html', 'text!partials/chatro @@ -217,9 +218,15 @@ define(['jquery', 'underscore', 'text!partials/chat.html', 'text!partials/chatro
subscope.p2pstate = false;
subscope.active = false;
subscope.pending = 0;
subscope.isUser = !!(buddy && buddy.session && buddy.session.Userid);
subscope.isContact = !!(buddy && buddy.contact);
subscope.canAddContact = !subscope.isgroupchat && subscope.isUser;
var handleContactFunctionality = function() {
var buddyId = buddy && buddy.session && buddy.session.Userid;
var myId = appData.get().userid;
var isAnotherUser = buddyId && myId !== buddyId;
subscope.contact.isContact = !!(buddy && buddy.contact);
subscope.contact.disableContact = !myId || !isAnotherUser;
subscope.contact.showContact = !subscope.isgroupchat && buddyId;
};
handleContactFunctionality();
if (!subscope.isgroupchat) {
buddyData.push(id);
}
@ -349,7 +356,7 @@ define(['jquery', 'underscore', 'text!partials/chat.html', 'text!partials/chatro @@ -349,7 +356,7 @@ define(['jquery', 'underscore', 'text!partials/chat.html', 'text!partials/chatro
if (userid !== data.Userid) {
return;
}
subscope.isContact = event.type === "contactadded";
subscope.contact.isContact = event.type === "contactadded";
safeApply(subscope);
};
contacts.e.on("contactadded", subscope.updateContactStatus);

4
static/partials/chatroom.html

@ -5,8 +5,8 @@ @@ -5,8 +5,8 @@
<button ng-if="!isgroupchat" class="btn btn-sm btn-default" title="{{_('Start video call')}}" ng-click="doCall()"><i class="fa fa-phone fa-fw"></i></button>
<button class="btn btn-sm btn-default btn-fileupload" title="{{_('Upload files')}}"><i class="fa fa-upload fa-fw"></i></button>
<button class="btn btn-sm btn-default btn-locationshare" title="{{_('Share my location')}}" ng-click="shareGeolocation()"><i class="fa fa-location-arrow fa-fw"></i></button>
<button ng-if="canAddContact && !isContact" class="btn btn-sm btn-primary" title="{{_('Add to contacts')}}" ng-click="addContact()"><i class="fa fa-star-o"></i></button>
<button ng-if="canAddContact && isContact" class="btn btn-sm btn-primary" title="{{_('Remove from contacts')}}" ng-click="removeContact()"><i class="fa fa-star"></i></button>
<button ng-if="contact.showContact && !contact.isContact" class="btn btn-sm btn-default" ng-class="{'disabled': contact.disableContact}" title="{{_('Add to contacts')}}" ng-click="addContact()"><i class="fa fa-star-o"></i></button>
<button ng-if="contact.showContact && contact.isContact" class="btn btn-sm btn-default" title="{{_('Remove from contacts')}}" ng-click="removeContact()"><i class="fa fa-star"></i></button>
</div>
<div class="btn-group pull-right">
<button class="btn btn-sm btn-default" title="{{_('Clear chat')}}" ng-click="doClear()"><i class="fa fa-eraser fa-fw"></i></button>

Loading…
Cancel
Save