-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
173 additions
and
74 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
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Socket } from "socket.io"; | ||
import { getArgumentScores } from "../analysis/argumentScoreHandler"; | ||
import { getReactionCountsForArgument, getUserReactionForArgument } from "../db/operations/reactionOperations"; | ||
|
||
|
||
export const sendReactionUpdate = async ( | ||
socket: Socket, | ||
io: any, | ||
graphId: string, | ||
argumentId: string | ||
) => { | ||
// Send new UserReaction state to the user who performed the action | ||
const userReaction = await getUserReactionForArgument(socket.data.user.id, argumentId); | ||
socket.emit('user reaction update', { argumentId, userReaction }) | ||
// Send new ReactionCounts states to all users currently in the graph | ||
const reactionCounts = await getReactionCountsForArgument(argumentId); | ||
io.to(graphId).emit('argument reactions update', { argumentId, reactionCounts }); | ||
// Send the new argument scores to all users currently in the graph | ||
// TODO Only send scores that changed | ||
const newScores = await getArgumentScores(graphId); | ||
// Convert Map to plain object before sending | ||
const scoresObject = Object.fromEntries(newScores); | ||
io.to(graphId).emit('graph scores update', scoresObject); | ||
} |
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