Relic
Relic
TTyphonJS
Created by Relic on 5/28/2024 in #typhonjs-runtime
Global Arrays & Writable Stores
I currently have this set to use a settings array to use to pass data to the SanityApp and also check to see if the Application is live because the application is to close if the array is empty. It's "populating the app" part and checking if the array is empty part is working as intended, but the interval I have set up in the script of the SanityApp appears to not be working as it's not updating automatically. SanityApp and SanityApplication.js
import { SvelteApplication } from '#runtime/svelte/application';
import SanityApp from './templates/SanityApp.svelte';
import { FatesDescentRoll } from './FatesDescentRoll.js';
import { MODULE_ID } from './settings.js';
import { debugLog } from './utils.js';

export default class SanityApplication extends SvelteApplication
{
constructor(actor, type, config, performRoll)
{
debugLog("SanityApplication | constructor called with:", actor, type, config);
const actorName = game.actors.get(actor.id)?.name;
const globalRequests = game.settings.get(MODULE_ID, "globalSaveRequests");

globalRequests.push({ actorId: actor.id, actorName, type, config });
game.settings.set(MODULE_ID, "globalSaveRequests", globalRequests);

super({
title: 'Sanity Dialog',
width: 630,
height: 'auto',
resizable: false,
svelte: {
class: SanityApp,
target: document.body,
props: {
performRoll
}
},
id: `sanity-dialog-${actor.id}`
});
}

static get defaultOptions()
{
return foundry.utils.mergeObject(super.defaultOptions, {
classes: ['sanity-dialog'],
resizable: false,
id: 'sanity-dialog'
});
}

static showSanityDialog(actorId, type, config)
{
const globalRequests = game.settings.get(MODULE_ID, "globalSaveRequests");

if (globalRequests.length === 0)
{
const actor = game.actors.get(actorId);
if (!actor) { return; }

const sanityApp = new SanityApplication(actor, type, config, FatesDescentRoll.performRoll);
sanityApp.render(true);
}
else
{
const actorName = game.actors.get(actorId)?.name;
globalRequests.push({ actorId, actorName, type, config });
game.settings.set(MODULE_ID, "globalSaveRequests", globalRequests);
}
}
}
import { SvelteApplication } from '#runtime/svelte/application';
import SanityApp from './templates/SanityApp.svelte';
import { FatesDescentRoll } from './FatesDescentRoll.js';
import { MODULE_ID } from './settings.js';
import { debugLog } from './utils.js';

export default class SanityApplication extends SvelteApplication
{
constructor(actor, type, config, performRoll)
{
debugLog("SanityApplication | constructor called with:", actor, type, config);
const actorName = game.actors.get(actor.id)?.name;
const globalRequests = game.settings.get(MODULE_ID, "globalSaveRequests");

globalRequests.push({ actorId: actor.id, actorName, type, config });
game.settings.set(MODULE_ID, "globalSaveRequests", globalRequests);

super({
title: 'Sanity Dialog',
width: 630,
height: 'auto',
resizable: false,
svelte: {
class: SanityApp,
target: document.body,
props: {
performRoll
}
},
id: `sanity-dialog-${actor.id}`
});
}

static get defaultOptions()
{
return foundry.utils.mergeObject(super.defaultOptions, {
classes: ['sanity-dialog'],
resizable: false,
id: 'sanity-dialog'
});
}

static showSanityDialog(actorId, type, config)
{
const globalRequests = game.settings.get(MODULE_ID, "globalSaveRequests");

if (globalRequests.length === 0)
{
const actor = game.actors.get(actorId);
if (!actor) { return; }

const sanityApp = new SanityApplication(actor, type, config, FatesDescentRoll.performRoll);
sanityApp.render(true);
}
else
{
const actorName = game.actors.get(actorId)?.name;
globalRequests.push({ actorId, actorName, type, config });
game.settings.set(MODULE_ID, "globalSaveRequests", globalRequests);
}
}
}
21 replies
TTyphonJS
Created by Relic on 5/23/2024 in #typhonjs-runtime
Application !Closing
No description
11 replies