Skip to content

Commit 540e38d

Browse files
committedApr 9, 2015
Conpherence - fix recent participant cache
Summary: Ref T7795. This fixes the behavior where you end up with a "a, b, c..." as the list of participants, and yet user a just left. Test Plan: joined and left a thread. verified database had correct values. observed correct behavior in messages dropdown Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin, epriestley Maniphest Tasks: T7795 Differential Revision: https://secure.phabricator.com/D12338
1 parent dba984b commit 540e38d

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed
 

‎src/applications/conpherence/editor/ConpherenceEditor.php

+21-5
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ protected function applyCustomInternalTransaction(
235235
PhabricatorLiskDAO $object,
236236
PhabricatorApplicationTransaction $xaction) {
237237

238+
$make_author_recent_participant = true;
238239
switch ($xaction->getTransactionType()) {
239240
case PhabricatorTransactions::TYPE_COMMENT:
240241
$object->setMessageCount((int)$object->getMessageCount() + 1);
@@ -244,23 +245,38 @@ protected function applyCustomInternalTransaction(
244245
break;
245246
case ConpherenceTransactionType::TYPE_PARTICIPANTS:
246247
if (!$this->getIsNewObject()) {
247-
// if we added people, add them to the end of "recent" participants
248248
$old_map = array_fuse($xaction->getOldValue());
249249
$new_map = array_fuse($xaction->getNewValue());
250+
// if we added people, add them to the end of "recent" participants
250251
$add = array_keys(array_diff_key($new_map, $old_map));
251-
if ($add) {
252+
// if we remove people, then definintely remove them from "recent"
253+
// participants
254+
$del = array_keys(array_diff_key($old_map, $new_map));
255+
if ($add || $del) {
252256
$participants = $object->getRecentParticipantPHIDs();
253-
$participants = array_merge($participants, $add);
257+
if ($add) {
258+
$participants = array_merge($participants, $add);
259+
}
260+
if ($del) {
261+
$participants = array_diff($participants, $del);
262+
$actor = $this->requireActor();
263+
if (in_array($actor->getPHID(), $del)) {
264+
$make_author_recent_participant = false;
265+
}
266+
}
254267
$participants = array_slice(array_unique($participants), 0, 10);
255268
$object->setRecentParticipantPHIDs($participants);
256269
}
257270
}
258271
break;
259272
}
260-
$this->updateRecentParticipantPHIDs($object, $xaction);
273+
274+
if ($make_author_recent_participant) {
275+
$this->makeAuthorMostRecentParticipant($object, $xaction);
276+
}
261277
}
262278

263-
private function updateRecentParticipantPHIDs(
279+
private function makeAuthorMostRecentParticipant(
264280
PhabricatorLiskDAO $object,
265281
PhabricatorApplicationTransaction $xaction) {
266282

0 commit comments

Comments
 (0)
Failed to load comments.