related tags: refactor /related_tags.js to avoid updating unchanged columns.
Refactor the /related_tags.js call so that when the "Related tags" button is clicked, it only replaces the columns that actually changed, not the entire related tags section. This avoids rebuilding the Recent / Frequent / Translated Tags / Artist columns every time the "Related tags" button is clicked.
This commit is contained in:
@@ -3,8 +3,6 @@ import Utility from './utility';
|
||||
let RelatedTag = {};
|
||||
|
||||
RelatedTag.initialize_all = function() {
|
||||
RelatedTag.artists = [];
|
||||
RelatedTag.translated_tags = [];
|
||||
$(document).on("click.danbooru", ".related-tags-button", RelatedTag.on_click_related_tags_button);
|
||||
$(document).on("click.danbooru", ".related-tags a.search-tag", RelatedTag.toggle_tag);
|
||||
$(document).on("click.danbooru", "#show-related-tags-link, #hide-related-tags-link", RelatedTag.toggle);
|
||||
@@ -20,15 +18,6 @@ RelatedTag.tags_include = function(name) {
|
||||
return $.inArray(name.toLowerCase(), current) > -1;
|
||||
}
|
||||
|
||||
RelatedTag.update_related_tags = function (category = "") {
|
||||
$.get("/related_tag.js", {
|
||||
"query": RelatedTag.current_tag(),
|
||||
"category": category,
|
||||
"translated_tags": RelatedTag.translated_tags.join(" "),
|
||||
"artists": RelatedTag.artists.join(" "),
|
||||
});
|
||||
}
|
||||
|
||||
RelatedTag.on_open_post_edit_dialog = function(event) {
|
||||
$("#related-tags-container").removeClass("visible").addClass("hidden");
|
||||
}
|
||||
@@ -38,20 +27,18 @@ RelatedTag.on_close_post_edit_dialog = function(event) {
|
||||
}
|
||||
|
||||
RelatedTag.on_show_post_edit_form = function(event) {
|
||||
RelatedTag.update_related_tags();
|
||||
$.get("/related_tag.js", { user_tags: true });
|
||||
$("#fetch-data-manual").click();
|
||||
}
|
||||
|
||||
RelatedTag.on_click_related_tags_button = function (event) {
|
||||
const category = $(event.target).data("category");
|
||||
RelatedTag.update_related_tags(category);
|
||||
$("#related-tags-container").removeClass("hidden").addClass("visible");
|
||||
$.get("/related_tag.js", { query: RelatedTag.current_tag(), category: $(event.target).data("category") });
|
||||
RelatedTag.show();
|
||||
}
|
||||
|
||||
RelatedTag.on_update_source_data = function (event, source) {
|
||||
Danbooru.RelatedTag.artists = source.artists.map(artist => artist.name);
|
||||
Danbooru.RelatedTag.translated_tags = source.translated_tags.map(tag => tag[0]);
|
||||
RelatedTag.update_related_tags();
|
||||
RelatedTag.on_update_source_data = function (event, { source, related_tags_html }) {
|
||||
$(".source-related-tags-columns").replaceWith(related_tags_html);
|
||||
RelatedTag.update_selected();
|
||||
}
|
||||
|
||||
RelatedTag.current_tag = function() {
|
||||
|
||||
Reference in New Issue
Block a user