@@ -267,7 +267,7 @@ func (n *Notification) HTMLURL() string {
267267// NotificationList contains a list of notifications
268268type NotificationList []* Notification
269269
270- func (nl NotificationList ) getRepoIDs () []int64 {
270+ func (nl NotificationList ) getPendingRepoIDs () []int64 {
271271 var ids = make (map [int64 ]struct {}, len (nl ))
272272 for _ , notification := range nl {
273273 if notification .Repository != nil {
@@ -286,9 +286,8 @@ func (nl NotificationList) LoadRepos() (RepositoryList, error) {
286286 return RepositoryList {}, nil
287287 }
288288
289- var repoIDs = nl .getRepoIDs ()
289+ var repoIDs = nl .getPendingRepoIDs ()
290290 var repos = make (map [int64 ]* Repository , len (repoIDs ))
291- var reposList = make (RepositoryList , 0 , len (repoIDs ))
292291 var left = len (repoIDs )
293292 for left > 0 {
294293 var limit = defaultMaxInSize
@@ -311,23 +310,33 @@ func (nl NotificationList) LoadRepos() (RepositoryList, error) {
311310 }
312311
313312 repos [repo .ID ] = & repo
314- reposList = append (reposList , & repo )
315313 }
316314 _ = rows .Close ()
317315
318316 left -= limit
319317 repoIDs = repoIDs [limit :]
320318 }
321319
320+ var reposList = make (RepositoryList , 0 , len (repoIDs ))
322321 for _ , notification := range nl {
323322 if notification .Repository == nil {
324323 notification .Repository = repos [notification .RepoID ]
325324 }
325+ var found bool
326+ for _ , r := range reposList {
327+ if r .ID == notification .Repository .ID {
328+ found = true
329+ break
330+ }
331+ }
332+ if ! found {
333+ reposList = append (reposList , notification .Repository )
334+ }
326335 }
327336 return reposList , nil
328337}
329338
330- func (nl NotificationList ) getIssueIDs () []int64 {
339+ func (nl NotificationList ) getPendingIssueIDs () []int64 {
331340 var ids = make (map [int64 ]struct {}, len (nl ))
332341 for _ , notification := range nl {
333342 if notification .Issue != nil {
@@ -346,7 +355,7 @@ func (nl NotificationList) LoadIssues() error {
346355 return nil
347356 }
348357
349- var issueIDs = nl .getIssueIDs ()
358+ var issueIDs = nl .getPendingIssueIDs ()
350359 var issues = make (map [int64 ]* Issue , len (issueIDs ))
351360 var left = len (issueIDs )
352361 for left > 0 {
@@ -380,15 +389,13 @@ func (nl NotificationList) LoadIssues() error {
380389 for _ , notification := range nl {
381390 if notification .Issue == nil {
382391 notification .Issue = issues [notification .IssueID ]
383- if notification .Issue != nil {
384- notification .Issue .Repo = notification .Repository
385- }
392+ notification .Issue .Repo = notification .Repository
386393 }
387394 }
388395 return nil
389396}
390397
391- func (nl NotificationList ) getCommentIDs () []int64 {
398+ func (nl NotificationList ) getPendingCommentIDs () []int64 {
392399 var ids = make (map [int64 ]struct {}, len (nl ))
393400 for _ , notification := range nl {
394401 if notification .CommentID == 0 || notification .Comment != nil {
@@ -407,7 +414,7 @@ func (nl NotificationList) LoadComments() error {
407414 return nil
408415 }
409416
410- var commentIDs = nl .getCommentIDs ()
417+ var commentIDs = nl .getPendingCommentIDs ()
411418 var comments = make (map [int64 ]* Comment , len (commentIDs ))
412419 var left = len (commentIDs )
413420 for left > 0 {
@@ -441,9 +448,7 @@ func (nl NotificationList) LoadComments() error {
441448 for _ , notification := range nl {
442449 if notification .CommentID > 0 && notification .Comment == nil {
443450 notification .Comment = comments [notification .CommentID ]
444- if notification .Comment != nil {
445- notification .Comment .Issue = notification .Issue
446- }
451+ notification .Comment .Issue = notification .Issue
447452 }
448453 }
449454 return nil
0 commit comments