Skip to content

Commit

Permalink
other discussions link. fixes #74
Browse files Browse the repository at this point in the history
  • Loading branch information
rystaf committed Apr 27, 2024
1 parent 4a862b4 commit 4483159
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
22 changes: 16 additions & 6 deletions state.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ type Activity struct {

type Post struct {
lemmy.PostView
Rank int
State *State
Rank int
State *State
CrossPosts int
}

type Session struct {
Expand Down Expand Up @@ -666,10 +667,19 @@ func (state *State) GetPost(postid int64) {
state.Error = err
return
}
state.Posts = []Post{Post{
PostView: resp.PostView,
State: state,
}}
post := Post{
PostView: resp.PostView,
State: state,
CrossPosts: len(resp.CrossPosts),
}
if state.Listing == "Local" && post.Post.Local {
for _, p := range resp.CrossPosts {
if !p.Post.Local {
post.CrossPosts--
}
}
}
state.Posts = []Post{post}
if state.CommentID > 0 && len(state.Posts) > 0 {
state.Posts[0].Rank = -1
}
Expand Down
4 changes: 4 additions & 0 deletions templates/nav.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@
<li id="showimages"><a id="se" href="">show images</a></li>
{{ end }}
{{ end }}

{{ if and .PostID }}{{ $post := (index .Posts 0) }}{{ if $post.CrossPosts }}
<li><a href="/{{.Host}}/search?q={{ $post.Post.URL.String }}&searchtype=Url{{ if not $post.Post.Local }}&listingType=All{{end}}">other discussions ({{ $post.CrossPosts }})</a></li>
{{ end }}{{ end }}
</ul>
{{ end }}
</nav>

0 comments on commit 4483159

Please sign in to comment.