This commit is contained in:
Dan Ballard 2019-10-28 14:12:05 -07:00
commit 30b8d9ab6d
2 changed files with 13 additions and 1 deletions

View File

@ -184,6 +184,7 @@ func (this *GrandCentralDispatcher) loadMessagesPaneHelper(handle string) {
group := the.Peer.GetGroup(handle) group := the.Peer.GetGroup(handle)
tl := group.GetTimeline() tl := group.GetTimeline()
nick, _ := group.GetAttribute(constants.Nick) nick, _ := group.GetAttribute(constants.Nick)
updateLastReadTime(group)
if nick == "" { if nick == "" {
this.SetToolbarTitle(handle) this.SetToolbarTitle(handle)
} else { } else {
@ -232,6 +233,7 @@ func (this *GrandCentralDispatcher) loadMessagesPaneHelper(handle string) {
nick = handle nick = handle
} }
} }
updateLastReadTime(contact)
this.SetToolbarTitle(nick) this.SetToolbarTitle(nick)
peer := the.Peer.GetContact(handle) peer := the.Peer.GetContact(handle)

View File

@ -33,6 +33,12 @@ func initLastReadTime(attr Attributable) time.Time {
return lastRead 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 { func countUnread(messages []model.Message, lastRead time.Time) int {
count := 0 count := 0
for i := len(messages) - 1; i >= 0; i-- { 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) { 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 we have this group loaded already
if this.parentGcd.CurrentOpenConversation() == m.Handle { if this.parentGcd.CurrentOpenConversation() == m.Handle {