Skip to content
This repository has been archived by the owner on May 26, 2019. It is now read-only.

Commit

Permalink
Enabled message history on client side
Browse files Browse the repository at this point in the history
  • Loading branch information
SniperGER committed Mar 10, 2019
1 parent 45e000e commit 111d0db
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
9 changes: 9 additions & 0 deletions metroui-vue/index.js
Expand Up @@ -1639,6 +1639,15 @@ var Messages = {
setTimeout(() => {
this.$refs["scrollContainer"].scrollTo(0, this.$refs["scrollContainer"].scrollHeight);
});
},
/**
*
*/
setMessages(messageData) {
this.$data.messages = [];
messageData.forEach(messageObj => {
this.addMessage(messageObj);
});
}
}
};
Expand Down
15 changes: 13 additions & 2 deletions src/components/NeoChannelPage.vue
Expand Up @@ -164,6 +164,17 @@ export default {
break;
case PackageType.EnterChannelResponse:
if (packageObj.content.result === "Success") {
let messages = packageObj.content.channel.messages.map(messageObj => {
return {
author: messageObj.identity.id,
displayName: messageObj.identity.name,
date: new Date(messageObj.timestamp),
text: messageObj.message,
type: this.currentIdentity.id === messageObj.identity.id ? "sent" : "received"
}
});
this.$refs["messageContainer"].setMessages(messages);
this.$store.commit("setCurrentChannel", packageObj.content.channel);
this.$refs["channelView"].setTitle(this.currentChannel.name);
} else {
Expand Down Expand Up @@ -229,8 +240,8 @@ export default {
content: (() => {
return (
<div>
<input type="text" placeholder="Name des Channels" data-required />
<input type="text" placeholder="Id des Channels" data-minlength="3" />
<input type="text" placeholder="Channel-Name" data-required />
<input type="text" placeholder="Channel-ID (min. 3 Zeichen)" data-minlength="3" />
<input type="text" placeholder="Benutzerlimit (-1 für unbegrenzt)" data-required />
<input type="password" placeholder="Passwort (optional)" />
<p>Wähle die Art des Channels:</p>
Expand Down

0 comments on commit 111d0db

Please sign in to comment.