mirror of
https://github.com/rystaf/mlmym.git
synced 2024-11-24 22:20:37 +00:00
mark post read. fixes #20
This commit is contained in:
parent
1eec1a7274
commit
5d778161ec
|
@ -223,6 +223,10 @@ function formSubmit(e) {
|
||||||
e.submitter.disabled = "disabled"
|
e.submitter.disabled = "disabled"
|
||||||
request(targ.target, params,
|
request(targ.target, params,
|
||||||
function(res){
|
function(res){
|
||||||
|
if (data.get("op") == "read_post") {
|
||||||
|
document.getElementById("p"+data.get("postid")).remove()
|
||||||
|
return
|
||||||
|
}
|
||||||
targ.outerHTML = res
|
targ.outerHTML = res
|
||||||
setup()
|
setup()
|
||||||
},
|
},
|
||||||
|
|
16
routes.go
16
routes.go
|
@ -1102,6 +1102,22 @@ func UserOp(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
||||||
r.URL.Path = "/" + state.Host + "/c/" + resp.PostView.Community.Name
|
r.URL.Path = "/" + state.Host + "/c/" + resp.PostView.Community.Name
|
||||||
r.URL.RawQuery = ""
|
r.URL.RawQuery = ""
|
||||||
}
|
}
|
||||||
|
case "read_post":
|
||||||
|
postid, _ := strconv.Atoi(r.FormValue("postid"))
|
||||||
|
post := types.MarkPostAsRead{
|
||||||
|
PostID: postid,
|
||||||
|
Read: true,
|
||||||
|
}
|
||||||
|
if r.FormValue("submit") == "mark unread" {
|
||||||
|
post.Read = false
|
||||||
|
}
|
||||||
|
_, err := state.Client.MarkPostAsRead(context.Background(), post)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
} else if r.FormValue("xhr") != "" {
|
||||||
|
w.Write([]byte{})
|
||||||
|
return
|
||||||
|
}
|
||||||
case "vote_post":
|
case "vote_post":
|
||||||
var score int16
|
var score int16
|
||||||
score = 1
|
score = 1
|
||||||
|
|
|
@ -59,6 +59,6 @@
|
||||||
{{ template "sidebar.html" . }}
|
{{ template "sidebar.html" . }}
|
||||||
</main>
|
</main>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
<script src="/_/static/utils.js?v=19"></script>
|
<script src="/_/static/utils.js?v=20"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -139,7 +139,7 @@
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
<script src="/_/static/utils.js?v=19"></script>
|
<script src="/_/static/utils.js?v=20"></script>
|
||||||
{{ template "sidebar.html" . }}
|
{{ template "sidebar.html" . }}
|
||||||
</main>
|
</main>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{{ if and (ne .State.Op "vote_post") (ne .State.Op "save_post") }}
|
{{ if and (ne .State.Op "vote_post") (ne .State.Op "save_post") }}
|
||||||
<div class="post{{if .Post.Deleted}} deleted{{end}}{{ if .Post.FeaturedCommunity }} distinguished{{end}}{{if .Post.FeaturedLocal }} announcement{{end}}">
|
<div class="post{{if .Post.Deleted}} deleted{{end}}{{ if .Post.FeaturedCommunity }} distinguished{{end}}{{if .Post.FeaturedLocal }} announcement{{end}}" id="p{{.Post.ID}}">
|
||||||
{{ if gt .Rank 0 }}
|
{{ if gt .Rank 0 }}
|
||||||
<div class="rank"> {{ .Rank }} </div>
|
<div class="rank"> {{ .Rank }} </div>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
@ -91,6 +91,17 @@
|
||||||
{{ if .State.PostID }}
|
{{ if .State.PostID }}
|
||||||
<a id="hidechildren" class="scripting" href="">hide all child comments</a>
|
<a id="hidechildren" class="scripting" href="">hide all child comments</a>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
{{ if and .State.Site .State.Site.MyUser.IsValid (not .State.Site.MyUser.MustValue.LocalUserView.LocalUser.ShowReadPosts) }}
|
||||||
|
<form class="link-btn" method="POST">
|
||||||
|
<input type="hidden" name="postid" value="{{.Post.ID }}">
|
||||||
|
<input type="hidden" name="op" value="read_post">
|
||||||
|
{{ if .Post.Deleted }}
|
||||||
|
<input type="submit" name="submit" value="mark unread">
|
||||||
|
{{ else }}
|
||||||
|
<input type="submit" name="submit" value="mark read">
|
||||||
|
{{ end }}
|
||||||
|
</form>
|
||||||
|
{{ end }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div></div>
|
<div></div>
|
||||||
|
|
Loading…
Reference in a new issue