Fix issue #96: When right clicking actor on foundry, show action to force sync to dragonroll
All checks were successful
Test / test (push) Successful in 2s
All checks were successful
Test / test (push) Successful in 2s
This commit is contained in:
@@ -64,9 +64,9 @@ function resolveWorldAssets(fields, campaign) {
|
||||
}
|
||||
}
|
||||
|
||||
async function saveFoundryActor(campaign, source, fullSync = false) {
|
||||
async function saveFoundryActor(campaign, source, fullSync = false, replace = false) {
|
||||
const foundryActorId = String(source?._id || source?.id || '').trim().slice(0, 120);
|
||||
const fields = foundryActorToCharacter(source || {});
|
||||
const fields = foundryActorToCharacter(source || {}, replace);
|
||||
if (!foundryActorId || !fields.name) return null;
|
||||
resolveWorldAssets(fields, campaign);
|
||||
|
||||
@@ -304,12 +304,16 @@ router.post('/sync/snapshot', async (req, res) => {
|
||||
}
|
||||
|
||||
const fullSync = req.body.fullSync === true;
|
||||
// A forced actor sync from the module's context menu replaces the campaign's
|
||||
// row for the actors it sends entirely (Syndria98/dragonroll#96). It stays
|
||||
// clear of fullSync: it never prunes, unlike a reconnect's full snapshot.
|
||||
const replace = req.body.replace === true;
|
||||
// A module that knows nothing about item folders sends neither the tree
|
||||
// nor the folder of an item, and then nothing here touches the folders.
|
||||
const folderSources = Array.isArray(req.body.folders) ? req.body.folders : null;
|
||||
const actors = [];
|
||||
for (const source of actorSources || []) {
|
||||
const mapping = await saveFoundryActor(campaign, source, fullSync);
|
||||
const mapping = await saveFoundryActor(campaign, source, fullSync, replace);
|
||||
if (mapping) actors.push(mapping);
|
||||
}
|
||||
const itemFolders = folderSources ? await syncFoundryItemFolders(campaign, folderSources) : null;
|
||||
|
||||
Reference in New Issue
Block a user