Commit 0e228dad authored by 우지원's avatar 우지원
Browse files

채널퇴장 오류해결

parent 5eb8bad9
...@@ -24,7 +24,7 @@ const ChannelSingle = (props) => { ...@@ -24,7 +24,7 @@ const ChannelSingle = (props) => {
if (A) { if (A) {
await roomApi.doubleJoin({ roomId: roomId, index1: A.index1, index2: A.index2, joinChName: A.joinChName }) await roomApi.doubleJoin({ roomId: roomId, index1: A.index1, index2: A.index2, joinChName: A.joinChName })
} }
const roomA = await roomApi.joinChannel({ roomId: roomId, channelName: e, plusUser: data.name, index: index1 }) await roomApi.joinChannel({ roomId: roomId, channelName: e, plusUser: data.name, index: index1 })
setRoomName(e) setRoomName(e)
setSuccess(true) setSuccess(true)
} else { } else {
...@@ -69,35 +69,33 @@ const ChannelSingle = (props) => { ...@@ -69,35 +69,33 @@ const ChannelSingle = (props) => {
<div className="overflow-auto" style={{ height: '610px' }}> <div className="overflow-auto" style={{ height: '610px' }}>
{props.channel.map((el,i) => ( {props.channel.map((el,i) => (
<div className="mb-3" key={`channel${i}`}> <div className="mb-3" key={`channel${i}`}>
<Link to={`/room/${roomId}/${el.channelName}`}> <div
<div className="m-3 p-1 row"
className="m-3 p-1 row" style={{ backgroundColor: '#E0CEE8' }}
style={{ backgroundColor: '#E0CEE8' }} onClick={() => joinChannel(el.channelName)}
onClick={() => joinChannel(el.channelName)} >
> {el.channelName === channelId ? (
{el.channelName === channelId ? ( <img
<img className="col-auto mt-2"
className="col-auto mt-2" src="/fullSpeaker.png"
src="/fullSpeaker.png" width="25px"
width="25px" height="25px"
height="25px" />
/> ) : (
) : ( <img
<img className="col-auto mt-2"
className="col-auto mt-2" src="/emptySpeaker.png"
src="/emptySpeaker.png" width="25px"
width="25px" height="25px"
height="25px" />
/> )}
)} <h5 className="col mt-2" style={{ color: 'black' }}>
<h5 className="col mt-2" style={{ color: 'black' }}> {el.channelName}
{el.channelName} </h5>
</h5> </div>
</div>
</Link>
{el.joinName && {el.joinUser &&
el.joinName.map((e,i) => ( el.joinUser.map((e,i) => (
<div key={`member${i}`}> <div key={`member${i}`}>
<ul className="mx-5" style={{ color: '#76D079' }}> <ul className="mx-5" style={{ color: '#76D079' }}>
<li> <li>
......
...@@ -17,7 +17,7 @@ const Roomnamechange = () => { ...@@ -17,7 +17,7 @@ const Roomnamechange = () => {
async function getdata(Roomdata) { async function getdata(Roomdata) {
try { try {
const data = await RoomApi.getRoom(Roomdata); const data = await RoomApi.getRoom([Roomdata]);
setRoom(data); setRoom(data);
console.log(data); console.log(data);
} catch (error) { } catch (error) {
......
...@@ -140,24 +140,16 @@ const changename = async (req, res) => { ...@@ -140,24 +140,16 @@ const changename = async (req, res) => {
const joinChannel = async (req, res) => { const joinChannel = async (req, res) => {
const { roomId, channelName, plusUser, index } = req.body; const { roomId, channelName, plusUser, index } = req.body;
console.log("연결성공");
const room = await Room.findOne({ where: { id: roomId } }); const room = await Room.findOne({ where: { id: roomId } });
room.channel[index][channelName].push(plusUser); room.channel[index][channelName].push(plusUser);
console.log("확인2", room.channel[index]);
console.log("확인2", room.channel);
await Room.update({ channel: room.channel }, { where: { id: roomId } }); await Room.update({ channel: room.channel }, { where: { id: roomId } });
return res.json(true); return res.json(true);
}; };
const doubleJoin = async (req, res) => { const doubleJoin = async (req, res) => {
console.log("연결성공", req.body);
const { roomId, index1, index2, joinChName } = req.body; const { roomId, index1, index2, joinChName } = req.body;
console.log(index1);
const room = await Room.findOne({ where: { id: roomId } }); const room = await Room.findOne({ where: { id: roomId } });
console.log(room.channel[index1][joinChName]);
room.channel[index1][joinChName].splice(index2, 1); room.channel[index1][joinChName].splice(index2, 1);
console.log(room.channel[index1][joinChName]);
console.log("room.channel", room.channel);
await Room.update({ channel: room.channel }, { where: { id: roomId } }); await Room.update({ channel: room.channel }, { where: { id: roomId } });
return res.json(true); return res.json(true);
}; };
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment