Improvements based on sonar cloud feedback
This commit is contained in:
parent
7ae476af3d
commit
a20ee430ed
@ -79,23 +79,8 @@ export default function updateRandomUser(meetingId, userIds, choice, requesterId
|
||||
}
|
||||
|
||||
else { // We generate 5 users randomly, just for animation, and last one is the chosen one
|
||||
const itrations = intervals.length -1;
|
||||
let IDs = userIds.slice();
|
||||
for(i = 0; i < itrations; i++ ){
|
||||
if(IDs == 0) { // we used up all the options
|
||||
IDs = userIds.slice(); //start over
|
||||
let userId = IDs.splice(0, 1);
|
||||
if(userList[userList.length] == [userId, intervals[i]]){ //If we start over with the one we finnished, change it
|
||||
IDs.push(userId);
|
||||
userId = IDs.splice(0, 1)
|
||||
}
|
||||
userList.push([userId, intervals[i]]);
|
||||
} else {
|
||||
const userId = IDs.splice(Math.floor(Math.random() * IDs.length), 1);
|
||||
userList.push([userId, intervals[i]]);
|
||||
}
|
||||
}
|
||||
userList.push([chosenUser, intervals[itrations + 1]]);
|
||||
getFiveRandom(userList, userIds);
|
||||
userList.push([chosenUser, intervals[intervals.length]]);
|
||||
}
|
||||
|
||||
const modifier = {
|
||||
@ -113,3 +98,21 @@ export default function updateRandomUser(meetingId, userIds, choice, requesterId
|
||||
Logger.error(`Setting randomly selected userId and interval = ${userList} by requesterId=${requesterId} in meetingId=${meetingId}`);
|
||||
}
|
||||
}
|
||||
|
||||
function getFiveRandom(userList, userIds){
|
||||
let IDs = userIds.slice();
|
||||
for(let i = 0; i < intervals.length - 1; i++ ){
|
||||
if(IDs == 0) { // we used up all the options
|
||||
IDs = userIds.slice(); //start over
|
||||
let userId = IDs.splice(0, 1);
|
||||
if(userList[userList.length] == [userId, intervals[i]]){ //If we start over with the one we finnished, change it
|
||||
IDs.push(userId);
|
||||
userId = IDs.splice(0, 1)
|
||||
}
|
||||
userList.push([userId, intervals[i]]);
|
||||
} else {
|
||||
const userId = IDs.splice(Math.floor(Math.random() * IDs.length), 1);
|
||||
userList.push([userId, intervals[i]]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,12 +28,20 @@ const RandomUserSelectContainer = (props) => {
|
||||
|
||||
const currentUser = { userId: Auth.userID, presenter: users[Auth.meetingID][Auth.userID].presenter };
|
||||
|
||||
try{
|
||||
if(!currentUser.presenter && //this functionality does not bother presenter
|
||||
(keepModalOpen == false) && //we only ween a change if modal has been closed before
|
||||
(!keepModalOpen) && //we only ween a change if modal has been closed before
|
||||
(randomlySelectedUser[0][1] != updateIndicator)//if tey are different, a user was generated
|
||||
){ keepModalOpen = true; } //reopen modal
|
||||
|
||||
if(!currentUser.presenter){ updateIndicator = randomlySelectedUser[0][1]; } //keep indicator up to date
|
||||
}catch(err){
|
||||
console.error(
|
||||
"Issue in Random User container caused by back-end crash\n"
|
||||
+ "Value of 6 randomly selected users was passed as {"
|
||||
+ randomlySelectedUser
|
||||
+ "}\nHowever, it is handled.");
|
||||
}
|
||||
|
||||
if (randomlySelectedUser) {
|
||||
mappedRandomlySelectedUsers = randomlySelectedUser.map((ui) => {
|
||||
|
Loading…
Reference in New Issue
Block a user