1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 23:02:42 +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:
epriestley 2016-07-12 13:22:28 -07:00
parent ea813985a2
commit 46cf189413
2 changed files with 26 additions and 6 deletions

View file

@ -163,6 +163,8 @@ final class PhabricatorCalendarEventEditor
$map[$phid] = $status_uninvited; $map[$phid] = $status_uninvited;
} else if (!$is_old && $is_new) { } else if (!$is_old && $is_new) {
$map[$phid] = $status_invited; $map[$phid] = $status_invited;
} else {
$map[$phid] = $invitees[$phid]->getStatus();
} }
} }

View file

@ -176,10 +176,7 @@ final class PhabricatorCalendarEventTransaction
case self::TYPE_INVITE: case self::TYPE_INVITE:
$text = null; $text = null;
// Fill in any new invitees as "uninvited" in the old data, to make list($old, $new) = $this->getSimpleInvites($old, $new);
// some of the rendering logic a little easier.
$status_uninvited = PhabricatorCalendarEventInvitee::STATUS_UNINVITED;
$old = $old + array_fill_keys(array_keys($new), $status_uninvited);
if (count($old) === 1 if (count($old) === 1
&& count($new) === 1 && count($new) === 1
@ -396,8 +393,7 @@ final class PhabricatorCalendarEventTransaction
case self::TYPE_INVITE: case self::TYPE_INVITE:
$text = null; $text = null;
$status_uninvited = PhabricatorCalendarEventInvitee::STATUS_UNINVITED; list($old, $new) = $this->getSimpleInvites($old, $new);
$old = $old + array_fill_keys(array_keys($new), $status_uninvited);
if (count($old) === 1 if (count($old) === 1
&& count($new) === 1 && count($new) === 1
@ -592,4 +588,26 @@ final class PhabricatorCalendarEventTransaction
return $tags; 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);
}
} }