Merge pull request #326 from maraoz/fix/online-status

Fix avatar online status -- Awesome!
This commit is contained in:
Gustavo Maximiliano Cortez 2014-05-08 17:44:54 -03:00
commit 9b8b5383d2
3 changed files with 25 additions and 15 deletions

View File

@ -123,19 +123,17 @@
<div class="large-9 medium-9 small-9 columns">
<div class="bottom-copay"
ng-repeat="c in $root.wallet.getRegisteredPeerIds()">
<video
ng-if="$root.videoInfo[c.peerId]"
class="video-small"
<video ng-if="$root.videoInfo[c.peerId]"
avatar peer="{{c}}"
autoplay
confvideo
peer="{{c.peerId}}"
ng-src="{{$root.getVideoURL(c.peerId)}}"
title="{{c.peerId + (c.peerId == $root.wallet.network.peerId?' (You)':'')}}" ></video>
<img ng-if="!$root.videoInfo[c.peerId]"
ng-class="($root.wallet.getOnlinePeerIDs().indexOf(c.peerId) != -1) ? 'online' : 'offline'"
class="video-small"
ng-src="{{$root.getVideoURL(c.peerId)}}"
></video>
<img ng-if="!$root.videoInfo[c.peerId]"
avatar peer="{{c}}"
ng-class="($root.wallet.getOnlinePeerIDs().indexOf(c.peerId) != -1) ? 'online' : 'offline'"
src="./img/satoshi.gif"
title="{{c.peerId + (c.peerId == $root.wallet.network.peerId?' (You)':'')}}" />
/>
<span ng-if="c.nick" style="position:absolute; bottom:-10px; width: 80px; overflow: hidden;">{{c.nick}}</span>
</div>
</div>
@ -240,7 +238,7 @@
</select>
</div>
<div class="large-6 columns">
<h6>Select required number of signatures</h6>
<h6>Select required signatures</h6>
<select ng-model="requiredCopayers" ng-options="requiredCopayers as requiredCopayers for requiredCopayers in RCValues">
</select>
</div>

View File

@ -89,12 +89,15 @@ angular.module('copay.directives')
});
}
}
}).directive('confvideo', function($rootScope) {
}).directive('avatar', function($rootScope) {
return {
link: function(scope, element, attrs) {
var peer = attrs.peer;
element.addClass(($rootScope.wallet.getOnlinePeerIDs().indexOf(peer) != -1) ? 'online' : 'offline');
var muted = $rootScope.getVideoMutedStatus(peer);
var peer = JSON.parse(attrs.peer)
var peerId = peer.peerId;
var nick = peer.nick;
element.addClass('video-small');
element.attr('title', peerId + (peerId == $rootScope.wallet.network.peerId ? ' (You)' : ''));
var muted = $rootScope.getVideoMutedStatus(peerId);
if (muted) {
element.attr("muted", true);
}

View File

@ -9,6 +9,15 @@ angular.module('copay.controllerUtils')
$rootScope.getVideoURL = function(copayer) {
var vi = $rootScope.videoInfo[copayer]
if (!vi) return;
//alert($rootScope.wallet.getOnlinePeerIDs());
//alert(copayer);
if ($rootScope.wallet.getOnlinePeerIDs().indexOf(copayer) === -1) {
// peer disconnected, remove his video
delete $rootScope.videoInfo[copayer]
return;
}
var encoded = vi.url;
var url = decodeURI(encoded);
var trusted = $sce.trustAsResourceUrl(url);