From 57610bc2fd3b1cc4d516dbdcddf4d2a524b0fc4c Mon Sep 17 00:00:00 2001
From: Audrey Hamelers <hamelers@ebi.ac.uk>
Date: Fri, 1 Mar 2019 17:20:29 +0000
Subject: [PATCH] event description updates for merged users

---
 app/components/activity/EventDescription.jsx | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/app/components/activity/EventDescription.jsx b/app/components/activity/EventDescription.jsx
index 2b567fe5a..3a509e75b 100644
--- a/app/components/activity/EventDescription.jsx
+++ b/app/components/activity/EventDescription.jsx
@@ -47,8 +47,11 @@ const ReplyButton = styled(Button)`
 `
 const Username = ({ id }) => (
   <Query query={GET_USER} variables={{ id }}>
-    {({ data, loading }) => {
-      if (loading || !data || !data.user) {
+    {({ data, loading, error }) => {
+      if (error) {
+        return <em>[User has been deleted]</em>
+      }
+      if (loading || !data) {
         return `...`
       }
       const { givenNames, surname } = data.user.identities[0].name
@@ -244,10 +247,16 @@ const EventDescription = ({ audit, manuscript }) => {
     )
   }
   if (objectType === 'team') {
-    if (changes.role_name === 'submitter') {
+    if (
+      changes.role_name === 'submitter' ||
+      (originalData && originalData.role_name === 'submitter')
+    ) {
       return `Became submitter`
     }
-    if (changes.role_name === 'reviewer') {
+    if (
+      changes.role_name === 'reviewer' ||
+      (originalData && originalData.role_name === 'reviewer')
+    ) {
       if (audit.user.id === changes.user_id) {
         return `Became reviewer`
       }
-- 
GitLab