diff --git a/go/gothings/gcd.go b/go/gothings/gcd.go index 22802c1d..0caf4499 100644 --- a/go/gothings/gcd.go +++ b/go/gothings/gcd.go @@ -184,6 +184,7 @@ func (this *GrandCentralDispatcher) loadMessagesPaneHelper(handle string) { group := the.Peer.GetGroup(handle) tl := group.GetTimeline() nick, _ := group.GetAttribute(constants.Nick) + updateLastReadTime(group) if nick == "" { this.SetToolbarTitle(handle) } else { @@ -232,6 +233,7 @@ func (this *GrandCentralDispatcher) loadMessagesPaneHelper(handle string) { nick = handle } } + updateLastReadTime(contact) this.SetToolbarTitle(nick) peer := the.Peer.GetContact(handle) diff --git a/go/gothings/uistate.go b/go/gothings/uistate.go index 2bac7a83..14dae73d 100644 --- a/go/gothings/uistate.go +++ b/go/gothings/uistate.go @@ -33,6 +33,12 @@ func initLastReadTime(attr Attributable) time.Time { return lastRead } +func updateLastReadTime(attr Attributable) { + lastRead := time.Now() + lastReadVal, _ := lastRead.MarshalText() + attr.SetAttribute(constants.LastRead, string(lastReadVal)) +} + func countUnread(messages []model.Message, lastRead time.Time) int { count := 0 for i := len(messages) - 1; i >= 0; i-- { @@ -159,7 +165,11 @@ func (this *InterfaceState) AddSendMessageError(peer string, signature string, e } func (this *InterfaceState) AddMessage(m *gobjects.Message) { - this.GetContact(m.From) + if len(m.Handle) == 32 { // GROUP + updateLastReadTime(the.Peer.GetGroup(m.Handle)) + } else { + updateLastReadTime(the.Peer.GetContact(m.Handle)) + } // If we have this group loaded already if this.parentGcd.CurrentOpenConversation() == m.Handle {