X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/e731dd71a77ad4ad1e9db22535e89444bb98e5d9..cfe08d42d69a7233838cfee7874b1852cb2c3db6:/app/assets/javascripts/messages.js diff --git a/app/assets/javascripts/messages.js b/app/assets/javascripts/messages.js index 0cae79a58..0f5933eba 100644 --- a/app/assets/javascripts/messages.js +++ b/app/assets/javascripts/messages.js @@ -1,30 +1,16 @@ $(document).ready(function () { - $(".inbox-mark-unread").on("ajax:success", function (event, data) { - $("#inboxanchor").remove(); - $(".user-button").before(data.inboxanchor); - - $("#inbox-count").replaceWith(data.inbox_count); - - $(this).parents(".inbox-row").removeClass("inbox-row").addClass("inbox-row-unread"); - }); - - $(".inbox-mark-read").on("ajax:success", function (event, data) { - $("#inboxanchor").remove(); - $(".user-button").before(data.inboxanchor); - - $("#inbox-count").replaceWith(data.inbox_count); - - $(this).parents(".inbox-row-unread").removeClass("inbox-row-unread").addClass("inbox-row"); + $(".messages-table .destroy-message").on("turbo:submit-end", function (event) { + if (event.detail.success) { + event.target.dataset.isDestroyed = true; + } }); - $(".inbox-destroy").on("ajax:success", function (event, data) { - $("#inboxanchor").remove(); - $(".user-button").before(data.inboxanchor); - - $("#inbox-count").replaceWith(data.inbox_count); - - $(this).parents(".inbox-row, .inbox-row-unread").fadeOut(800, "linear", function () { - $(this).remove(); - }); + $(".messages-table tbody tr").on("turbo:before-morph-element", function (event) { + if ($(event.target).find("[data-is-destroyed]").length > 0) { + event.preventDefault(); // NB: prevent Turbo from morhping/removing this element + $(event.target).fadeOut(800, "linear", function () { + $(this).remove(); + }); + } }); });