From 0d9900ee801b40f102e0f9d5f0b01bf3128b550a Mon Sep 17 00:00:00 2001 From: Kim Mantas Date: Wed, 20 Mar 2024 19:42:41 +0000 Subject: [PATCH] Additional v12 deprecation adjustments. --- module/applications/award.mjs | 8 +++++--- module/dice/damage-roll.mjs | 3 ++- module/documents/item.mjs | 5 +++-- module/enrichers.mjs | 3 ++- module/migration.mjs | 2 +- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/module/applications/award.mjs b/module/applications/award.mjs index 09f63fc7df..7bb124a10c 100644 --- a/module/applications/award.mjs +++ b/module/applications/award.mjs @@ -260,11 +260,13 @@ export default class Award extends DialogMixin(FormApplication) { const whisperTargets = game.users.filter(user => destination.testUserPermission(user, "OWNER")); const whisper = whisperTargets.length !== game.users.size; - messages.push({ - type: CONST.CHAT_MESSAGE_TYPES.OTHER, + const messageData = { content, whisper: whisper ? whisperTargets : [] - }); + }; + // TODO: Remove when v11 support is dropped. + if ( game.release.generation < 12 ) messageData.type = CONST.CHAT_MESSAGE_TYPES.OTHER; + messages.push(messageData); } if ( messages.length ) cls.createDocuments(messages); } diff --git a/module/dice/damage-roll.mjs b/module/dice/damage-roll.mjs index 39dbe3010b..b86fc97d13 100644 --- a/module/dice/damage-roll.mjs +++ b/module/dice/damage-roll.mjs @@ -208,10 +208,11 @@ export default class DamageRoll extends Roll { // Prepare chat data messageData = foundry.utils.mergeObject({ user: game.user.id, - type: CONST.CHAT_MESSAGE_TYPES.ROLL, sound: CONFIG.sounds.dice }, messageData); messageData.rolls = rolls; + // TODO: Remove when v11 support is dropped. + if ( game.release.generation < 12 ) messageData.type = CONST.CHAT_MESSAGE_TYPES.ROLL; // Either create the message or just return the chat data const cls = getDocumentClass("ChatMessage"); diff --git a/module/documents/item.mjs b/module/documents/item.mjs index d8a63a7aca..b3c36b4a2f 100644 --- a/module/documents/item.mjs +++ b/module/documents/item.mjs @@ -1398,11 +1398,12 @@ export default class Item5e extends SystemDocumentMixin(Item) { // Create the ChatMessage data object const chatData = { user: game.user.id, - type: CONST.CHAT_MESSAGE_TYPES.OTHER, content: html, speaker: ChatMessage.getSpeaker({actor: this.actor, token}), flags: {"core.canPopout": true} }; + // TODO: Remove when v11 support is dropped. + if ( game.release.generation < 12 ) chatData.type = CONST.CHAT_MESSAGE_TYPES.OTHER; // If the Item was destroyed in the process of displaying its card - embed the item data in the chat message if ( (this.type === "consumable") && !this.actor.items.has(this.id) ) { @@ -2160,7 +2161,7 @@ export default class Item5e extends SystemDocumentMixin(Item) { */ static _onChatCardToggleContent(event) { const header = event.currentTarget; - if ( header.classList.contains("collapsible") ) { + if ( header.classList.contains("collapsible") && !event.target.closest(".collapsible-content.card-content") ) { event.preventDefault(); header.classList.toggle("collapsed"); diff --git a/module/enrichers.mjs b/module/enrichers.mjs index 098fafdce7..38141c834d 100644 --- a/module/enrichers.mjs +++ b/module/enrichers.mjs @@ -992,7 +992,6 @@ async function rollAction(event) { const MessageClass = getDocumentClass("ChatMessage"); const chatData = { user: game.user.id, - type: CONST.CHAT_MESSAGE_TYPES.OTHER, content: await renderTemplate("systems/dnd5e/templates/chat/request-card.hbs", { buttonLabel: createRollLabel({ ...target.dataset, format: "short", icon: true }), hiddenLabel: createRollLabel({ ...target.dataset, format: "short", icon: true, hideDC: true }), @@ -1001,6 +1000,8 @@ async function rollAction(event) { flavor: game.i18n.localize("EDITOR.DND5E.Inline.RollRequest"), speaker: MessageClass.getSpeaker({user: game.user}) }; + // TODO: Remove when v11 support is dropped. + if ( game.release.generation < 12 ) chatData.type = CONST.CHAT_MESSAGE_TYPES.OTHER; return MessageClass.create(chatData); } } diff --git a/module/migration.mjs b/module/migration.mjs index b0bdabe33e..b2bea1224a 100644 --- a/module/migration.mjs +++ b/module/migration.mjs @@ -496,7 +496,7 @@ export const migrateCopyActorTransferEffects = function(actor, effects, { actorU */ export const migrateEffectData = function(effect, migrationData, { parent }={}) { const updateData = {}; - _migrateDocumentIcon(effect, updateData, {...migrationData, field: "icon"}); + _migrateDocumentIcon(effect, updateData, {...migrationData, field: game.release.generation < 12 ? "icon" : "img"}); _migrateEffectArmorClass(effect, updateData); if ( foundry.utils.isNewerVersion("3.1.0", effect._stats?.systemVersion ?? parent?._stats?.systemVersion) ) { _migrateTransferEffect(effect, parent, updateData);