Fix #4663: Tag script mode sometimes adds "null" tag.

This commit is contained in:
evazion
2021-01-11 19:27:10 -06:00
parent c1b865b160
commit a698ca2b8c
2 changed files with 2 additions and 1 deletions

View File

@@ -151,7 +151,7 @@ PostModeMenu.click = function(e) {
Post.tag(post_id, "upvote:me");
} else if (s === "tag-script") {
var current_script_id = localStorage.getItem("current_tag_script_id");
var tag_script = localStorage.getItem("tag-script-" + current_script_id);
var tag_script = localStorage.getItem("tag-script-" + current_script_id) ?? "";
Post.tag(post_id, tag_script);
} else {
return;

View File

@@ -444,6 +444,7 @@ Post.show_pending_update_notice = function() {
}
Post.tag = function(post_id, tags) {
tags ??= "";
const tag_string = (Array.isArray(tags) ? tags.join(" ") : String(tags));
Post.update(post_id, "tag-script", { post: { old_tag_string: "", tag_string: tag_string }});
}