v3: fixes to database schema and user registration
This commit is contained in:
@@ -63,7 +63,12 @@ function isStringArray(val: unknown): val is string[] {
|
||||
|
||||
function isVotesUpdatePayload(
|
||||
msg: Record<string, unknown>,
|
||||
): msg is { dumpId: string; voteCount: number; voterId: string; action: "cast" | "remove" } {
|
||||
): msg is {
|
||||
dumpId: string;
|
||||
voteCount: number;
|
||||
voterId: string;
|
||||
action: "cast" | "remove";
|
||||
} {
|
||||
return typeof msg.dumpId === "string" &&
|
||||
typeof msg.voteCount === "number" &&
|
||||
typeof msg.voterId === "string" &&
|
||||
@@ -164,7 +169,9 @@ export function WSProvider({ children, token, userId }: WSProviderProps) {
|
||||
|
||||
case "welcome": {
|
||||
backoff = 500; // reset backoff on successful connect
|
||||
if (!isOnlineUserArray(msg.users) || !isStringArray(msg.myVotes)) break;
|
||||
if (!isOnlineUserArray(msg.users) || !isStringArray(msg.myVotes)) {
|
||||
break;
|
||||
}
|
||||
setOnlineUsers(msg.users);
|
||||
setMyVotes(new Set(msg.myVotes));
|
||||
setUnreadNotificationCount(
|
||||
@@ -320,7 +327,9 @@ export function WSProvider({ children, token, userId }: WSProviderProps) {
|
||||
}
|
||||
|
||||
case "notification_created": {
|
||||
if (!msg.notification || typeof msg.notification !== "object") break;
|
||||
if (!msg.notification || typeof msg.notification !== "object") {
|
||||
break;
|
||||
}
|
||||
const notification = deserializeNotification(
|
||||
msg.notification as RawNotification,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user