From 4f3bacb182ef1c5ed520e813e55cf769334741ab Mon Sep 17 00:00:00 2001 From: vtyeh Date: Tue, 15 Oct 2024 16:23:28 -0700 Subject: [PATCH] Fix broken links in drafts loaded with "load more" by dynamically creating edit link based on single_user bool in config.ini --- static/js/posts.js | 4 ++-- templates/user/articles.tmpl | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/static/js/posts.js b/static/js/posts.js index dfc30b7..17a31a8 100644 --- a/static/js/posts.js +++ b/static/js/posts.js @@ -188,7 +188,7 @@ var movePostHTML = function(postID) { } return $tmpl.innerHTML.replace(/POST_ID/g, postID); } -var createPostEl = function(post, owned) { +var createPostEl = function(post, owned, singleUser) { var $post = document.createElement('div'); let p = H.createPost(post.id, "", post.body) var title = (post.title || p.title || post.id); @@ -202,7 +202,7 @@ var createPostEl = function(post, owned) { posted = getFormattedDate(new Date(post.created)) } var hasDraft = H.exists('draft' + post.id); - $post.innerHTML += '

' + posted + ' edit' + (hasDraft ? 'ed' : '') + ' delete '+movePostHTML(post.id)+'

'; + $post.innerHTML += '

' + posted + ' edit' + (hasDraft ? 'ed' : '') + ' delete '+movePostHTML(post.id)+'

'; if (post.error) { $post.innerHTML += '

Sync error: ' + post.error + '

'; diff --git a/templates/user/articles.tmpl b/templates/user/articles.tmpl index 92f9c40..3e50863 100644 --- a/templates/user/articles.tmpl +++ b/templates/user/articles.tmpl @@ -202,8 +202,9 @@ function loadMorePosts() { if (http.readyState == 4) { if (http.status == 200) { var data = JSON.parse(http.responseText); + var singleUser = {{ .SingleUser }}; for (var i=0; i