diff --git a/module/applications/ui/chatLog.mjs b/module/applications/ui/chatLog.mjs index 854a031d..5e507a3b 100644 --- a/module/applications/ui/chatLog.mjs +++ b/module/applications/ui/chatLog.mjs @@ -1,3 +1,5 @@ +import { emitAsGM, GMUpdateEvent } from "../../systemRegistration/socket.mjs"; + export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLog { constructor(options) { super(options); @@ -98,7 +100,16 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo if (message.system.source.item && message.system.source.action) { const action = this.getAction(actor, message.system.source.item, message.system.source.action); if (!action || !action?.hasSave) return; - action.rollSave(token.actor, event, message).then(result => action.updateSaveMessage(result, message, token.id)); + action.rollSave(token.actor, event, message).then(result => emitAsGM( + GMUpdateEvent.UpdateSaveMessage, + action.updateSaveMessage.bind(action, result, message, token.id), + { + action: action.uuid, + message: message._id, + token: token.id, + result + } + )); } } diff --git a/module/systemRegistration/socket.mjs b/module/systemRegistration/socket.mjs index 0410ec02..e97fe5b0 100644 --- a/module/systemRegistration/socket.mjs +++ b/module/systemRegistration/socket.mjs @@ -23,7 +23,8 @@ export const socketEvent = { export const GMUpdateEvent = { UpdateDocument: 'DhGMUpdateDocument', UpdateSetting: 'DhGMUpdateSetting', - UpdateFear: 'DhGMUpdateFear' + UpdateFear: 'DhGMUpdateFear', + UpdateSaveMessage: 'DhGMUpdateSaveMessage' }; export const RefreshType = { @@ -55,8 +56,12 @@ export const registerSocketHooks = () => { ) ) ); - /* Hooks.callAll(socketEvent.DhpFearUpdate); - await game.socket.emit(`system.${CONFIG.DH.id}`, { action: socketEvent.DhpFearUpdate }); */ + break; + case GMUpdateEvent.UpdateSaveMessage: + const action = await fromUuid(data.update.action), + message = game.messages.get(data.update.message); + if(!action || !message) return; + action.updateSaveMessage(data.update.result, message, data.update.token); break; }