Skip to content

Commit

Permalink
fix show first sent message
Browse files Browse the repository at this point in the history
  • Loading branch information
nanu-c committed Sep 30, 2019
1 parent 58665ae commit a263184
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
6 changes: 4 additions & 2 deletions app/webserver/webserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,9 @@ func wsReader(conn *websocket.Conn) {
createChatMessage := CreateChatMessage{}
json.Unmarshal([]byte(p), &createChatMessage)
log.Println("Create chat for ", createChatMessage.Tel)
sess := createChat(createChatMessage.Tel)
sendMessageList(conn, sess.Tel)
createChat(createChatMessage.Tel)
activeChat = createChatMessage.Tel
store.ActiveSessionID = activeChat
} else if incomingMessage.Type == "leaveChat" {
activeChat = ""
store.ActiveSessionID = ""
Expand Down Expand Up @@ -415,6 +416,7 @@ func sendMessageList(client *websocket.Conn, id string) {
fmt.Println(err)
return
}
log.Debugln(messageList)
messageList.Session.MarkRead()
chatListEnvelope := &MessageListEnvelope{
MessageList: messageList,
Expand Down
2 changes: 1 addition & 1 deletion axolotl-web/src/pages/DeviceList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<template>
<div class="deviceList">
<div v-if="devices.length>1" class="row">
<div v-for="device in devices" v-if="device.id!=1" v-bind:key="device.id"
<div v-for="device in devices" v-if="device.id!=1" v-bind:key="device.id"
class="col-12 device row">
<div class="col-10">
{{device.name}} <br/>
Expand Down
2 changes: 2 additions & 0 deletions axolotl-web/src/pages/MessageList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ export default {
if(this.messageInput!=""){
this.$store.dispatch("sendMessage", {to:this.chatId, message:this.messageInput});
this.messageInput=""
if(this.$store.state.messageList.Messages==null)
this.$store.dispatch("getMessageList", this.getId());
document.getElementById("messageInput").style.height="auto";
}
Expand Down
10 changes: 3 additions & 7 deletions axolotl-web/src/store/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ export default new Vuex.Store({
SOCKET_ONCLOSE (state) {
state.socket.isConnected = false
},
SOCKET_ONERROR (state, event) {
console.error(state, event)
SOCKET_ONERROR () {
// console.error(state, event)
},
// default handler called for all methods
SOCKET_ONMESSAGE (state, message) {
Expand Down Expand Up @@ -146,14 +146,12 @@ export default new Vuex.Store({

},
// mutations for reconnect methods
SOCKET_RECONNECT(state, count) {
console.info(state, count)
SOCKET_RECONNECT() {
},
SOCKET_RECONNECT_ERROR(state) {
state.socket.reconnectError = true;
},
SET_CONFIG_GUI(state) {
console.log("set gui as ut");
state.gui = "ut";
}
},
Expand All @@ -165,7 +163,6 @@ export default new Vuex.Store({
"request":"addDevice",
"url":url,
}
console.log("add device",url);
Vue.prototype.$socket.send(JSON.stringify(message))
}
},
Expand Down Expand Up @@ -237,7 +234,6 @@ export default new Vuex.Store({
this.commit("LEAVE_CHAT");
},
createChat:function(context, tel){
console.log("create chat ", tel);
if(this.state.socket.isConnected){
var message = {
"request":"createChat",
Expand Down

0 comments on commit a263184

Please sign in to comment.