Merge branch 'master' into ai/issue-98
All checks were successful
Test / test (push) Successful in 2s

This commit is contained in:
2026-10-16 14:31:39 +00:00
7 changed files with 115 additions and 14 deletions

View File

@@ -567,7 +567,7 @@ function reportActorSyncError(error) {
console.warn(`${MODULE_ID} | Character sync failed and will retry.`, error);
}
async function pushFoundryActors(actors, fullSync = false) {
async function pushFoundryActors(actors, fullSync = false, replace = false) {
const token = getSyncToken();
if (!token || !game.user?.isGM || !game.world || (!actors.length && !fullSync)) return;
if (game.system.id !== "dnd5e") {
@@ -586,6 +586,9 @@ async function pushFoundryActors(actors, fullSync = false) {
// The folder tree those world items stand in (see worldItemFolderSnapshots).
folders: worldItemFolderSnapshots(),
fullSync,
// A forced sync replaces the campaign's row for these actors outright; a live
// change or a full snapshot never sets this, so the campaign keeps its edits.
replace,
}, token);
for (const mapping of result.actors || []) {
@@ -608,8 +611,9 @@ async function deleteDragonrollActor(foundryActorId) {
}
// Sending actors on purpose, whether or not autosync is on: this is the push the
// GM asks for. It upserts those actors only, so unlike a full snapshot it never
// prunes anything else the campaign holds.
// GM asks for. It replaces everything the campaign holds for those actors (Syndria98/
// dragonroll#96), but it upserts them only, so unlike a full snapshot it never prunes
// anything else the campaign holds.
async function forceSyncActorsToDragonroll(actors) {
if (!game.user?.isGM || !game.world || !actors.length) return;
if (!getSyncToken()) {
@@ -625,7 +629,7 @@ async function forceSyncActorsToDragonroll(actors) {
if (!supported.length) return;
try {
await pushFoundryActors(supported);
await pushFoundryActors(supported, false, true);
ui.notifications?.info(supported.length === 1
? `${supported[0].name} was sent to the Dragonroll campaign.`
: `${supported.length} actors were sent to the Dragonroll campaign.`);
@@ -1640,7 +1644,8 @@ Hooks.once("ready", () => {
});
// A GM sends selected actors to Dragonroll from the actor directory's context
// menu. This works with autosync on and off: it is the one push done on purpose.
// menu, replacing whatever the campaign holds for them. This works with autosync on
// and off: it is the one push done on purpose.
Hooks.on("getActorDirectoryEntryContext", (html, options) => {
if (!game.user?.isGM || !getSyncToken()) return;