mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
[Fix] 987 - Auto Expand Bottom Chat (#1010)
* If the last message in the chatlog is updated, scroll to bottom of chatlog * Cleaned up with ui.chat methods
This commit is contained in:
parent
f19548ef4f
commit
4038c44f9a
1 changed files with 30 additions and 17 deletions
|
|
@ -43,6 +43,18 @@ export default class DhpChatMessage extends foundry.documents.ChatMessage {
|
||||||
return super._preDelete(options, user);
|
return super._preDelete(options, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @inheritDoc */
|
||||||
|
_onUpdate(changes, options, userId) {
|
||||||
|
super._onUpdate(changes, options, userId);
|
||||||
|
|
||||||
|
const lastMessage = Array.from(game.messages).sort((a, b) => b.timestamp - a.timestamp)[0];
|
||||||
|
if (lastMessage.id === this.id && ui.chat.isAtBottom) {
|
||||||
|
setTimeout(() => {
|
||||||
|
ui.chat.scrollBottom();
|
||||||
|
}, 5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
enrichChatMessage(html) {
|
enrichChatMessage(html) {
|
||||||
const elements = html.querySelectorAll('[data-perm-id]');
|
const elements = html.querySelectorAll('[data-perm-id]');
|
||||||
elements.forEach(e => {
|
elements.forEach(e => {
|
||||||
|
|
@ -55,7 +67,7 @@ export default class DhpChatMessage extends foundry.documents.ChatMessage {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (this.isContentVisible) {
|
if (this.isContentVisible) {
|
||||||
if(this.type === 'dualityRoll') {
|
if (this.type === 'dualityRoll') {
|
||||||
html.classList.add('duality');
|
html.classList.add('duality');
|
||||||
switch (this.system.roll?.result?.duality) {
|
switch (this.system.roll?.result?.duality) {
|
||||||
case 1:
|
case 1:
|
||||||
|
|
@ -70,27 +82,28 @@ export default class DhpChatMessage extends foundry.documents.ChatMessage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const autoExpandRoll = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.appearance).expandRollMessage,
|
const autoExpandRoll = game.settings.get(
|
||||||
rollSections = html.querySelectorAll(".roll-part"),
|
CONFIG.DH.id,
|
||||||
itemDesc = html.querySelector(".domain-card-move");
|
CONFIG.DH.SETTINGS.gameSettings.appearance
|
||||||
|
).expandRollMessage,
|
||||||
|
rollSections = html.querySelectorAll('.roll-part'),
|
||||||
|
itemDesc = html.querySelector('.domain-card-move');
|
||||||
rollSections.forEach(s => {
|
rollSections.forEach(s => {
|
||||||
if(s.classList.contains("roll-section")) {
|
if (s.classList.contains('roll-section')) {
|
||||||
const toExpand = s.querySelector('[data-action="expandRoll"]');
|
const toExpand = s.querySelector('[data-action="expandRoll"]');
|
||||||
toExpand.classList.toggle("expanded", autoExpandRoll.roll);
|
toExpand.classList.toggle('expanded', autoExpandRoll.roll);
|
||||||
} else if(s.classList.contains("damage-section"))
|
} else if (s.classList.contains('damage-section'))
|
||||||
s.classList.toggle("expanded", autoExpandRoll.damage);
|
s.classList.toggle('expanded', autoExpandRoll.damage);
|
||||||
else if(s.classList.contains("target-section"))
|
else if (s.classList.contains('target-section')) s.classList.toggle('expanded', autoExpandRoll.target);
|
||||||
s.classList.toggle("expanded", autoExpandRoll.target);
|
|
||||||
});
|
});
|
||||||
if(itemDesc && autoExpandRoll.desc)
|
if (itemDesc && autoExpandRoll.desc) itemDesc.setAttribute('open', '');
|
||||||
itemDesc.setAttribute("open", "");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!game.user.isGM) {
|
if (!game.user.isGM) {
|
||||||
const applyButtons = html.querySelector(".apply-buttons");
|
const applyButtons = html.querySelector('.apply-buttons');
|
||||||
applyButtons?.remove();
|
applyButtons?.remove();
|
||||||
if(!this.isAuthor && !this.speakerActor?.isOwner) {
|
if (!this.isAuthor && !this.speakerActor?.isOwner) {
|
||||||
const buttons = html.querySelectorAll(".ability-card-footer > .ability-use-button");
|
const buttons = html.querySelectorAll('.ability-card-footer > .ability-use-button');
|
||||||
buttons.forEach(b => b.remove());
|
buttons.forEach(b => b.remove());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue