some fixes

dev
adb 4 years ago
parent 1d50bae135
commit 286bc25446

@ -14,13 +14,13 @@
</template>
<script>
import avatar from "@/components/avatar";
import {getMxcFromRoom} from "@/lib/getMxc";
import {getTime} from "@/lib/getTimeStrings";
import {calcUserName} from "@/lib/matrixUtils";
import avatar from '@/components/avatar';
import {getMxcFromRoom} from '@/lib/getMxc';
import {getTime} from '@/lib/getTimeStrings';
import {calcUserName} from '@/lib/matrixUtils';
export default {
name: "userListElement",
name: 'roomListElement',
components:{
avatar
},
@ -34,8 +34,8 @@ export default {
return `${this.calcUserName(event.sender)}: ${event.content.body||'unknown event'} ${getTime(event.origin_server_ts)}`;
},
getLatestEvent(room){
if (!room.timeline[room.timeline.length-1]) return undefined;
return room.timeline[room.timeline.length-1].event;
return room.timeline[room.timeline.length-1]
&& room.timeline[room.timeline.length-1].event;
},
calcUserName,
getMxcFromRoom

@ -15,10 +15,10 @@
</template>
<script>
import avatar from "@/components/avatar";
import avatar from '@/components/avatar';
export default {
name: "userListElement",
name: 'userListElement',
components:{
avatar
},

@ -1,6 +1,5 @@
import sdk from 'matrix-js-sdk'
import {matrix} from '@/main';
import parseMXC from '@modular-matrix/parse-mxc';
export function getMxcFromUser(user){
return user.avatarUrl;
@ -20,14 +19,9 @@ export function getMxcFromRoomId(roomId){
}
export function getPreviewUrl(mxcUrl, size = 64, resizeMethod = 'crop'){
let mxc = parseMXC.parse(mxcUrl);
return `${matrix.baseUrl}/_matrix/media/v1/thumbnail/${
mxc.homeserver}/${mxc.id}?width=${size}&height=${size}&method=${resizeMethod}`;
return matrix.client.mxcUrlToHttp(mxcUrl, size, size, resizeMethod);
}
export function getMediaUrl(mxcUrl){
if (!mxcUrl) return undefined;
let mxc = parseMXC.parse(mxcUrl);
return `${matrix.baseUrl}/_matrix/media/r0/download/${
mxc.homeserver}/${mxc.id}`;
return matrix.client.mxcUrlToHttp(mxcUrl);
}

@ -67,7 +67,7 @@ export class MatrixHandler {
this.rooms = this.client.getRooms();
this.loading = false;
callback();
this.listenToPushEvents()
this.listenToPushEvents();
});
}
listenToPushEvents(){

@ -9,4 +9,10 @@ export function calcUserName(userId){
}
export function 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>
import textbtn from '@/components/textbtn';
import {matrix} from '@/main.js';
import {cookieHandler} from "@/lib/cookieHandler";
import ThrobberOverlay from "@/components/throbberOverlay";
import {cookieHandler} from '@/lib/cookieHandler';
import ThrobberOverlay from '@/components/throbberOverlay';
import {isValidUserId} from '@/lib/matrixUtils';
export default {
name: "login.vue",
name: 'login.vue',
components: {
ThrobberOverlay,
textbtn
@ -42,7 +43,7 @@ export default {
} if (this.password === '') {
this.loginError = 'password is empty';
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';
return;
}
@ -83,10 +84,10 @@ export default {
},
data(){
return {
user: "",
password: "",
homeServer: "https://adb.sh",
loginError: "",
user: '',
password: '',
homeServer: 'https://adb.sh',
loginError: '',
cookie: new cookieHandler(),
loading: false
}

Loading…
Cancel
Save