feat: merge consecutive share events

This commit is contained in:
Barış Soner Uşaklı
2025-02-21 12:57:07 -05:00
parent 9bfa885392
commit 9153f8cfae
3 changed files with 32 additions and 2 deletions

View File

@@ -85,12 +85,24 @@ define('forum/topic/threadTools', [
topicContainer.on('click', '[component="topic/event/delete"]', function () {
const eventId = $(this).attr('data-topic-event-id');
const eventEl = $(this).parents('[component="topic/event"]');
const eventEl = $(this).parents('[data-topic-event-id]');
bootbox.confirm('[[topic:delete-event-confirm]]', (ok) => {
if (ok) {
api.del(`/topics/${tid}/events/${eventId}`, {})
.then(function () {
const itemsParent = eventEl.parents('[component="topic/event/items"]');
eventEl.remove();
if (itemsParent.length) {
const childrenCount = itemsParent.children().length;
const eventParent = itemsParent.parents('[component="topic/event"]');
if (!childrenCount) {
eventParent.remove();
} else {
eventParent
.find('[data-bs-toggle]')
.translateText(`[[topic:announcers-x, ${childrenCount}]]`);
}
}
})
.catch(alerts.error);
}