Merge remote-tracking branch 'origin/dev'
This commit is contained in:
commit
292b123f5a
@ -34,6 +34,7 @@
|
|||||||
"eslint": "^6.7.2",
|
"eslint": "^6.7.2",
|
||||||
"eslint-plugin-vue": "^7.5.0",
|
"eslint-plugin-vue": "^7.5.0",
|
||||||
"node-sass": "^5.0.0",
|
"node-sass": "^5.0.0",
|
||||||
|
"recorder-js": "*",
|
||||||
"sass-loader": "^10.1.1",
|
"sass-loader": "^10.1.1",
|
||||||
"vue-router": "^3.4.9",
|
"vue-router": "^3.4.9",
|
||||||
"vue-template-compiler": "^2.6.11"
|
"vue-template-compiler": "^2.6.11"
|
||||||
|
1
public/sym/ic_attach_file_white.svg
Normal file
1
public/sym/ic_attach_file_white.svg
Normal file
@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#FFFFFF"><path d="M0 0h24v24H0z" fill="none"/><path d="M16.5 6v11.5c0 2.21-1.79 4-4 4s-4-1.79-4-4V5c0-1.38 1.12-2.5 2.5-2.5s2.5 1.12 2.5 2.5v10.5c0 .55-.45 1-1 1s-1-.45-1-1V6H10v9.5c0 1.38 1.12 2.5 2.5 2.5s2.5-1.12 2.5-2.5V5c0-2.21-1.79-4-4-4S7 2.79 7 5v12.5c0 3.04 2.46 5.5 5.5 5.5s5.5-2.46 5.5-5.5V6h-1.5z"/></svg>
|
After Width: | Height: | Size: 409 B |
1
public/sym/ic_insert_emoticon_white.svg
Normal file
1
public/sym/ic_insert_emoticon_white.svg
Normal file
@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#FFFFFF"><path d="M0 0h24v24H0z" fill="none"/><path d="M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8zm3.5-9c.83 0 1.5-.67 1.5-1.5S16.33 8 15.5 8 14 8.67 14 9.5s.67 1.5 1.5 1.5zm-7 0c.83 0 1.5-.67 1.5-1.5S9.33 8 8.5 8 7 8.67 7 9.5 7.67 11 8.5 11zm3.5 6.5c2.33 0 4.31-1.46 5.11-3.5H6.89c.8 2.04 2.78 3.5 5.11 3.5z"/></svg>
|
After Width: | Height: | Size: 510 B |
1
public/sym/ic_mic_white.svg
Normal file
1
public/sym/ic_mic_white.svg
Normal file
@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#FFFFFF"><path d="M0 0h24v24H0z" fill="none"/><path d="M12 14c1.66 0 2.99-1.34 2.99-3L15 5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3zm5.3-3c0 3-2.54 5.1-5.3 5.1S6.7 14 6.7 11H5c0 3.41 2.72 6.23 6 6.72V21h2v-3.28c3.28-.48 6-3.3 6-6.72h-1.7z"/></svg>
|
After Width: | Height: | Size: 348 B |
@ -2,34 +2,7 @@
|
|||||||
<div class="event">
|
<div class="event">
|
||||||
<div v-if="event.type==='m.room.message'" :class="type==='send'?'messageSend':'messageReceive'" class="message">
|
<div v-if="event.type==='m.room.message'" :class="type==='send'?'messageSend':'messageReceive'" class="message">
|
||||||
<reply-event :event="replyEvent" v-if="replyEvent"/>
|
<reply-event :event="replyEvent" v-if="replyEvent"/>
|
||||||
|
<event-content :content="event.content"/>
|
||||||
<div v-if="event.content.msgtype==='m.text'" v-html="parseMessage(event.content.body)"/>
|
|
||||||
<div v-else-if="event.content.msgtype==='m.notice'" class="notice" v-html="parseMessage(event.content.body)"/>
|
|
||||||
<div v-else-if="event.content.msgtype==='m.image'" class="image">
|
|
||||||
<img :src="getMediaUrl(event.content.url)" :alt="event.content.body"/><br>
|
|
||||||
{{event.content.body}}
|
|
||||||
</div>
|
|
||||||
<div v-else-if="event.content.msgtype==='m.file'" class="file">
|
|
||||||
file: <a :href="getMediaUrl(event.content.url)">
|
|
||||||
{{event.content.filename || getMediaUrl(event.content.url)}}
|
|
||||||
</a><br>{{event.content.body}}
|
|
||||||
</div>
|
|
||||||
<div v-else-if="event.content.msgtype==='m.audio'" class="audio">
|
|
||||||
<audio controls>
|
|
||||||
<source :src="getMediaUrl(event.content.url)" :type="event.content.mimetype">
|
|
||||||
your browser doesn't support audio
|
|
||||||
</audio><br>
|
|
||||||
{{event.content.body}}
|
|
||||||
</div>
|
|
||||||
<div v-else-if="event.content.msgtype==='m.video'" class="video">
|
|
||||||
<video controls>
|
|
||||||
<source :src="getMediaUrl(event.content.url)" :type="event.content.mimetype">
|
|
||||||
your browser doesn't support video
|
|
||||||
</video><br>
|
|
||||||
{{event.content.body}}
|
|
||||||
</div>
|
|
||||||
<div v-else class="italic">unsupported message type {{event.content.msgtype}}</div>
|
|
||||||
|
|
||||||
<div class="time">{{getTime(event.origin_server_ts)}}</div>
|
<div class="time">{{getTime(event.origin_server_ts)}}</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-else class="info">
|
<div v-else class="info">
|
||||||
@ -47,10 +20,11 @@ import {parseMessage} from '@/lib/eventUtils';
|
|||||||
import {getTime} from '@/lib/getTimeStrings';
|
import {getTime} from '@/lib/getTimeStrings';
|
||||||
import {getMediaUrl} from '@/lib/getMxc';
|
import {getMediaUrl} from '@/lib/getMxc';
|
||||||
import ReplyEvent from '@/components/replyEvent';
|
import ReplyEvent from '@/components/replyEvent';
|
||||||
|
import EventContent from '@/components/eventContent';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'message',
|
name: 'message',
|
||||||
components: {ReplyEvent},
|
components: {EventContent, ReplyEvent},
|
||||||
props: {
|
props: {
|
||||||
type: String,
|
type: String,
|
||||||
event: Object,
|
event: Object,
|
||||||
@ -134,32 +108,6 @@ export default {
|
|||||||
.notice{
|
.notice{
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
}
|
}
|
||||||
.image{
|
|
||||||
width: 100%;
|
|
||||||
img{
|
|
||||||
max-width: 100%;
|
|
||||||
height: auto;
|
|
||||||
max-height: 35rem;
|
|
||||||
border-radius: 0.5rem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.video{
|
|
||||||
width: 100%;
|
|
||||||
video{
|
|
||||||
max-width: 100%;
|
|
||||||
height: auto;
|
|
||||||
max-height: 35rem;
|
|
||||||
border-radius: 0.5rem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.audio{
|
|
||||||
audio{
|
|
||||||
max-width: 100%;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.italic{
|
|
||||||
font-style: italic;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
.messageReceive{
|
.messageReceive{
|
||||||
background-color: #424141;
|
background-color: #424141;
|
||||||
|
128
src/components/eventContent.vue
Normal file
128
src/components/eventContent.vue
Normal file
@ -0,0 +1,128 @@
|
|||||||
|
<template>
|
||||||
|
<div v-if="content.msgtype==='m.text'" v-html="parseMessage(content.body)"/>
|
||||||
|
<div v-else-if="content.msgtype==='m.notice'" class="notice" v-html="parseMessage(content.body)"/>
|
||||||
|
<div v-else-if="content.msgtype==='m.image'" class="image">
|
||||||
|
<img :src="getSource(content.url)" :alt="content.body" :class="`${compact?'compact':''}`"/><br>
|
||||||
|
{{content.body}}
|
||||||
|
</div>
|
||||||
|
<div v-else-if="content.msgtype==='m.file'" :class="`file ${compact?'compact':''}`">
|
||||||
|
<a :href="getSource(content.url)" target="_blank">
|
||||||
|
<div class="fileContent">
|
||||||
|
<icon
|
||||||
|
title="file"
|
||||||
|
ic="./sym/ic_attach_file_white.svg"
|
||||||
|
class="download"
|
||||||
|
/>
|
||||||
|
<div class="filename">
|
||||||
|
{{content.filename || getSource(content.url)}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
<div class="text">
|
||||||
|
{{content.body}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-else-if="content.msgtype==='m.audio'" :class="`audio ${compact?'compact':''}`">
|
||||||
|
<audio controls :class="`${compact?'compact':''}`">
|
||||||
|
<source :src="getSource(content.url)" :type="content.mimetype">
|
||||||
|
your browser doesn't support audio
|
||||||
|
</audio><br>
|
||||||
|
{{content.body}}
|
||||||
|
</div>
|
||||||
|
<div v-else-if="content.msgtype==='m.video'" :class="`video ${compact?'compact':''}`">
|
||||||
|
<video controls :class="`${compact?'compact':''}`">
|
||||||
|
<source :src="getSource(content.url)" :type="content.mimetype">
|
||||||
|
your browser doesn't support video
|
||||||
|
</video><br>
|
||||||
|
{{content.body}}
|
||||||
|
</div>
|
||||||
|
<div v-else class="italic">unsupported message type {{content.msgtype}}</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import {getMediaUrl} from '@/lib/getMxc';
|
||||||
|
import {parseMessage} from '@/lib/eventUtils';
|
||||||
|
import Icon from '@/components/icon';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'eventContent',
|
||||||
|
components: {Icon},
|
||||||
|
props: {
|
||||||
|
content: Object,
|
||||||
|
compact: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
getSource(url){
|
||||||
|
return url.includes('mxc')?getMediaUrl(url):url;
|
||||||
|
},
|
||||||
|
parseMessage
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.file{
|
||||||
|
max-width: 30rem;
|
||||||
|
.fileContent{
|
||||||
|
position: relative;
|
||||||
|
background-color: #1d1d1d;
|
||||||
|
padding: 0.5rem;
|
||||||
|
border-radius: 0.5rem;
|
||||||
|
min-height: 3rem;
|
||||||
|
.filename{
|
||||||
|
display: inline-block;
|
||||||
|
position: relative;
|
||||||
|
margin-left: 4rem;
|
||||||
|
top: 0;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
.download{
|
||||||
|
position: absolute;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.compact{
|
||||||
|
max-width: 20rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.image{
|
||||||
|
width: 100%;
|
||||||
|
img{
|
||||||
|
max-width: 100%;
|
||||||
|
height: auto;
|
||||||
|
max-height: 35rem;
|
||||||
|
border-radius: 0.5rem;
|
||||||
|
}
|
||||||
|
.compact{
|
||||||
|
max-width: 8rem;
|
||||||
|
max-height: 8rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.video{
|
||||||
|
width: 100%;
|
||||||
|
video{
|
||||||
|
max-width: 100%;
|
||||||
|
height: auto;
|
||||||
|
max-height: 35rem;
|
||||||
|
border-radius: 0.5rem;
|
||||||
|
}
|
||||||
|
.compact{
|
||||||
|
max-width: 8rem;
|
||||||
|
max-height: 8rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.audio{
|
||||||
|
audio{
|
||||||
|
max-width: 100%;
|
||||||
|
}
|
||||||
|
.compact{
|
||||||
|
max-width: 16rem;
|
||||||
|
max-height: 8rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.italic{
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
</style>
|
62
src/components/fileUpload.vue
Normal file
62
src/components/fileUpload.vue
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
<template>
|
||||||
|
<div class="fileUpload">
|
||||||
|
<icon
|
||||||
|
title="upload media"
|
||||||
|
class="leftBtn attachFile"
|
||||||
|
ic="./sym/ic_attach_file_white.svg"
|
||||||
|
@click.native="$refs.fileInput.click()"
|
||||||
|
/>
|
||||||
|
<input
|
||||||
|
type="file" id="fileInput" ref="fileInput"
|
||||||
|
@change="setFile({file: $refs.fileInput.files[0]})"
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import icon from '@/components/icon';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'soundRecorder',
|
||||||
|
components: {
|
||||||
|
icon
|
||||||
|
},
|
||||||
|
props:{
|
||||||
|
onChange: Function
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
setFile({file}){
|
||||||
|
this.readFile(file).then(blob => {
|
||||||
|
blob.name = file.name;
|
||||||
|
this.onChange({blob})
|
||||||
|
});
|
||||||
|
},
|
||||||
|
readFile(file){
|
||||||
|
return new Promise(resolve => {
|
||||||
|
let reader = new FileReader();
|
||||||
|
reader.onerror = console.error;
|
||||||
|
reader.onload = async event => {
|
||||||
|
resolve(await (await fetch(event.target.result)).blob());
|
||||||
|
}
|
||||||
|
reader.readAsDataURL(file);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.fileUpload{
|
||||||
|
display: inline-block;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
.leftBtn{
|
||||||
|
background-color: unset;
|
||||||
|
height: 2.5rem;
|
||||||
|
width: 2.5rem;
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
|
#fileInput{
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
</style>
|
@ -1,21 +1,47 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="newMessageBanner" ref="newMessageBanner">
|
<div class="newMessageBanner" ref="newMessageBanner">
|
||||||
<reply-event v-if="replyTo" :event="replyTo" @click.native="resetReplyTo()"/>
|
<reply-event v-if="replyTo" :event="replyTo" @click.native="resetReplyTo()"/>
|
||||||
<form v-on:submit.prevent="sendMessage()">
|
<div v-if="attachment" class="attachment">
|
||||||
|
<event-content :content="attachment" class="attachmentContent" :compact="true"/>
|
||||||
|
<icon
|
||||||
|
title="remove"
|
||||||
|
class="remove"
|
||||||
|
ic="./sym/ic_close_white.svg"
|
||||||
|
@click.native="resetAttachment()"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
<textarea
|
<textarea
|
||||||
@keyup.enter.exact="sendMessage()"
|
@keyup.enter.exact="onSubmit(event)"
|
||||||
@input="resizeMessageBanner(); sendTyping(2000);"
|
@input="resizeMessageBanner(); sendTyping(2000);"
|
||||||
v-model="event.content.body"
|
v-model="event.content.body"
|
||||||
ref="newMessageInput" class="newMessageInput"
|
ref="newMessageInput" class="newMessageInput"
|
||||||
rows="1" placeholder="type a message ..."
|
rows="1" placeholder="type a message ..."
|
||||||
/>
|
/>
|
||||||
<icon
|
<icon
|
||||||
|
v-if="event.content.body && !getRecordingState() || attachment"
|
||||||
type="submit"
|
type="submit"
|
||||||
title="press enter to submit"
|
title="press enter to submit"
|
||||||
class="sendMessageBtn"
|
class="sendMessageBtn"
|
||||||
ic="./sym/ic_send_white.svg"
|
ic="./sym/ic_send_white.svg"
|
||||||
|
@click.native="onSubmit(event)"
|
||||||
|
/>
|
||||||
|
<sound-recorder v-else class="recorder" :on-stop="setAttachment" ref="recorder"/>
|
||||||
|
<div class="mediaButtons">
|
||||||
|
<icon
|
||||||
|
title="toggle emoji"
|
||||||
|
class="leftBtn emojiToggle"
|
||||||
|
ic="./sym/ic_insert_emoticon_white.svg"
|
||||||
|
@click.native="toggleEmojiPicker()"
|
||||||
|
/>
|
||||||
|
<fileUpload class="leftBtn" :on-change="setAttachment"/>
|
||||||
|
</div>
|
||||||
|
<v-emoji-picker
|
||||||
|
v-if="showEmojiPicker"
|
||||||
|
class="emojiPicker"
|
||||||
|
@select="onSelectEmoji"
|
||||||
|
:dark="true"
|
||||||
|
:continuousList="true"
|
||||||
/>
|
/>
|
||||||
</form>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -25,12 +51,20 @@ import {matrix} from '@/main.js';
|
|||||||
import {parseMessage} from '@/lib/eventUtils';
|
import {parseMessage} from '@/lib/eventUtils';
|
||||||
import {calcUserName} from '@/lib/matrixUtils';
|
import {calcUserName} from '@/lib/matrixUtils';
|
||||||
import ReplyEvent from '@/components/replyEvent';
|
import ReplyEvent from '@/components/replyEvent';
|
||||||
|
import {VEmojiPicker} from 'v-emoji-picker';
|
||||||
|
import EventContent from '@/components/eventContent';
|
||||||
|
import SoundRecorder from '@/components/soundRecorder';
|
||||||
|
import FileUpload from '@/components/fileUpload';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'newMessage',
|
name: 'newMessage',
|
||||||
components: {
|
components: {
|
||||||
|
FileUpload,
|
||||||
|
SoundRecorder,
|
||||||
|
EventContent,
|
||||||
ReplyEvent,
|
ReplyEvent,
|
||||||
icon
|
icon,
|
||||||
|
VEmojiPicker
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
onResize: Function,
|
onResize: Function,
|
||||||
@ -39,21 +73,37 @@ export default {
|
|||||||
resetReplyTo: Function
|
resetReplyTo: Function
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
sendMessage(){
|
onSubmit(event){
|
||||||
let content = this.event.content;
|
console.log(event)
|
||||||
if (!content.body.trim()) return;
|
event.content.msgtype==='m.text'?this.sendEvent(event):this.sendMediaEvent(event);
|
||||||
matrix.sendEvent(this.event, this.roomId, this.replyTo);
|
},
|
||||||
content.body = '';
|
async sendEvent(event){
|
||||||
|
if (!event.content.body.trim()) return;
|
||||||
|
if (this.replyTo) this.setReplyTo(this.replyTo);
|
||||||
|
matrix.sendEvent(new Proxy(this.event, this.eventProxyHandler), this.roomId);
|
||||||
|
event.content.body = '';
|
||||||
|
this.resetAttachment();
|
||||||
this.resetReplyTo();
|
this.resetReplyTo();
|
||||||
let id = this.$refs.newMessageInput;
|
let id = this.$refs.newMessageInput;
|
||||||
id.style.height = '1.25rem';
|
id.style.height = '1.25rem';
|
||||||
this.onResize(id.parentElement.clientHeight);
|
this.onResize(id.parentElement.clientHeight);
|
||||||
},
|
},
|
||||||
|
sendMediaEvent(event){
|
||||||
|
matrix.client.uploadContent(this.attachment.blob).then(mxc => {
|
||||||
|
event.content.url = mxc;
|
||||||
|
this.sendEvent(event);
|
||||||
|
});
|
||||||
|
},
|
||||||
sendTyping(timeout){
|
sendTyping(timeout){
|
||||||
if (this.waitForSendTyping) return;
|
if (this.waitForSendTyping) return;
|
||||||
matrix.client.sendTyping(this.roomId, true, timeout+100);
|
matrix.client.sendTyping(this.roomId, true, timeout+100);
|
||||||
setTimeout(()=>this.waitForSendTyping=false, timeout);
|
setTimeout(()=>this.waitForSendTyping=false, timeout);
|
||||||
},
|
},
|
||||||
|
setReplyTo(event){
|
||||||
|
this.event.content['m.relates_to'] = {
|
||||||
|
'm.in_reply_to': event
|
||||||
|
}
|
||||||
|
},
|
||||||
resizeMessageBanner(){
|
resizeMessageBanner(){
|
||||||
let id = this.$refs.newMessageInput;
|
let id = this.$refs.newMessageInput;
|
||||||
id.style.height = '1.25rem';
|
id.style.height = '1.25rem';
|
||||||
@ -69,6 +119,41 @@ export default {
|
|||||||
onSelectEmoji(emoji) {
|
onSelectEmoji(emoji) {
|
||||||
this.event.content.body += emoji.data;
|
this.event.content.body += emoji.data;
|
||||||
},
|
},
|
||||||
|
getRecordingState(){
|
||||||
|
return this.$refs.recorder && this.$refs.recorder.isRecording
|
||||||
|
},
|
||||||
|
async setAttachment({blob, file = blob}){
|
||||||
|
this.attachment = {
|
||||||
|
msgtype: this.getMsgType(file.type),
|
||||||
|
mimetype: file.type,
|
||||||
|
url: window.URL.createObjectURL(file),
|
||||||
|
filename: file.name,
|
||||||
|
blob,
|
||||||
|
file
|
||||||
|
};
|
||||||
|
this.event.content = {
|
||||||
|
body: file.name,
|
||||||
|
msgtype: this.attachment.msgtype,
|
||||||
|
mimetype: this.attachment.mimetype,
|
||||||
|
filename: file.name
|
||||||
|
};
|
||||||
|
},
|
||||||
|
resetAttachment(){
|
||||||
|
if (!this.attachment) return;
|
||||||
|
window.URL.revokeObjectURL(this.attachment.file);
|
||||||
|
this.event.content = {
|
||||||
|
body: this.attachment?this.event.content.body.replace(this.attachment.filename, ''):'',
|
||||||
|
msgtype: 'm.text'
|
||||||
|
};
|
||||||
|
this.attachment = undefined;
|
||||||
|
},
|
||||||
|
getMsgType(fileType){
|
||||||
|
return {
|
||||||
|
'image': 'm.image',
|
||||||
|
'audio': 'm.audio',
|
||||||
|
'video': 'm.video'
|
||||||
|
}[fileType.split('/', 1)[0]] || 'm.file';
|
||||||
|
},
|
||||||
parseMessage,
|
parseMessage,
|
||||||
calcUserName
|
calcUserName
|
||||||
},
|
},
|
||||||
@ -80,20 +165,29 @@ export default {
|
|||||||
body: '',
|
body: '',
|
||||||
msgtype: 'm.text',
|
msgtype: 'm.text',
|
||||||
'm.relates_to': {
|
'm.relates_to': {
|
||||||
'm.in_reply_to': {
|
'm.in_reply_to': undefined
|
||||||
event_id: undefined
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
showEmojiPicker: false,
|
showEmojiPicker: false,
|
||||||
waitForSendTyping: false
|
waitForSendTyping: false,
|
||||||
|
attachment: undefined,
|
||||||
|
eventProxyHandler: {
|
||||||
|
set: () => true,
|
||||||
|
get: (target, key) => {
|
||||||
|
if (typeof target[key] === 'object') return new Proxy(Object.assign({}, target[key]), this.eventProxyHandler);
|
||||||
|
return target[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
updated() {
|
||||||
|
this.resizeMessageBanner();
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped lang="scss">
|
||||||
.newMessageBanner{
|
.newMessageBanner{
|
||||||
position: absolute;
|
position: absolute;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
@ -109,10 +203,10 @@ export default {
|
|||||||
margin-top: 1.25rem;
|
margin-top: 1.25rem;
|
||||||
margin-bottom: 0.75rem;
|
margin-bottom: 0.75rem;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
left: 1rem;
|
left: 5.5rem;
|
||||||
min-height: 1.5rem;
|
min-height: 1.5rem;
|
||||||
max-height: 10rem;
|
max-height: 10rem;
|
||||||
width: calc(100% - 7rem);
|
width: calc(100% - 10rem);
|
||||||
height: 1.25rem;
|
height: 1.25rem;
|
||||||
background-color: #fff0;
|
background-color: #fff0;
|
||||||
border: 0 solid #fff0;
|
border: 0 solid #fff0;
|
||||||
@ -144,4 +238,59 @@ export default {
|
|||||||
.username{
|
.username{
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
.emojiPicker{
|
||||||
|
position: absolute;
|
||||||
|
bottom: calc(100% + 0.25rem);
|
||||||
|
left: 0.25rem;
|
||||||
|
z-index: 10;
|
||||||
|
max-width: calc(100% - 0.5rem - 2px);
|
||||||
|
}
|
||||||
|
.mediaButtons{
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
bottom: 0;
|
||||||
|
height: fit-content;
|
||||||
|
width: fit-content;
|
||||||
|
}
|
||||||
|
.leftBtn{
|
||||||
|
position: relative;
|
||||||
|
left: 0.25rem;
|
||||||
|
bottom: 0.5rem;
|
||||||
|
background-color: unset;
|
||||||
|
height: 2.5rem;
|
||||||
|
width: 2.5rem;
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
|
.recorder{
|
||||||
|
position: absolute;
|
||||||
|
height: 100%;
|
||||||
|
bottom: 0;
|
||||||
|
right: 0;
|
||||||
|
border-radius: 0 1rem 0 0;
|
||||||
|
}
|
||||||
|
.attachment{
|
||||||
|
top: 0.5rem;
|
||||||
|
left: 0.5rem;
|
||||||
|
position: relative;
|
||||||
|
width: fit-content;
|
||||||
|
height: fit-content;
|
||||||
|
.attachmentContent{
|
||||||
|
position: relative;
|
||||||
|
width: fit-content;
|
||||||
|
}
|
||||||
|
.remove{
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
right: -3rem;
|
||||||
|
background-color: unset;
|
||||||
|
height: 2.5rem;
|
||||||
|
width: 2.5rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
img{
|
||||||
|
max-width: 10rem;
|
||||||
|
height: auto;
|
||||||
|
max-height: 4rem;
|
||||||
|
border-radius: 0.5rem;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
34
src/components/popupQuestion.vue
Normal file
34
src/components/popupQuestion.vue
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<template>
|
||||||
|
<div class="questionBox">
|
||||||
|
<p class="text">{{question}}</p>
|
||||||
|
<textbtn text="yes" @click.native="callback(true)"/>
|
||||||
|
<textbtn text="no" @click.native="callback(false)"/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import textbtn from '@/components/textbtn';
|
||||||
|
export default {
|
||||||
|
name: 'popupQuestion',
|
||||||
|
components: {textbtn},
|
||||||
|
props:{
|
||||||
|
question: String,
|
||||||
|
callback: Function
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.questionBox{
|
||||||
|
position: absolute;
|
||||||
|
width: auto;
|
||||||
|
background-color: #1d1d1d;
|
||||||
|
box-shadow: 6px 6px 10px #111;
|
||||||
|
border-radius: 1.5rem;
|
||||||
|
.text{
|
||||||
|
position: relative;
|
||||||
|
width: 100%;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
@ -14,13 +14,13 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import avatar from "@/components/avatar";
|
import avatar from '@/components/avatar';
|
||||||
import {getMxcFromRoom} from "@/lib/getMxc";
|
import {getMxcFromRoom} from '@/lib/getMxc';
|
||||||
import {getTime} from "@/lib/getTimeStrings";
|
import {getTime} from '@/lib/getTimeStrings';
|
||||||
import {calcUserName} from "@/lib/matrixUtils";
|
import {calcUserName} from '@/lib/matrixUtils';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "userListElement",
|
name: 'roomListElement',
|
||||||
components:{
|
components:{
|
||||||
avatar
|
avatar
|
||||||
},
|
},
|
||||||
@ -34,8 +34,8 @@ export default {
|
|||||||
return `${this.calcUserName(event.sender)}: ${event.content.body||'unknown event'} ${getTime(event.origin_server_ts)}`;
|
return `${this.calcUserName(event.sender)}: ${event.content.body||'unknown event'} ${getTime(event.origin_server_ts)}`;
|
||||||
},
|
},
|
||||||
getLatestEvent(room){
|
getLatestEvent(room){
|
||||||
if (!room.timeline[room.timeline.length-1]) return undefined;
|
return room.timeline[room.timeline.length-1]
|
||||||
return room.timeline[room.timeline.length-1].event;
|
&& room.timeline[room.timeline.length-1].event;
|
||||||
},
|
},
|
||||||
calcUserName,
|
calcUserName,
|
||||||
getMxcFromRoom
|
getMxcFromRoom
|
||||||
|
114
src/components/soundRecorder.vue
Normal file
114
src/components/soundRecorder.vue
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
<template>
|
||||||
|
<div class="recorder">
|
||||||
|
<icon
|
||||||
|
v-if="!isRecording"
|
||||||
|
title="record voice"
|
||||||
|
class="recordBtn start"
|
||||||
|
ic="./sym/ic_mic_white.svg"
|
||||||
|
@click.native="startRecording()"
|
||||||
|
ref="startRecord"
|
||||||
|
/>
|
||||||
|
<div v-else class="voiceMeterContainer">
|
||||||
|
<div class="voiceMeter" ref="voiceMeter"></div>
|
||||||
|
<icon
|
||||||
|
title="record voice"
|
||||||
|
class="recordBtn stop"
|
||||||
|
ic="./sym/ic_mic_white.svg"
|
||||||
|
@click.native="stopRecording()"
|
||||||
|
ref="stopRecord"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import icon from '@/components/icon';
|
||||||
|
import Recorder from 'recorder-js';
|
||||||
|
const audioContext = new (window.AudioContext || window.webkitAudioContext)();
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'soundRecorder',
|
||||||
|
components: {
|
||||||
|
icon
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
onStart: {
|
||||||
|
type: Function,
|
||||||
|
default: ()=>{}
|
||||||
|
},
|
||||||
|
onStop: {
|
||||||
|
type: Function,
|
||||||
|
default: ()=>{}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
startRecording(){
|
||||||
|
this.onStart();
|
||||||
|
navigator.mediaDevices.getUserMedia({audio: true})
|
||||||
|
.then(stream => {
|
||||||
|
this.recorder.init(stream);
|
||||||
|
this.recorder.start().then(()=>this.isRecording=true);
|
||||||
|
})
|
||||||
|
.catch(err => console.log('unable to get stream', err));
|
||||||
|
},
|
||||||
|
stopRecording(){
|
||||||
|
this.recorder.stop()
|
||||||
|
.then(({blob}) => {
|
||||||
|
blob.name = `Recording-${new Date().toISOString()}.${blob.type.split('/')[1]}`;
|
||||||
|
this.onStop({blob});
|
||||||
|
this.isRecording=false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
setVoiceMeter(value){
|
||||||
|
if (!this.$refs.stopRecord) return;
|
||||||
|
this.$refs.voiceMeter.style.height = `calc(3rem + ${value/4}px`;
|
||||||
|
this.$refs.voiceMeter.style.width = `calc(3rem + ${value/4}px`;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
data(){
|
||||||
|
return{
|
||||||
|
recorder: new Recorder(audioContext, {
|
||||||
|
onAnalysed: data => this.setVoiceMeter(data.lineTo)
|
||||||
|
}),
|
||||||
|
isRecording: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.recordBtn{
|
||||||
|
position: absolute;
|
||||||
|
right: 1rem;
|
||||||
|
bottom: 0.25rem;
|
||||||
|
background-color: #1d1d1d;
|
||||||
|
border-radius: 50%;
|
||||||
|
}
|
||||||
|
.recordBtn.stop{
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
background-color: #c63e3e;
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
|
.voiceMeter{
|
||||||
|
position: absolute;
|
||||||
|
background-color: #fff;
|
||||||
|
top: 50%;
|
||||||
|
left: 50%;
|
||||||
|
transform: translate(-50%,-50%);
|
||||||
|
border-radius: 50%;
|
||||||
|
box-shadow: 3px 3px 10px #111;
|
||||||
|
}
|
||||||
|
.voiceMeterContainer{
|
||||||
|
position: absolute;
|
||||||
|
height: 3rem;
|
||||||
|
width: 3rem;
|
||||||
|
bottom: 0.25rem;
|
||||||
|
right: 1rem;
|
||||||
|
}
|
||||||
|
.recorder{
|
||||||
|
height: 100%;
|
||||||
|
width: 8rem;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
</style>
|
@ -15,10 +15,10 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import avatar from "@/components/avatar";
|
import avatar from '@/components/avatar';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "userListElement",
|
name: 'userListElement',
|
||||||
components:{
|
components:{
|
||||||
avatar
|
avatar
|
||||||
},
|
},
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import {getMxcFromUserId, getAvatarUrl} from '@/lib/getMxc';
|
import {getMxcFromUserId, getPreviewUrl} from '@/lib/getMxc';
|
||||||
import {calcUserName} from '@/lib/matrixUtils';
|
import {calcUserName} from '@/lib/matrixUtils';
|
||||||
import {getRoom} from '@/lib/matrixUtils';
|
import {getRoom} from '@/lib/matrixUtils';
|
||||||
import {router} from '@/router';
|
import {router} from '@/router';
|
||||||
@ -22,7 +22,7 @@ export class NotificationHandler{
|
|||||||
let mxc = getMxcFromUserId(event.sender);
|
let mxc = getMxcFromUserId(event.sender);
|
||||||
new Notification(`${calcUserName(event.sender)} in ${getRoom(event.room_id).name}`, {
|
new Notification(`${calcUserName(event.sender)} in ${getRoom(event.room_id).name}`, {
|
||||||
body: event.content.body,
|
body: event.content.body,
|
||||||
icon: mxc?getAvatarUrl(mxc):undefined
|
icon: mxc?getPreviewUrl(mxc):undefined
|
||||||
}).onclick = ()=>router.push(`/rooms/${event.room_id}`);
|
}).onclick = ()=>router.push(`/rooms/${event.room_id}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,6 +1,5 @@
|
|||||||
import sdk from 'matrix-js-sdk'
|
import sdk from 'matrix-js-sdk'
|
||||||
import {matrix} from '@/main';
|
import {matrix} from '@/main';
|
||||||
import parseMXC from '@modular-matrix/parse-mxc';
|
|
||||||
|
|
||||||
export function getMxcFromUser(user){
|
export function getMxcFromUser(user){
|
||||||
return user.avatarUrl;
|
return user.avatarUrl;
|
||||||
@ -20,14 +19,9 @@ export function getMxcFromRoomId(roomId){
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getPreviewUrl(mxcUrl, size = 64, resizeMethod = 'crop'){
|
export function getPreviewUrl(mxcUrl, size = 64, resizeMethod = 'crop'){
|
||||||
let mxc = parseMXC.parse(mxcUrl);
|
return matrix.client.mxcUrlToHttp(mxcUrl, size, size, resizeMethod);
|
||||||
return `${matrix.baseUrl}/_matrix/media/v1/thumbnail/${
|
|
||||||
mxc.homeserver}/${mxc.id}?width=${size}&height=${size}&method=${resizeMethod}`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getMediaUrl(mxcUrl){
|
export function getMediaUrl(mxcUrl){
|
||||||
if (!mxcUrl) return undefined;
|
return matrix.client.mxcUrlToHttp(mxcUrl);
|
||||||
let mxc = parseMXC.parse(mxcUrl);
|
|
||||||
return `${matrix.baseUrl}/_matrix/media/r0/download/${
|
|
||||||
mxc.homeserver}/${mxc.id}`;
|
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
import matrix from 'matrix-js-sdk';
|
import matrix from 'matrix-js-sdk';
|
||||||
import {NotificationHandler} from "@/lib/NotificationHandler";
|
import {NotificationHandler} from '@/lib/NotificationHandler';
|
||||||
|
|
||||||
export class MatrixHandler {
|
export class MatrixHandler {
|
||||||
constructor(clientDisplayName = 'matrix-chat') {
|
constructor(clientDisplayName = 'matrix-chat') {
|
||||||
@ -67,7 +67,7 @@ export class MatrixHandler {
|
|||||||
this.rooms = this.client.getRooms();
|
this.rooms = this.client.getRooms();
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
callback();
|
callback();
|
||||||
this.listenToPushEvents()
|
this.listenToPushEvents();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
listenToPushEvents(){
|
listenToPushEvents(){
|
||||||
@ -77,17 +77,9 @@ export class MatrixHandler {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
async sendEvent({content, type}, roomId, replyTo = undefined){
|
async sendEvent({content, type}, roomId){
|
||||||
await this.client.sendEvent(roomId, type, {
|
return await this.client.sendEvent(roomId, type, content)
|
||||||
body: content.body.trim(),
|
.then(() => console.log('message sent successfully'))
|
||||||
msgtype: content.msgtype,
|
.catch((err) => console.log(`error while sending message => ${err}`));
|
||||||
'm.relates_to': {
|
|
||||||
'm.in_reply_to': {
|
|
||||||
event_id: replyTo?replyTo.event_id:undefined
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}).then(() => console.log('message sent successfully'))
|
|
||||||
.catch((err) => console.log(`error while sending message => ${err}`)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -10,3 +10,9 @@ export function calcUserName(userId){
|
|||||||
export function getRoom(roomId){
|
export function getRoom(roomId){
|
||||||
return matrix.client.getRoom(roomId);
|
return matrix.client.getRoom(roomId);
|
||||||
}
|
}
|
||||||
|
export function isValidUserId(id){
|
||||||
|
return id.match(/^@[a-zA-Z0-9_.+-]+:[a-z0-9.-]+\.[a-z]+$/);
|
||||||
|
}
|
||||||
|
export function isValidRoomId(id){
|
||||||
|
return id.match(/^(#|!)[a-zA-Z0-9_.+-]+:[a-z0-9.-]+\.[a-z]+$/);
|
||||||
|
}
|
@ -22,11 +22,12 @@
|
|||||||
<script>
|
<script>
|
||||||
import textbtn from '@/components/textbtn';
|
import textbtn from '@/components/textbtn';
|
||||||
import {matrix} from '@/main.js';
|
import {matrix} from '@/main.js';
|
||||||
import {cookieHandler} from "@/lib/cookieHandler";
|
import {cookieHandler} from '@/lib/cookieHandler';
|
||||||
import ThrobberOverlay from "@/components/throbberOverlay";
|
import ThrobberOverlay from '@/components/throbberOverlay';
|
||||||
|
import {isValidUserId} from '@/lib/matrixUtils';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "login.vue",
|
name: 'login.vue',
|
||||||
components: {
|
components: {
|
||||||
ThrobberOverlay,
|
ThrobberOverlay,
|
||||||
textbtn
|
textbtn
|
||||||
@ -42,7 +43,7 @@ export default {
|
|||||||
} if (this.password === '') {
|
} if (this.password === '') {
|
||||||
this.loginError = 'password is empty';
|
this.loginError = 'password is empty';
|
||||||
return;
|
return;
|
||||||
} if (!(this.user.match(/^@[a-zA-Z0-9_.+-]+:[a-z0-9.-]+\.[a-z]+$/))) {
|
} if (!isValidUserId(this.user)) {
|
||||||
this.loginError = 'username is in wrong style';
|
this.loginError = 'username is in wrong style';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -83,10 +84,10 @@ export default {
|
|||||||
},
|
},
|
||||||
data(){
|
data(){
|
||||||
return {
|
return {
|
||||||
user: "",
|
user: '',
|
||||||
password: "",
|
password: '',
|
||||||
homeServer: "https://adb.sh",
|
homeServer: 'https://adb.sh',
|
||||||
loginError: "",
|
loginError: '',
|
||||||
cookie: new cookieHandler(),
|
cookie: new cookieHandler(),
|
||||||
loading: false
|
loading: false
|
||||||
}
|
}
|
||||||
|
@ -6,16 +6,34 @@
|
|||||||
<div id="roomList" class="roomList">
|
<div id="roomList" class="roomList">
|
||||||
<h1 class="wideElement">[chat]</h1><h1 class="smallElement">[c]</h1>
|
<h1 class="wideElement">[chat]</h1><h1 class="smallElement">[c]</h1>
|
||||||
<input v-model="search" class="input wideElement" type="text" maxlength="50" placeholder="search">
|
<input v-model="search" class="input wideElement" type="text" maxlength="50" placeholder="search">
|
||||||
<div
|
<p class="wideElement">rooms ↴</p>
|
||||||
v-for="room in Object.assign([], matrix.rooms)
|
|
||||||
.sort(obj => obj.timeline[obj.timeline.length-1].event.origin_server_ts)"
|
|
||||||
:key="room.roomId" @click="openChat(room)"
|
|
||||||
>
|
|
||||||
<room-list-element
|
<room-list-element
|
||||||
v-if="!search || room.name.toLowerCase().includes(search.toLowerCase().trim())"
|
v-for="room in Object.assign([], matrix.client.getRooms())
|
||||||
|
.sort(obj => obj.timeline[obj.timeline.length-1].event.origin_server_ts)
|
||||||
|
.filter(prop=>matchResults(prop.name, search)||prop.roomId===search)"
|
||||||
|
:key="room.roomId" @click.native="openChat(room)"
|
||||||
:room="room"
|
:room="room"
|
||||||
class="roomListElement"
|
class="roomListElement"
|
||||||
/>
|
/>
|
||||||
|
<div v-if="search">
|
||||||
|
<p class="wideElement">users ↴</p><p class="smallElement">—</p>
|
||||||
|
<user-list-element
|
||||||
|
v-for="user in matrix.client.getUsers()
|
||||||
|
.filter(prop=>matchResults(prop.displayName, search)||matchResults(prop.userId, search))
|
||||||
|
.slice(0,10)"
|
||||||
|
:user="user" :key="user.userId"
|
||||||
|
@click.native="setQuestion(`create private chat with '${user.displayName}'?`,()=>createRoom({user}))"
|
||||||
|
/>
|
||||||
|
<p class="wideElement">suggestions ↴</p><p class="smallElement">…</p>
|
||||||
|
<div class="wideElement">
|
||||||
|
<p v-if="isValidUserId(search)">create chat: {{search}} ➤</p>
|
||||||
|
<p v-if="isValidRoomId(search)"
|
||||||
|
@click="setQuestion(`join room '${search}'?`, ()=>joinRoom(search))"
|
||||||
|
>join room: {{search}} ➤</p>
|
||||||
|
<p v-if="search.match(/^[a-zA-Z0-9_.+-]+$/)"
|
||||||
|
@click="setQuestion(`create room '${search}'?`,()=>createRoom({name: search}))"
|
||||||
|
>create room: {{search}} ➤</p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<chat
|
<chat
|
||||||
@ -28,21 +46,27 @@
|
|||||||
/>
|
/>
|
||||||
<div class="noRoomSelected" v-else>Please select a room to be displayed.</div>
|
<div class="noRoomSelected" v-else>Please select a room to be displayed.</div>
|
||||||
<chatInformation v-if="showRoom && showChatInfo" :room="getCurrentRoom()" :close-chat-info="()=>showChatInfo=false"/>
|
<chatInformation v-if="showRoom && showChatInfo" :room="getCurrentRoom()" :close-chat-info="()=>showChatInfo=false"/>
|
||||||
|
<popup-question v-if="popup.question" :callback="popup.callback" :question="popup.question" class="center"/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import chat from '@/views/chat.vue';
|
import chat from '@/views/chat.vue';
|
||||||
import chatInformation from "@/components/chatInformation";
|
import chatInformation from '@/components/chatInformation';
|
||||||
import {matrix} from "@/main";
|
import {matrix} from '@/main';
|
||||||
import ThrobberOverlay from "@/components/throbberOverlay";
|
import ThrobberOverlay from '@/components/throbberOverlay';
|
||||||
import {getMxcFromRoom} from "@/lib/getMxc";
|
import {getMxcFromRoom} from '@/lib/getMxc';
|
||||||
import roomListElement from "@/components/roomListElement";
|
import roomListElement from '@/components/roomListElement';
|
||||||
import {getRoom} from "@/lib/matrixUtils";
|
import {getRoom, getUser} from '@/lib/matrixUtils';
|
||||||
|
import {isValidUserId, isValidRoomId} from '@/lib/matrixUtils';
|
||||||
|
import userListElement from '@/components/userListElement';
|
||||||
|
import PopupQuestion from '@/components/popupQuestion';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "rooms",
|
name: 'rooms',
|
||||||
components:{
|
components:{
|
||||||
|
PopupQuestion,
|
||||||
|
userListElement,
|
||||||
ThrobberOverlay,
|
ThrobberOverlay,
|
||||||
chat,
|
chat,
|
||||||
chatInformation,
|
chatInformation,
|
||||||
@ -56,21 +80,52 @@ export default {
|
|||||||
this.$nextTick(() => this.showRoom = true);
|
this.$nextTick(() => this.showRoom = true);
|
||||||
this.search = '';
|
this.search = '';
|
||||||
},
|
},
|
||||||
getMxcFromRoom,
|
|
||||||
getRoom,
|
|
||||||
getCurrentRoom(){
|
getCurrentRoom(){
|
||||||
return getRoom(this.$route.path.split('/')[2]);
|
return getRoom(this.$route.path.split('/')[2]);
|
||||||
},
|
},
|
||||||
closeChat(){
|
closeChat(){
|
||||||
this.$router.push('/rooms');
|
this.$router.push('/rooms');
|
||||||
|
},
|
||||||
|
matchResults(prop, search){
|
||||||
|
return prop.toLowerCase().includes(search.toLowerCase().trim());
|
||||||
|
},
|
||||||
|
setQuestion(question, callback){
|
||||||
|
this.popup = {
|
||||||
|
question,
|
||||||
|
callback:(res)=>{
|
||||||
|
this.popup = false;
|
||||||
|
if (res) callback();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
joinRoom(room){
|
||||||
|
this.matrix.client.join(room).then(()=>{
|
||||||
|
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,
|
||||||
|
getRoom,
|
||||||
|
getUser,
|
||||||
|
isValidUserId,
|
||||||
|
isValidRoomId
|
||||||
},
|
},
|
||||||
data(){
|
data(){
|
||||||
return {
|
return {
|
||||||
matrix,
|
matrix,
|
||||||
showChatInfo: false,
|
showChatInfo: false,
|
||||||
showRoom: true,
|
showRoom: true,
|
||||||
search: ''
|
search: '',
|
||||||
|
popup:{
|
||||||
|
question: '',
|
||||||
|
callback: ()=>{}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
@ -89,6 +144,8 @@ export default {
|
|||||||
background-color: #222;
|
background-color: #222;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
|
overflow-x: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
}
|
}
|
||||||
.chat{
|
.chat{
|
||||||
position: absolute;
|
position: absolute;
|
||||||
@ -122,6 +179,13 @@ input{
|
|||||||
.smallElement{
|
.smallElement{
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
.center{
|
||||||
|
position: fixed;
|
||||||
|
top: 50%;
|
||||||
|
left: 50%;
|
||||||
|
transform: translate(-50%,-50%);
|
||||||
|
z-index: 50;
|
||||||
|
}
|
||||||
|
|
||||||
@media (max-width: 48rem) and (min-width: 30rem) {
|
@media (max-width: 48rem) and (min-width: 30rem) {
|
||||||
.wideElement{
|
.wideElement{
|
||||||
@ -134,7 +198,6 @@ input{
|
|||||||
z-index: 30;
|
z-index: 30;
|
||||||
width: 4rem;
|
width: 4rem;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
overflow-x: hidden;
|
|
||||||
scrollbar-width: none;
|
scrollbar-width: none;
|
||||||
}
|
}
|
||||||
.roomList:hover{
|
.roomList:hover{
|
||||||
|
Loading…
Reference in New Issue
Block a user