mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
fix: minor enhancement
This commit is contained in:
parent
8790b6fab8
commit
b2c4335526
@ -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) {
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user