Compare commits

..

No commits in common. "4090afc9d809544eebc9a04ed312fe9ed5a70d8c" and "cb440efb35d127aac5e8993963760cc5a74fc743" have entirely different histories.

8 changed files with 19 additions and 47 deletions

1
.gitignore vendored
View File

@ -1,7 +1,6 @@
.DS_Store .DS_Store
node_modules node_modules
/dist /dist
package-lock.json
# local env files # local env files

Binary file not shown.

Before

Width:  |  Height:  |  Size: 128 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

BIN
src/assets/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

View File

@ -3,7 +3,7 @@
<form v-on:submit.prevent="sendMessage()"> <form v-on:submit.prevent="sendMessage()">
<label for="newMessageInput"></label> <label for="newMessageInput"></label>
<textarea @keyup.enter.exact="sendMessage()" @input="resizeMessageBanner()" ref="newMessageInput" id="newMessageInput" class="newMessageInput" <textarea @keyup.enter.exact="sendMessage()" @input="resizeMessageBanner()" ref="newMessageInput" id="newMessageInput" class="newMessageInput"
autocomplete="off" rows="1" placeholder="type a message ..." v-model="msg.content.body" /> autocomplete="off" placeholder="type a message ..." v-model="msg.content.body" />
<icon type="submit" title="press enter to submit" id="sendMessageBtn" <icon type="submit" title="press enter to submit" id="sendMessageBtn"
ic="./sym/ic_send_white_24px.svg" /> ic="./sym/ic_send_white_24px.svg" />
</form> </form>

View File

@ -2,38 +2,36 @@ import matrix from 'matrix-js-sdk';
import main from '@/main.js'; import main from '@/main.js';
// import Vue from 'vue'; // import Vue from 'vue';
let client = matrix.createClient({}); const client = matrix.createClient({
baseUrl: 'https://adb.sh',
accessToken: getCookie('accessToken'),
userId: getCookie('userId'),
});
let session = { let session = {
user: '', user: '',
baseUrl: '', password: '',
accessToken: '', accessToken: '',
rooms: [], rooms: [],
currentRoom: undefined, currentRoom: undefined,
login: { login: {
user: '', user: '',
password: '', password: '',
baseUrl: 'https://adb.sh',
}, },
}; };
console.log(`cookie => ${document.cookie}`); console.log(document.cookie);
if (getCookie('accessToken') && getCookie('userId') && getCookie('baseUrl')) { if (getCookie('accessToken') && getCookie('userId')) {
document.cookie = `expires=${new Date(Date.now() + 86400 * 10 * 1000)}`; document.cookie = `expires=${new Date(Date.now() + 86400 * 10 * 1000)}`;
session = { session = {
user: getCookie('userId'), user: getCookie('userId'),
baseUrl: getCookie('baseUrl'), password: '',
accessToken: getCookie('accessToken'), accessToken: getCookie('accessToken'),
rooms: [], rooms: [],
currentRoom: undefined, currentRoom: undefined,
}; };
// Vue.$router.push("/rooms/") // Vue.$router.push("/rooms/")
window.location.href = '/#/rooms/'; window.location.href = '/#/rooms/';
client = matrix.createClient({
baseUrl: getCookie('baseUrl'),
accessToken: getCookie('accessToken'),
userId: getCookie('userId'),
});
client.startClient(); client.startClient();
client.once('sync', (state) => { client.once('sync', (state) => {
console.log(state); console.log(state);
@ -61,9 +59,6 @@ export default {
main.methods.error('username is in wrong style'); main.methods.error('username is in wrong style');
return; return;
} }
client = matrix.createClient({
baseUrl: session.login.baseUrl
});
client.login('m.login.password', { client.login('m.login.password', {
user: session.login.user, user: session.login.user,
password: session.login.password, password: session.login.password,
@ -71,11 +66,10 @@ export default {
}).then((response) => { }).then((response) => {
document.cookie = `accessToken=${response.access_token}`; document.cookie = `accessToken=${response.access_token}`;
document.cookie = `userId=${session.login.user}`; document.cookie = `userId=${session.login.user}`;
document.cookie = `baseUrl=${session.login.baseUrl}`; document.cookie = `max-expires=${new Date(Date.now() + 86400 * 10 * 1000)}`;
document.cookie = `expires=${new Date(Date.now() + 86400 * 10 * 1000)}`;
session = { session = {
user: session.login.user, user: session.login.user,
baseUrl: session.login.baseUrl, password: '',
accessToken: response.access_token, accessToken: response.access_token,
rooms: [], rooms: [],
currentRoom: undefined, currentRoom: undefined,
@ -86,20 +80,12 @@ export default {
console.log(`login error => ${response.error}`); console.log(`login error => ${response.error}`);
} }
window.location.href = '/#/rooms/'; window.location.href = '/#/rooms/';
window.location.reload(); client.startClient();
/*client.startClient();
client.once('sync', (state) => { client.once('sync', (state) => {
console.log(state); console.log(state);
});*/ });
}); });
}, },
logout(){
document.cookie = `accessToken=`;
document.cookie = `userId=`;
document.cookie = `baseUrl=`;
document.cookie = `expires=${new Date(0)}`;
window.location.reload();
},
sendMessage(msg) { sendMessage(msg) {
const msgSend = { const msgSend = {
type: msg.type, type: msg.type,

View File

@ -63,12 +63,8 @@ export default {
return { return {
chatroom: main.data().chatroom, chatroom: main.data().chatroom,
session: matrix.data().session, session: matrix.data().session,
showScrollBtn: false, showScrollBtn: false
scrollOnUpdate: true
} }
},
updated(){
//this.scrollToBottom();
} }
} }
</script> </script>

View File

@ -1,17 +1,11 @@
<template> <template>
<div id="login"> <div id="login">
<h1 class="title">[chat]</h1> <h1 class="title">[chat]</h1>
<form v-if="session.login" @submit.prevent="login()"> <form @submit.prevent="login()">
<input v-model="session.login.user" class="input" name="user" type="text" maxlength="30" placeholder="@user:adb.sh"><br> <input v-model="session.login.user" class="input" name="user" type="text" maxlength="30" placeholder="@user:adb.sh"><br>
<input v-model="session.login.password" class="input" name="password" type="password" maxlength="30" placeholder="password"><br> <input v-model="session.login.password" class="input" name="password" type="password" maxlength="30" placeholder="password"><br>
<input v-model="session.login.baseUrl" class="input" name="homeserver" maxlength="50" placeholder="https://matrix.org"><br>
<textbtn type="submit" text="login" /> <textbtn type="submit" text="login" />
</form> </form>
<div v-else>
<p>you are already logged in</p>
<textbtn @click.native="$router.push('room')" text="chat" />
<textbtn @click.native="logout()" text="logout" />
</div>
</div> </div>
</template> </template>
@ -26,10 +20,7 @@ export default {
}, },
methods: { methods: {
login(){ login(){
matrix.methods.login(); matrix.methods.login()
},
logout(){
matrix.methods.logout();
} }
}, },
data(){ data(){

View File

@ -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>
@ -44,7 +44,7 @@ export default {
}, },
data(){ data(){
return { return {
session: matrix.data().session session: matrix.data().session,
} }
} }
} }