diff --git a/client/messagestorage.go b/client/messagestorage.go index 7b5f800..710bc45 100644 --- a/client/messagestorage.go +++ b/client/messagestorage.go @@ -123,8 +123,8 @@ func GetNewMessages(peer *Peer, lastDbId int, password string) ([]*InternalUserM } // Get old messages from a peer -func GetMessagesHistory(peer *Peer, inAppMsgCount int, lastDbId int, wantMore int, password string) ([]*InternalUserMessage, error) { - var messages []*InternalUserMessage +func GetMessagesHistory(peer *Peer, inAppMsgCount int, lastDbId int, wantMore int, password string) ([]InternalUserMessage, error) { + var messages []InternalUserMessage fileidx := len(peer.DbIds) - 1 // initialize count with last db message count countStack, err := getMessageCount(peer.DbIds[fileidx]) @@ -162,7 +162,7 @@ func GetMessagesHistory(peer *Peer, inAppMsgCount int, lastDbId int, wantMore in defer rows.Close() for rows.Next() { - var ium InternalUserMessage + var ium *InternalUserMessage var um meowlib.UserMessage var id int64 var m []byte @@ -182,7 +182,7 @@ func GetMessagesHistory(peer *Peer, inAppMsgCount int, lastDbId int, wantMore in ium = InternalUserMessageFromUserMessage(peer, &um) ium.Dbid = id ium.Dbfile = peer.DbIds[fileidx] - messages = append(messages, ium) + messages = append(messages, *ium) } // TODO DB overlap return messages, nil diff --git a/client/peer.go b/client/peer.go index 68ae76b..1412470 100644 --- a/client/peer.go +++ b/client/peer.go @@ -288,7 +288,7 @@ func (p *Peer) UpdateMessage(msg InternalUserMessage) error { return nil } -func (p *Peer) LoadLastMessages(alreadyLoadedCount int, oldestMessageId int, qty int) ([]*InternalUserMessage, error) { +func (p *Peer) LoadLastMessages(alreadyLoadedCount int, oldestMessageId int, qty int) ([]InternalUserMessage, error) { return GetMessagesHistory(p, alreadyLoadedCount, oldestMessageId, 1, p.GetDbPassword()) }