Skip to content

Commit 0f15a17

Browse files
refactor: call channelRoom() instead of hardcoding channel name string (#6)
Related: #5
1 parent 2a32486 commit 0f15a17

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

server/src/channel/create.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ajv, logger, userRoom } from "../util.js";
1+
import { ajv, logger, userRoom, channelRoom } from "../util.js";
22

33
const validate = ajv.compile({
44
type: "object",
@@ -41,7 +41,7 @@ export function createChannel({ io, socket, db }) {
4141
// broadcast to other tabs of the same user
4242
socket.to(userRoom(socket.userId)).emit("channel:created", channel);
4343

44-
io.in(userRoom(socket.userId)).socketsJoin(`channel:${channel.id}`);
44+
io.in(userRoom(socket.userId)).socketsJoin(channelRoom(channel.id));
4545

4646
callback({
4747
status: "OK",

server/src/channel/join.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ajv, logger, userRoom } from "../util.js";
1+
import { ajv, logger, userRoom, channelRoom } from "../util.js";
22

33
const validate = ajv.compile({
44
type: "object",
@@ -37,7 +37,7 @@ export function joinChannel({ io, socket, db }) {
3737
// broadcast to the other tabs of the same user
3838
socket.to(userRoom(socket.userId)).emit("channel:joined", channel);
3939

40-
io.in(userRoom(socket.userId)).socketsJoin(`channel:${channel.id}`);
40+
io.in(userRoom(socket.userId)).socketsJoin(channelRoom(channel.id));
4141

4242
callback({
4343
status: "OK",

server/src/user/reach.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ajv, logger, userRoom } from "../util.js";
1+
import { ajv, logger, userRoom, channelRoom } from "../util.js";
22

33
const validate = ajv.compile({
44
type: "object",
@@ -46,7 +46,7 @@ export function reachUser({ io, socket, db }) {
4646
// broadcast to other tabs of the same user
4747
socket.to(userRoom(socket.userId)).emit("channel:created", channel);
4848

49-
io.in(userRoom(socket.userId)).socketsJoin(`channel:${channel.id}`);
49+
io.in(userRoom(socket.userId)).socketsJoin(channelRoom(channel.id));
5050

5151
callback({
5252
status: "OK",

0 commit comments

Comments
 (0)