Skip to content

Commit 92be0a1

Browse files
Fix edge case error when topics list is temporarily empty
1 parent 1b3234a commit 92be0a1

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed
Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
using System.Linq;
1+
using System.Collections.Generic;
2+
using System.Linq;
23
using System.Web.Mvc;
3-
using OurUmbraco.Community.People;
44
using OurUmbraco.Forum.Services;
55
using Umbraco.Web.Mvc;
66

@@ -11,9 +11,14 @@ public class LatestActivityController : SurfaceController
1111
public ActionResult LatestActivity(int numberOfTopics = 10)
1212
{
1313
var discourseService = new DiscourseService();
14-
var discourseTopics = discourseService.GetLatestTopics("questions", 5).Take(numberOfTopics).ToList();
14+
var discourseTopics = discourseService.GetLatestTopics("questions", 5);
15+
var topics = new List<Models.DiscourseTopic>();
16+
if(discourseTopics != null)
17+
{
18+
topics = discourseTopics.Take(numberOfTopics).ToList();
19+
}
1520

16-
return PartialView("~/Views/Partials/Home/LatestForumActivity.cshtml", discourseTopics);
21+
return PartialView("~/Views/Partials/Home/LatestForumActivity.cshtml", topics);
1722
}
1823
}
1924
}

0 commit comments

Comments
 (0)