feat: show room shared icon

pull/82/head
sualko 2020-09-08 17:01:50 +02:00
parent b5f03b5981
commit 4203ee3987
5 changed files with 29 additions and 7 deletions

View File

@ -54,12 +54,14 @@ class Room extends Entity implements JsonSerializable {
public $password;
public $everyoneIsModerator;
public $requireModerator = false;
public $shared = false;
public function __construct() {
$this->addType('maxParticipants', 'integer');
$this->addType('record', 'boolean');
$this->addType('everyoneIsModerator', 'boolean');
$this->addType('requireModerator', 'boolean');
$this->addType('shared', 'boolean');
}
public function jsonSerialize(): array {
@ -74,7 +76,8 @@ class Room extends Entity implements JsonSerializable {
'access' => $this->access,
'password' => $this->password,
'everyoneIsModerator' => boolval($this->everyoneIsModerator),
'requireModerator' => boolval($this->requireModerator),
'requireModerator' => boolval($this->requireModerator),
'shared' => boolval($this->shared),
];
}
}

View File

@ -19,9 +19,13 @@ class RoomMapper extends QBMapper {
public function find(int $id): Room {
/* @var $qb IQueryBuilder */
$qb = $this->db->getQueryBuilder();
$qb->select('*')
->from($this->tableName)
->where($qb->expr()->eq('id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT)));
$qb->select('r.*')
->from($this->tableName, 'r')
->leftJoin('r', 'bbb_room_shares', 's', $qb->expr()->eq('r.id', 's.room_id'))
->addSelect($qb->createFunction('count(case when "s"."permission" = 0 then 1 else null end) as shared'))
->where($qb->expr()->eq('r.id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT)))
->groupBy('r.id');
;
/** @var Room */
return $this->findEntity($qb);
@ -34,9 +38,13 @@ class RoomMapper extends QBMapper {
public function findByUid(string $uid): Room {
/* @var $qb IQueryBuilder */
$qb = $this->db->getQueryBuilder();
$qb->select('*')
->from($this->tableName)
->where($qb->expr()->eq('uid', $qb->createNamedParameter($uid)));
$qb->select('r.*')
->from($this->tableName, 'r')
->leftJoin('r', 'bbb_room_shares', 's', $qb->expr()->eq('r.id', 's.room_id'))
->addSelect($qb->createFunction('count(case when "s"."permission" = 0 then 1 else null end) as shared'))
->where($qb->expr()->eq('r.uid', $qb->createNamedParameter($uid)))
->groupBy('r.id');
;
/** @var Room */
return $this->findEntity($qb);
@ -51,6 +59,7 @@ class RoomMapper extends QBMapper {
$qb->select('r.*')
->from($this->tableName, 'r')
->leftJoin('r', 'bbb_room_shares', 's', $qb->expr()->eq('r.id', 's.room_id'))
->addSelect($qb->createFunction('count(case when "s"."permission" = 0 then 1 else null end) as shared'))
->where(
$qb->expr()->orX(
$qb->expr()->eq('r.user_id', $qb->createNamedParameter($userId)),

View File

@ -37,6 +37,7 @@ export interface Room {
password?: string;
everyoneIsModerator: boolean;
requireModerator: boolean;
shared: boolean;
}
export interface RoomShare {

View File

@ -44,6 +44,14 @@ const EditRoomDialog: React.FC<Props> = ({ room, restriction, updateProperty, op
});
}, [room.id, open]);
useEffect(() => {
if (!shares) {
return;
}
updateProperty('shared', shares.filter(share => share.permission === Permission.Admin).length > 0);
}, [shares]);
function inputElement(label: string, field: string, type: 'text' | 'number' = 'text') {
return (
<div className="bbb-form-element">

View File

@ -187,6 +187,7 @@ const RoomRow: React.FC<Props> = (props) => {
</td>
<td className="bbb-shrink">
{room.userId !== OC.currentUser && <img src={avatarUrl} alt="Avatar" className="bbb-avatar" />}
{(room.userId === OC.currentUser && room.shared) && <span className="icon icon-shared icon-visible"/>}
</td>
<td className="max-participants bbb-shrink">
{edit('maxParticipants', 'number', {min: minParticipantsLimit, max: maxParticipantsLimit < 0 ? undefined : maxParticipantsLimit})}