add matrixUtils
This commit is contained in:
parent
a67fa94447
commit
f1967d4189
@ -28,7 +28,7 @@ input{
|
|||||||
color: #fff;
|
color: #fff;
|
||||||
background-color: #1d1d1d;
|
background-color: #1d1d1d;
|
||||||
border-radius: 1.25rem;
|
border-radius: 1.25rem;
|
||||||
border: 1px solid #fff;
|
border: 0.1rem solid #fff;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
font-size: 1.1rem;
|
font-size: 1.1rem;
|
||||||
margin: 0.5rem;
|
margin: 0.5rem;
|
||||||
|
@ -23,10 +23,10 @@
|
|||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import icon from './icon.vue';
|
import icon from './icon.vue';
|
||||||
import {matrix} from "@/main";
|
|
||||||
import UserListElement from "@/components/userListElement";
|
import UserListElement from "@/components/userListElement";
|
||||||
import avatar from "@/components/avatar";
|
import avatar from "@/components/avatar";
|
||||||
import {getMxcFromRoom} from "@/lib/getMxc";
|
import {getMxcFromRoom} from "@/lib/getMxc";
|
||||||
|
import {getUser} from "@/lib/matrixUtils";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "chatInformation",
|
name: "chatInformation",
|
||||||
@ -40,12 +40,10 @@ export default {
|
|||||||
closeChatInfo: Function
|
closeChatInfo: Function
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getUser(userId){
|
|
||||||
return matrix.client.getUser(userId);
|
|
||||||
},
|
|
||||||
getMembers(){
|
getMembers(){
|
||||||
return Object.keys(this.room.currentState.members)
|
return Object.keys(this.room.currentState.members)
|
||||||
},
|
},
|
||||||
|
getUser,
|
||||||
getMxcFromRoom
|
getMxcFromRoom
|
||||||
},
|
},
|
||||||
data(){
|
data(){
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<div :class="type==='send'?'messageSend':'messageReceive'" class="message">
|
<div :class="type==='send'?'messageSend':'messageReceive'" class="message">
|
||||||
<div v-if="replyEvent" class="reply">
|
<div v-if="replyEvent" class="reply">
|
||||||
{{replyEvent.sender}}<br>
|
<span class="username">{{calcUserName(replyEvent.sender)}}</span><br>
|
||||||
{{replyEvent.type==='m.room.message'?replyEvent.content.body:'unkown event'}}
|
<span v-html="replyEvent.type==='m.room.message'?parseMessage(replyEvent.content.body):'unkown event'"></span>
|
||||||
</div>
|
</div>
|
||||||
<div v-html="parseMessage(msg)"></div>
|
<div v-html="parseMessage(msg)"></div>
|
||||||
<div class="time">{{time}}</div>
|
<div class="time">{{time}}</div>
|
||||||
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {matrix} from "@/main";
|
import {matrix} from "@/main";
|
||||||
|
import {calcUserName} from "@/lib/matrixUtils";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "message",
|
name: "message",
|
||||||
@ -51,7 +52,8 @@ export default {
|
|||||||
.replace(/</g, '<')
|
.replace(/</g, '<')
|
||||||
.replace(/>/g, '>')
|
.replace(/>/g, '>')
|
||||||
);
|
);
|
||||||
}
|
},
|
||||||
|
calcUserName
|
||||||
},
|
},
|
||||||
data(){
|
data(){
|
||||||
return{
|
return{
|
||||||
@ -99,4 +101,7 @@ export default {
|
|||||||
padding-left: 0.5rem;
|
padding-left: 0.5rem;
|
||||||
margin-bottom: 0.5rem;
|
margin-bottom: 0.5rem;
|
||||||
}
|
}
|
||||||
|
.username{
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
@ -17,7 +17,7 @@
|
|||||||
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 {matrix} from "@/main";
|
import {calcUserName} from "@/lib/matrixUtils";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "userListElement",
|
name: "userListElement",
|
||||||
@ -37,10 +37,7 @@ export default {
|
|||||||
if (!room.timeline[room.timeline.length-1]) return undefined;
|
if (!room.timeline[room.timeline.length-1]) return undefined;
|
||||||
return room.timeline[room.timeline.length-1].event;
|
return room.timeline[room.timeline.length-1].event;
|
||||||
},
|
},
|
||||||
calcUserName(userId) {
|
calcUserName,
|
||||||
if (matrix.user === userId) return 'you';
|
|
||||||
return matrix.client.getUser(userId).displayName || userId;
|
|
||||||
},
|
|
||||||
getMxcFromRoom
|
getMxcFromRoom
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
:class="groupTimeline?'indent username':'username'"
|
:class="groupTimeline?'indent username':'username'"
|
||||||
v-if="group[0].sender !== user && groupTimeline"
|
v-if="group[0].sender !== user && groupTimeline"
|
||||||
>
|
>
|
||||||
{{getUser(group[0].sender).displayName || group[0].sender}}
|
{{calcUserName(group[0].sender)}}
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
:class="groupTimeline?'indent event':'event'"
|
:class="groupTimeline?'indent event':'event'"
|
||||||
@ -37,6 +37,10 @@
|
|||||||
:content="event.content"
|
:content="event.content"
|
||||||
:roomId="roomId"
|
:roomId="roomId"
|
||||||
/>
|
/>
|
||||||
|
<div v-else-if="event.content.msgtype==='m.notice'" class="notice">
|
||||||
|
{{event.content.body}}
|
||||||
|
<span class="time">{{getTime(event.origin_server_ts)}}</span>
|
||||||
|
</div>
|
||||||
<div v-else-if="event.type==='m.room.member'" class="info">
|
<div v-else-if="event.type==='m.room.member'" class="info">
|
||||||
{{membershipEvents[event.content.membership]}}
|
{{membershipEvents[event.content.membership]}}
|
||||||
<span class="time">{{getTime(event.origin_server_ts)}}</span>
|
<span class="time">{{getTime(event.origin_server_ts)}}</span>
|
||||||
@ -52,9 +56,10 @@
|
|||||||
<script>
|
<script>
|
||||||
import message from "@/components/message";
|
import message from "@/components/message";
|
||||||
import avatar from "@/components/avatar";
|
import avatar from "@/components/avatar";
|
||||||
import {matrix} from "@/main";
|
|
||||||
import splitArray from "@/lib/splitArray";
|
import splitArray from "@/lib/splitArray";
|
||||||
import {getDate, getTime} from "@/lib/getTimeStrings";
|
import {getDate, getTime} from "@/lib/getTimeStrings";
|
||||||
|
import {getUser, calcUserName} from "@/lib/matrixUtils";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'eventGroup',
|
name: 'eventGroup',
|
||||||
components: {
|
components: {
|
||||||
@ -68,9 +73,8 @@ export default {
|
|||||||
roomId: String
|
roomId: String
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getUser(userId) {
|
getUser,
|
||||||
return matrix.client.getUser(userId);
|
calcUserName,
|
||||||
},
|
|
||||||
splitArray,
|
splitArray,
|
||||||
getDate,
|
getDate,
|
||||||
getTime
|
getTime
|
||||||
@ -132,11 +136,18 @@ export default {
|
|||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
.event{
|
.event{
|
||||||
.info{
|
.info {
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
margin-top: 0.5rem;
|
margin-top: 0.5rem;
|
||||||
margin-bottom: 0.5rem;
|
margin-bottom: 0.5rem;
|
||||||
margin-left: 0.5rem;
|
margin-left: 0.5rem;
|
||||||
|
.time {
|
||||||
|
font-size: 0.7rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.notice{
|
||||||
|
margin-top: 0.5rem;
|
||||||
|
margin-bottom: 0.5rem;
|
||||||
.time{
|
.time{
|
||||||
font-size: 0.7rem;
|
font-size: 0.7rem;
|
||||||
}
|
}
|
||||||
|
9
src/lib/matrixUtils.js
Normal file
9
src/lib/matrixUtils.js
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import {matrix} from '@/main';
|
||||||
|
|
||||||
|
export function getUser(userId) {
|
||||||
|
return matrix.client.getUser(userId);
|
||||||
|
}
|
||||||
|
export function calcUserName(userId){
|
||||||
|
if (matrix.user === userId) return 'you';
|
||||||
|
return matrix.client.getUser(userId).displayName || userId;
|
||||||
|
}
|
@ -106,7 +106,7 @@ export default {
|
|||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
input{
|
input{
|
||||||
width: calc(100% - 5rem);
|
width: calc(100% - 5.2rem);
|
||||||
}
|
}
|
||||||
.wideElement{
|
.wideElement{
|
||||||
display: block;
|
display: block;
|
||||||
|
Loading…
Reference in New Issue
Block a user