fix: minor enhancement

This commit is contained in:
abdou6666 2025-04-09 16:56:09 +01:00
parent 8790b6fab8
commit b2c4335526
3 changed files with 7 additions and 6 deletions

View File

@ -81,11 +81,14 @@ export class BlockService extends BaseService<
subscribe(@SocketReq() req: SocketRequest, @SocketRes() res: SocketResponse) {
try {
if (req.session.web?.profile?.id) {
this.gateway.io.socketsJoin(`blocks:${req.session.web.profile.id}`);
const room = `blocks:${req.session.web.profile.id}`;
this.gateway.io.socketsJoin(room);
this.logger.log('Subscribed to socket room', room);
return res.status(200).json({
success: true,
});
} else {
this.logger.error('Unable to subscribe to highlight blocks room');
throw new Error('Unable to join highlight blocks room');
}
} catch (e) {

View File

@ -413,6 +413,7 @@ export class WebsocketGateway
async handleHighlightBlock(
payload: IHookOperationMap['highlight']['operations']['block'],
) {
this.logger.log('highlighting block', payload);
this.io.to(`blocks:${payload.userId}`).emit('highlight:block', payload);
}
@ -420,7 +421,7 @@ export class WebsocketGateway
async highlightBlockErrored(
payload: IHookOperationMap['highlight']['operations']['error'],
) {
this.logger.warn('hook:highlight:error ', payload);
this.logger.warn('hook:highlight:error', payload);
this.io.to(`blocks:${payload.userId}`).emit('highlight:error', payload);
}
}

View File

@ -41,10 +41,7 @@ export const SocketProvider = (props: PropsWithChildren) => {
const [connected, setConnected] = useState(false);
const { toast } = useToast();
const { user } = useAuth();
const socket = useMemo(
() => new SocketIoClient(apiUrl, { auth: user }),
[apiUrl],
);
const socket = useMemo(() => new SocketIoClient(apiUrl), [apiUrl]);
useEffect(() => {
if (user && apiUrl)