No jam snippets if no jam projects!
This commit is contained in:
parent
a9b0606b79
commit
d2f44f8e5f
|
@ -66,18 +66,20 @@ func JamIndex2022(c *RequestContext) ResponseData {
|
||||||
projectIds = append(projectIds, jp.Project.ID)
|
projectIds = append(projectIds, jp.Project.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
snippets, err := hmndata.FetchSnippets(c, c.Conn, c.CurrentUser, hmndata.SnippetQuery{
|
if len(projectIds) > 0 {
|
||||||
ProjectIDs: projectIds,
|
snippets, err := hmndata.FetchSnippets(c, c.Conn, c.CurrentUser, hmndata.SnippetQuery{
|
||||||
Limit: 12,
|
ProjectIDs: projectIds,
|
||||||
})
|
Limit: 12,
|
||||||
if err != nil {
|
})
|
||||||
return c.ErrorResponse(http.StatusInternalServerError, oops.New(err, "failed to fetch snippets for jam showcase"))
|
if err != nil {
|
||||||
}
|
return c.ErrorResponse(http.StatusInternalServerError, oops.New(err, "failed to fetch snippets for jam showcase"))
|
||||||
showcaseItems = make([]templates.TimelineItem, 0, len(snippets))
|
}
|
||||||
for _, s := range snippets {
|
showcaseItems = make([]templates.TimelineItem, 0, len(snippets))
|
||||||
timelineItem := SnippetToTimelineItem(&s.Snippet, s.Asset, s.DiscordMessage, s.Projects, s.Owner, c.Theme, false)
|
for _, s := range snippets {
|
||||||
if timelineItem.CanShowcase {
|
timelineItem := SnippetToTimelineItem(&s.Snippet, s.Asset, s.DiscordMessage, s.Projects, s.Owner, c.Theme, false)
|
||||||
showcaseItems = append(showcaseItems, timelineItem)
|
if timelineItem.CanShowcase {
|
||||||
|
showcaseItems = append(showcaseItems, timelineItem)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -110,24 +112,23 @@ func JamFeed2022(c *RequestContext) ResponseData {
|
||||||
projectIds = append(projectIds, jp.Project.ID)
|
projectIds = append(projectIds, jp.Project.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
snippets, err := hmndata.FetchSnippets(c, c.Conn, c.CurrentUser, hmndata.SnippetQuery{
|
var timelineItems []templates.TimelineItem
|
||||||
ProjectIDs: projectIds,
|
if len(projectIds) > 0 {
|
||||||
})
|
snippets, err := hmndata.FetchSnippets(c, c.Conn, c.CurrentUser, hmndata.SnippetQuery{
|
||||||
if err != nil {
|
ProjectIDs: projectIds,
|
||||||
return c.ErrorResponse(http.StatusInternalServerError, oops.New(err, "failed to fetch snippets for jam showcase"))
|
})
|
||||||
|
if err != nil {
|
||||||
|
return c.ErrorResponse(http.StatusInternalServerError, oops.New(err, "failed to fetch snippets for jam showcase"))
|
||||||
|
}
|
||||||
|
|
||||||
|
timelineItems = make([]templates.TimelineItem, 0, len(snippets))
|
||||||
|
for _, s := range snippets {
|
||||||
|
timelineItem := SnippetToTimelineItem(&s.Snippet, s.Asset, s.DiscordMessage, s.Projects, s.Owner, c.Theme, false)
|
||||||
|
timelineItem.SmallInfo = true
|
||||||
|
timelineItems = append(timelineItems, timelineItem)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
timelineItems := make([]templates.TimelineItem, 0, len(snippets))
|
|
||||||
|
|
||||||
for _, s := range snippets {
|
|
||||||
timelineItem := SnippetToTimelineItem(&s.Snippet, s.Asset, s.DiscordMessage, s.Projects, s.Owner, c.Theme, false)
|
|
||||||
timelineItem.SmallInfo = true
|
|
||||||
timelineItems = append(timelineItems, timelineItem)
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO(asaf): add forum posts from jam project threads to timeline
|
|
||||||
// TODO(asaf): Sort timeline items
|
|
||||||
|
|
||||||
pageProjects := make([]templates.Project, 0, len(jamProjects))
|
pageProjects := make([]templates.Project, 0, len(jamProjects))
|
||||||
for _, p := range jamProjects {
|
for _, p := range jamProjects {
|
||||||
pageProjects = append(pageProjects, templates.ProjectAndStuffToTemplate(&p, hmndata.UrlContextForProject(&p.Project).BuildHomepage(), c.Theme))
|
pageProjects = append(pageProjects, templates.ProjectAndStuffToTemplate(&p, hmndata.UrlContextForProject(&p.Project).BuildHomepage(), c.Theme))
|
||||||
|
|
Loading…
Reference in New Issue