update_chat
adb 4 years ago
parent 4090afc9d8
commit b8ca871e09

@ -125,8 +125,8 @@ function getCookie(key) {
} }
client.on('event', (event) => { client.on('event', (event) => {
console.log(event.getType()); //console.log(event.getType());
console.log(event); //console.log(event);
if (event.getType() === 'm.room.name') { if (event.getType() === 'm.room.name') {
client.getRooms().forEach((newRoom) => { client.getRooms().forEach((newRoom) => {
const room = session.rooms.find((room) => room.roomId === newRoom.roomId); const room = session.rooms.find((room) => room.roomId === newRoom.roomId);
@ -136,7 +136,7 @@ client.on('event', (event) => {
}); });
console.log(`new room => ${newRoom.name}`); console.log(`new room => ${newRoom.name}`);
} else if (room.name !== newRoom.name) { } else if (room.name !== newRoom.name) {
console.log(`roomname changed from ${room.name} to ${newRoom.name}`); //console.log(`roomname changed from ${room.name} to ${newRoom.name}`);
room.name = newRoom.name; room.name = newRoom.name;
} }
}); });
@ -146,17 +146,16 @@ client.on('event', (event) => {
session.rooms.push({ session.rooms.push({
name: 'undefined', roomId: event.event.room_id, messages: [], members: [], name: 'undefined', roomId: event.event.room_id, messages: [], members: [],
}); });
console.log(`new user => ${event.event.sender}`); //console.log(`new user => ${event.event.sender}`);
} else { } else {
room.members.push({ sender: event.event.sender, content: event.event.content }); room.members.push({ sender: event.event.sender, content: event.event.content });
} }
} }
console.log(session);
}); });
client.on('Room.timeline', (event, room) => { client.on('Room.timeline', (event, room) => {
if (event.getType() === 'm.room.message') { if (event.getType() === 'm.room.message') {
console.log(`message => ${event.event.content.body}`); //console.log(`message => ${event.event.content.body}`);
const thisRoom = session.rooms.find((thisRoom) => thisRoom.roomId === room.roomId); const thisRoom = session.rooms.find((thisRoom) => thisRoom.roomId === room.roomId);
if (!thisRoom) { if (!thisRoom) {
session.rooms.push({ session.rooms.push({
@ -177,8 +176,3 @@ client.on('Room.timeline', (event, room) => {
} }
} }
}); });
client.on('Room.member', (member) => {
console.log('this is a member');
console.log(member);
});

@ -1,7 +1,7 @@
<template> <template>
<div> <div>
<div id="roomList" class="roomList"> <div id="roomList" class="roomList">
<h1>[chat]{{scrollOnUpdate}}</h1> <h1>[chat]</h1>
<h2>{{session.rooms.length}} rooms:</h2> <h2>{{session.rooms.length}} rooms:</h2>
<div v-for="room in session.rooms" :key="room.roomId" @click="openChat(room)" class="roomListElement"> <div v-for="room in session.rooms" :key="room.roomId" @click="openChat(room)" class="roomListElement">
<div class="roomImgPlaceholder">{{room.name.substr(0,2)}}</div> <div class="roomImgPlaceholder">{{room.name.substr(0,2)}}</div>

Loading…
Cancel
Save