mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 14:52:41 +01:00
Fix some EditEngine issues with rendering "invite" transactions
Summary: Ref T9275. We were rendering too many transactions and/or over-rendering invitees. Clean this logic up a bit: - List all before/after invitees. - Simplify the lists before rendering. Test Plan: Viewed an event, edited invitees, got sensible human-readable transactions. Reviewers: chad Reviewed By: chad Maniphest Tasks: T9275 Differential Revision: https://secure.phabricator.com/D16284
This commit is contained in:
parent
ea813985a2
commit
46cf189413
2 changed files with 26 additions and 6 deletions
|
@ -163,6 +163,8 @@ final class PhabricatorCalendarEventEditor
|
|||
$map[$phid] = $status_uninvited;
|
||||
} else if (!$is_old && $is_new) {
|
||||
$map[$phid] = $status_invited;
|
||||
} else {
|
||||
$map[$phid] = $invitees[$phid]->getStatus();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -176,10 +176,7 @@ final class PhabricatorCalendarEventTransaction
|
|||
case self::TYPE_INVITE:
|
||||
$text = null;
|
||||
|
||||
// Fill in any new invitees as "uninvited" in the old data, to make
|
||||
// some of the rendering logic a little easier.
|
||||
$status_uninvited = PhabricatorCalendarEventInvitee::STATUS_UNINVITED;
|
||||
$old = $old + array_fill_keys(array_keys($new), $status_uninvited);
|
||||
list($old, $new) = $this->getSimpleInvites($old, $new);
|
||||
|
||||
if (count($old) === 1
|
||||
&& count($new) === 1
|
||||
|
@ -396,8 +393,7 @@ final class PhabricatorCalendarEventTransaction
|
|||
case self::TYPE_INVITE:
|
||||
$text = null;
|
||||
|
||||
$status_uninvited = PhabricatorCalendarEventInvitee::STATUS_UNINVITED;
|
||||
$old = $old + array_fill_keys(array_keys($new), $status_uninvited);
|
||||
list($old, $new) = $this->getSimpleInvites($old, $new);
|
||||
|
||||
if (count($old) === 1
|
||||
&& count($new) === 1
|
||||
|
@ -592,4 +588,26 @@ final class PhabricatorCalendarEventTransaction
|
|||
return $tags;
|
||||
}
|
||||
|
||||
private function getSimpleInvites(array $old, array $new) {
|
||||
// Fill in any new invitees as "uninvited" in the old data, to make
|
||||
// some of the rendering logic a little easier.
|
||||
$status_uninvited = PhabricatorCalendarEventInvitee::STATUS_UNINVITED;
|
||||
$old = $old + array_fill_keys(array_keys($new), $status_uninvited);
|
||||
|
||||
$all = $old + $new;
|
||||
foreach (array_keys($all) as $key) {
|
||||
// If the invitee exists in both the old and new lists with the same
|
||||
// value, remove it from both.
|
||||
if (isset($old[$key]) && isset($new[$key])) {
|
||||
if ($old[$key] == $new[$key]) {
|
||||
unset($old[$key]);
|
||||
unset($new[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return array($old, $new);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue