diff --git a/public/utils.js b/public/utils.js
index ae67624..48a1e87 100644
--- a/public/utils.js
+++ b/public/utils.js
@@ -223,6 +223,10 @@ function formSubmit(e) {
e.submitter.disabled = "disabled"
request(targ.target, params,
function(res){
+ if (data.get("op") == "read_post") {
+ document.getElementById("p"+data.get("postid")).remove()
+ return
+ }
targ.outerHTML = res
setup()
},
diff --git a/routes.go b/routes.go
index b3cec93..88b5371 100644
--- a/routes.go
+++ b/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.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":
var score int16
score = 1
diff --git a/templates/frontpage.html b/templates/frontpage.html
index ac291fd..7ca8f0a 100644
--- a/templates/frontpage.html
+++ b/templates/frontpage.html
@@ -59,6 +59,6 @@
{{ template "sidebar.html" . }}
{{ end }}
-
+