mirror of
https://github.com/nerzhul/ocsms.git
synced 2025-06-07 07:56:23 +00:00
Add contact photos into peerlist
Add some support into controller
This commit is contained in:
parent
2fe4cc0ce0
commit
da5447a51b
@ -30,9 +30,10 @@ class OcSmsApp extends App {
|
||||
/*
|
||||
caching dosn´t work because on every call all will be reinstantiated
|
||||
*/
|
||||
private static $contacts; // dosn´t work
|
||||
private static $contacts;
|
||||
private static $contactPhotos;
|
||||
|
||||
private static $contactsInverted; // dosn´t work
|
||||
private static $contactsInverted;
|
||||
|
||||
private $c;
|
||||
|
||||
@ -85,7 +86,6 @@ class OcSmsApp extends App {
|
||||
|
||||
public function getContacts() {
|
||||
// Only load contacts if they aren't in the buffer
|
||||
// dosn´t work
|
||||
if(count(self::$contacts) == 0) {
|
||||
$this->loadContacts();
|
||||
}
|
||||
@ -94,13 +94,20 @@ class OcSmsApp extends App {
|
||||
|
||||
public function getInvertedContacts() {
|
||||
// Only load contacts if they aren't in the buffer
|
||||
// dosn´t work
|
||||
if(count(self::$contactsInverted) == 0) {
|
||||
$this->loadContacts();
|
||||
}
|
||||
return self::$contactsInverted;
|
||||
}
|
||||
|
||||
public function getContactPhotos() {
|
||||
// Only load contacts if they aren't in the buffer
|
||||
if(count(self::$contactPhotos) == 0) {
|
||||
$this->loadContacts();
|
||||
}
|
||||
return self::$contactPhotos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Partially importe this function from owncloud Chat app
|
||||
* https://github.com/owncloud/chat/blob/master/app/chat.php
|
||||
@ -129,12 +136,15 @@ class OcSmsApp extends App {
|
||||
$this->pushPhoneNumberToCache($phoneIds, $r["FN"]);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset ($r["PHOTO"])) {
|
||||
// Remove useless prefix
|
||||
$photoURL = preg_replace("#VALUE=uri:#","",$r["PHOTO"]);
|
||||
self::$contactPhotos[$r["FN"]] = $photoURL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
all numbers will be formatted
|
||||
*/
|
||||
private function pushPhoneNumberToCache($rawPhone, $contactName) {
|
||||
|
||||
$phoneNb = PhoneNumberFormatter::format($rawPhone);
|
||||
|
@ -111,6 +111,7 @@ class SmsController extends Controller {
|
||||
$phoneList = $this->smsMapper->getLastMessageTimestampForAllPhonesNumbers($this->userId);
|
||||
$contactsSrc = $this->app->getContacts();
|
||||
$contacts = array();
|
||||
$photos = $this->app->getContactPhotos();
|
||||
|
||||
$countPhone = count($phoneList);
|
||||
foreach ($phoneList as $number => $ts) {
|
||||
@ -126,7 +127,7 @@ class SmsController extends Controller {
|
||||
}
|
||||
}
|
||||
$lastRead = $this->smsMapper->getLastReadDate($this->userId);
|
||||
return new JSONResponse(array("phonelist" => $phoneList, "contacts" => $contacts, "lastRead" => $lastRead));
|
||||
return new JSONResponse(array("phonelist" => $phoneList, "contacts" => $contacts, "lastRead" => $lastRead, "photos" => $photos));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -38,7 +38,6 @@
|
||||
}
|
||||
#app-mailbox-peers li > a {
|
||||
display: block;
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
-moz-box-sizing: border-box; box-sizing: border-box;
|
||||
white-space: nowrap;
|
||||
@ -124,3 +123,11 @@
|
||||
.msg-spacer {
|
||||
clear: both;
|
||||
}
|
||||
|
||||
.ocsms-plavatar {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
float: left;
|
||||
background-size: 40px;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
|
@ -289,7 +289,12 @@ function fetchInitialPeerList(jsondata) {
|
||||
peerLabel = fn;
|
||||
}
|
||||
if ($.inArray(peerLabel, bufferedContacts) == -1) {
|
||||
peerListBuf += '<li><a href="#" mailbox-navigation="' + idxVal2 + '" mailbox-label="' + peerLabel + '">' + peerLabel + '</a></li>';
|
||||
//peerListBuf += '<li><a href="#" mailbox-navigation="' + idxVal2 + '" mailbox-label="' + peerLabel + '">' + peerLabel + '</a></li>';
|
||||
peerListBuf += '<li><div class="ocsms-plavatar"';
|
||||
if (typeof jsondata['photos'][peerLabel] != 'undefined') {
|
||||
peerListBuf += 'style="background-image: url(' + jsondata['photos'][peerLabel] + ');"';
|
||||
}
|
||||
peerListBuf += '></div><a href="#" mailbox-navigation="' + idxVal2 + '" mailbox-label="' + peerLabel + '">' + peerLabel + '</a></li>';
|
||||
bufferedContacts.push(peerLabel);
|
||||
}
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user