mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-25 15:39:27 -05:00
webui: added check for empty avatars and implemented avatar notify callback
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@8551 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
0e1b3eac2e
commit
89187bd453
@ -24,13 +24,17 @@ void peerDetailsToStream(StreamBase& stream, RsPeerDetails& details)
|
||||
;
|
||||
}
|
||||
|
||||
bool peerInfoToStream(StreamBase& stream, RsPeerDetails& details, RsPeers* peers, std::list<RsGroupInfo>& grpInfo)
|
||||
bool peerInfoToStream(StreamBase& stream, RsPeerDetails& details, RsPeers* peers, std::list<RsGroupInfo>& grpInfo, bool have_avatar)
|
||||
{
|
||||
bool ok = true;
|
||||
peerDetailsToStream(stream, details);
|
||||
stream << makeKeyValue("is_online", peers->isOnline(details.id));
|
||||
|
||||
std::string avatar_address = "/"+details.id.toStdString()+"/avatar_image";
|
||||
|
||||
if(!have_avatar)
|
||||
avatar_address = "";
|
||||
|
||||
stream << makeKeyValue("avatar_address", avatar_address);
|
||||
|
||||
StreamBase& grpStream = stream.getStreamToMember("groups");
|
||||
@ -77,6 +81,12 @@ void PeersHandler::notifyListChange(int list, int type)
|
||||
}
|
||||
}
|
||||
|
||||
void PeersHandler::notifyPeerHasNewAvatar(std::string /*peer_id*/)
|
||||
{
|
||||
RsStackMutex stack(mMtx); /********** STACK LOCKED MTX ******/
|
||||
mStateTokenServer->replaceToken(mStateToken);
|
||||
}
|
||||
|
||||
void PeersHandler::tick()
|
||||
{
|
||||
std::list<RsPeerId> online;
|
||||
@ -91,6 +101,18 @@ void PeersHandler::tick()
|
||||
}
|
||||
}
|
||||
|
||||
static bool have_avatar(RsMsgs* msgs, const RsPeerId& id)
|
||||
{
|
||||
// check if avatar data is available
|
||||
// requests missing avatar images as a side effect
|
||||
unsigned char *data = NULL ;
|
||||
int size = 0 ;
|
||||
msgs->getAvatarData(id, data,size) ;
|
||||
std::vector<uint8_t> avatar(data, data+size);
|
||||
delete[] data;
|
||||
return size != 0;
|
||||
}
|
||||
|
||||
void PeersHandler::handleWildcard(Request &req, Response &resp)
|
||||
{
|
||||
bool ok = false;
|
||||
@ -132,7 +154,7 @@ void PeersHandler::handleWildcard(Request &req, Response &resp)
|
||||
mRsPeers->getGroupInfoList(grpInfo);
|
||||
RsPeerDetails details;
|
||||
ok &= mRsPeers->getPeerDetails(RsPeerId(str), details);
|
||||
ok = peerInfoToStream(resp.mDataStream, details, mRsPeers, grpInfo);
|
||||
ok = peerInfoToStream(resp.mDataStream, details, mRsPeers, grpInfo, have_avatar(mRsMsgs, RsPeerId(str)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -182,7 +204,7 @@ void PeersHandler::handleWildcard(Request &req, Response &resp)
|
||||
for(std::vector<RsPeerDetails>::iterator vit = detailsVec.begin(); vit != detailsVec.end(); ++vit)
|
||||
{
|
||||
if(vit->gpg_id == *lit)
|
||||
peerInfoToStream(locationStream.getStreamToMember(),*vit, mRsPeers, grpInfo);
|
||||
peerInfoToStream(locationStream.getStreamToMember(),*vit, mRsPeers, grpInfo, have_avatar(mRsMsgs, vit->id));
|
||||
}
|
||||
}
|
||||
resp.mStateToken = getCurrentStateToken();
|
||||
|
@ -20,6 +20,7 @@ public:
|
||||
// from NotifyClient
|
||||
// note: this may get called from foreign threads
|
||||
virtual void notifyListChange(int list, int type); // friends list change
|
||||
virtual void notifyPeerHasNewAvatar(std::string /*peer_id*/);
|
||||
|
||||
// from Tickable
|
||||
virtual void tick();
|
||||
|
@ -314,7 +314,7 @@ var Peers3 = React.createClass({
|
||||
return(<div key={loc.peer_id} style={{color: loc.is_online? "lime": "grey"}}>{/*<div style={online_style}></div>*/}{loc.location}</div>);
|
||||
});
|
||||
var avatars = this.props.data.locations.map(function(loc){
|
||||
if(loc.is_online)
|
||||
if(loc.is_online && (loc.avatar_address !== ""))
|
||||
{
|
||||
var avatar_url = api_url + component.getPath() + loc.avatar_address;
|
||||
return <img style={{borderRadius: "3mm", margin: "2mm"}} src={avatar_url}/>;
|
||||
|
@ -314,7 +314,7 @@ var Peers3 = React.createClass({
|
||||
return(<div key={loc.peer_id} style={{color: loc.is_online? "lime": "grey"}}>{/*<div style={online_style}></div>*/}{loc.location}</div>);
|
||||
});
|
||||
var avatars = this.props.data.locations.map(function(loc){
|
||||
if(loc.is_online)
|
||||
if(loc.is_online && (loc.avatar_address !== ""))
|
||||
{
|
||||
var avatar_url = api_url + component.getPath() + loc.avatar_address;
|
||||
return <img style={{borderRadius: "3mm", margin: "2mm"}} src={avatar_url}/>;
|
||||
|
Loading…
Reference in New Issue
Block a user