add createRooms from search

dev
adb 4 years ago
parent c57c1d348f
commit 40812fc4a2

@ -10,7 +10,7 @@
<room-list-element <room-list-element
v-for="room in Object.assign([], matrix.client.getRooms()) v-for="room in Object.assign([], matrix.client.getRooms())
.sort(obj => obj.timeline[obj.timeline.length-1].event.origin_server_ts) .sort(obj => obj.timeline[obj.timeline.length-1].event.origin_server_ts)
.filter(prop=>matchResults(prop.name, search))" .filter(prop=>matchResults(prop.name, search)||prop.roomId===search)"
:key="room.roomId" @click.native="openChat(room)" :key="room.roomId" @click.native="openChat(room)"
:room="room" :room="room"
class="roomListElement" class="roomListElement"
@ -22,7 +22,7 @@
.filter(prop=>matchResults(prop.displayName, search)||matchResults(prop.userId, search)) .filter(prop=>matchResults(prop.displayName, search)||matchResults(prop.userId, search))
.slice(0,10)" .slice(0,10)"
:user="user" :key="user.userId" :user="user" :key="user.userId"
@click.native="setQuestion(`create private chat with '${search}'?`,()=>search='cool')" @click.native="setQuestion(`create private chat with '${user.displayName}'?`,()=>createRoom({user}))"
/> />
<p class="wideElement">suggestions </p><p class="smallElement"></p> <p class="wideElement">suggestions </p><p class="smallElement"></p>
<div class="wideElement"> <div class="wideElement">
@ -31,9 +31,8 @@
@click="setQuestion(`join room '${search}'?`, ()=>joinRoom(search))" @click="setQuestion(`join room '${search}'?`, ()=>joinRoom(search))"
>join room: {{search}} </p> >join room: {{search}} </p>
<p v-if="search.match(/^[a-zA-Z0-9_.+-]+$/)" <p v-if="search.match(/^[a-zA-Z0-9_.+-]+$/)"
@click="setQuestion(`create room '${search}'?`,()=>search='cool')" @click="setQuestion(`create room '${search}'?`,()=>createRoom({name: search}))"
>create room: {{search}} </p> >create room: {{search}} </p>
<room-list-element v-if="isValidRoomId(search) && getRoom(search)" :room="getRoom(search)"/>
</div> </div>
</div> </div>
</div> </div>
@ -101,7 +100,14 @@ export default {
}, },
joinRoom(room){ joinRoom(room){
this.matrix.client.join(room).then(()=>{ this.matrix.client.join(room).then(()=>{
this.openChat(room); this.openChat(getRoom(room.room_id));
});
},
async createRoom({name = '', user = undefined}){
return this.matrix.client.createRoom({name}).then(room => {
if (user) this.matrix.client.invite(room.room_id, user.userId);
this.openChat(getRoom(room.room_id));
return room;
}); });
}, },
getMxcFromRoom, getMxcFromRoom,

Loading…
Cancel
Save