fix: own comments trigger NEW
This commit is contained in:
30
tui.go
30
tui.go
@@ -1638,6 +1638,8 @@ func (m *App) trackThreadUpdates(details PRDetails) {
|
||||
state := m.readState.Data[prID]
|
||||
if state.Threads == nil {
|
||||
state.Threads = make(map[string]bool)
|
||||
}
|
||||
if state.Comments == nil {
|
||||
state.Comments = make(map[string]bool)
|
||||
}
|
||||
if !state.Initialized {
|
||||
@@ -1654,25 +1656,47 @@ func (m *App) trackThreadUpdates(details PRDetails) {
|
||||
}
|
||||
return
|
||||
}
|
||||
readStateChanged := false
|
||||
for _, thread := range details.Threads {
|
||||
threadIsNew := !state.Threads[thread.ID]
|
||||
updated := threadIsNew
|
||||
if threadIsNew {
|
||||
m.newThreads[thread.ID] = true
|
||||
}
|
||||
viewerAuthoredOnly := len(thread.Comments) > 0
|
||||
for _, comment := range thread.Comments {
|
||||
viewerAuthored := details.ViewerLogin != "" &&
|
||||
strings.EqualFold(comment.Author, details.ViewerLogin)
|
||||
if viewerAuthored {
|
||||
if !state.Comments[comment.ID] {
|
||||
state.Comments[comment.ID] = true
|
||||
readStateChanged = true
|
||||
}
|
||||
} else {
|
||||
viewerAuthoredOnly = false
|
||||
}
|
||||
if !state.Comments[comment.ID] {
|
||||
updated = true
|
||||
m.unreadComments[comment.ID] = true
|
||||
}
|
||||
m.knownComments[comment.ID] = true
|
||||
}
|
||||
if threadIsNew && !viewerAuthoredOnly {
|
||||
m.newThreads[thread.ID] = true
|
||||
} else if threadIsNew {
|
||||
state.Threads[thread.ID] = true
|
||||
readStateChanged = true
|
||||
updated = false
|
||||
}
|
||||
m.knownThreads[thread.ID] = true
|
||||
if updated {
|
||||
m.unreadThreads[thread.ID] = true
|
||||
m.updatedThreads[thread.ID] = true
|
||||
}
|
||||
}
|
||||
if readStateChanged {
|
||||
m.readState.Data[prID] = state
|
||||
if err := m.readState.save(); err != nil {
|
||||
m.recordHealth("read state", healthWarning, err.Error())
|
||||
}
|
||||
}
|
||||
m.initializedPRs[prID] = true
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user