This repository has been archived by the owner on Oct 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #680 from SuperViz/lab
Little bug fixes
- Loading branch information
Showing
8 changed files
with
90 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,6 +39,7 @@ const generateMockParticipant = ({ | |
name, | ||
disableDropdown, | ||
isPrivate, | ||
avatar: {}, | ||
}, | ||
}; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,70 @@ | ||
import { ParticipantByGroupApi } from '../../../common/types/participant.types'; | ||
|
||
|
||
const MENTION_ACTION = { | ||
SHOW: 'show', | ||
HIDE: 'hide' | ||
} | ||
HIDE: 'hide', | ||
}; | ||
|
||
const DEFAULT_HIDE_MENTION_LIST = { | ||
action: MENTION_ACTION.HIDE, | ||
mentions: [], | ||
findDigitParticipant: false, | ||
} | ||
}; | ||
|
||
type hideMentionList = { | ||
action: string; | ||
mentions: ParticipantByGroupApi[]; | ||
findDigitParticipant: boolean | ||
findDigitParticipant: boolean; | ||
}; | ||
|
||
const matchParticipant = (name: string, position, participantList: ParticipantByGroupApi[]): hideMentionList => { | ||
let mentionList = [] | ||
const matchParticipant = ( | ||
name: string, | ||
position, | ||
participantList: ParticipantByGroupApi[], | ||
): hideMentionList => { | ||
let mentionList = []; | ||
|
||
mentionList = participantList?.filter((participant: ParticipantByGroupApi) => participant?.email) | ||
mentionList = participantList?.filter((participant: ParticipantByGroupApi) => participant?.email); | ||
if (name.length > 0) { | ||
mentionList = mentionList | ||
.filter((participant: ParticipantByGroupApi) => participant?.name | ||
.toLowerCase() | ||
.search(name.toLowerCase()) !== -1 | ||
); | ||
if (name === mentionList[0]?.name?.toLowerCase()) { | ||
const mentions = prepareMentionList(mentionList, position); | ||
return { | ||
action: MENTION_ACTION.HIDE, | ||
mentions, | ||
findDigitParticipant: true | ||
} | ||
} | ||
mentionList = mentionList.filter( | ||
(participant: ParticipantByGroupApi) => | ||
participant?.name.toLowerCase().search(name.toLowerCase()) !== -1, | ||
); | ||
|
||
if (name === mentionList[0]?.name?.toLowerCase()) { | ||
const mentions = prepareMentionList(mentionList, position); | ||
return { | ||
action: MENTION_ACTION.HIDE, | ||
mentions, | ||
findDigitParticipant: true, | ||
}; | ||
} | ||
} | ||
|
||
if (!(mentionList?.length > 0)) { | ||
return DEFAULT_HIDE_MENTION_LIST | ||
return DEFAULT_HIDE_MENTION_LIST; | ||
} | ||
|
||
const mentions = prepareMentionList(mentionList, position); | ||
|
||
return { | ||
action: MENTION_ACTION.SHOW, | ||
mentions, | ||
findDigitParticipant: false | ||
} | ||
} | ||
findDigitParticipant: false, | ||
}; | ||
}; | ||
|
||
const prepareMentionList = (users: ParticipantByGroupApi[], position): ParticipantByGroupApi[] => { | ||
return users.map((user: ParticipantByGroupApi) => ({ | ||
id: user.id, | ||
name: user.name, | ||
avatar: user.avatar, | ||
email: user.email, | ||
position | ||
})) | ||
} | ||
position, | ||
})); | ||
}; | ||
|
||
export default { | ||
matchParticipant: (name, position, participantList: ParticipantByGroupApi[]) => matchParticipant(name, position, participantList), | ||
} | ||
matchParticipant: (name, position, participantList: ParticipantByGroupApi[]) => | ||
matchParticipant(name, position, participantList), | ||
}; |