]> git.localhorst.tv Git - alttp.git/blobdiff - resources/js/helpers/Participant.js
allow users to set their stream link
[alttp.git] / resources / js / helpers / Participant.js
index a44d465a4e57609b0e45ff5e756fde2344a1a8e2..eb943401f6074057b4e6fc625c0d7385c4d15042 100644 (file)
@@ -40,6 +40,18 @@ export const findResult = (participant, round) => {
        return round.results.find(result => result.user_id === participant.user_id);
 };
 
+export const patchUser = (participant, user) => {
+       if (!participant || !user) return participant;
+       if (participant.user_id != user.id) return participant;
+       return {
+               ...participant,
+               user: {
+                       ...participant.user,
+                       ...user,
+               },
+       };
+};
+
 export const sortByResult = (participants, round) => {
        if (!participants || !participants.length) return participants;
        if (!round || !round.results || !round.results.length) return participants;
@@ -50,5 +62,6 @@ export default {
        compareResult,
        compareUsername,
        findResult,
+       patchUser,
        sortByResult,
 };