Begin implementing the socket event handlers
This commit is contained in:
parent
36811b268c
commit
bfd408ef0b
3 changed files with 72 additions and 8 deletions
|
|
@ -1 +1,45 @@
|
|||
export function dataRequest() {};
|
||||
import { DialogManager } from "../utils/DialogManager.mjs";
|
||||
|
||||
export async function dataRequest(payload) {
|
||||
const {
|
||||
id,
|
||||
users,
|
||||
config,
|
||||
request,
|
||||
} = payload;
|
||||
|
||||
if (!id) {
|
||||
ui.notifications.error(game.i18n.format(
|
||||
`taf.notifs.error.malformed-socket-payload`,
|
||||
{
|
||||
event: `query.prompt`,
|
||||
details: `A request ID must be provided`,
|
||||
}),
|
||||
);
|
||||
return;
|
||||
};
|
||||
|
||||
// null/undefined is a special case for "all users but me" by default
|
||||
if (!Array.isArray(users) || users != null) {
|
||||
ui.notifications.error(game.i18n.format(
|
||||
`taf.notifs.error.malformed-socket-payload`,
|
||||
{
|
||||
event: `query.prompt`,
|
||||
details: ``,
|
||||
}),
|
||||
);
|
||||
return;
|
||||
};
|
||||
|
||||
if (!users.includes(game.user.id)) { return };
|
||||
|
||||
request.id = id;
|
||||
const result = await DialogManager.ask(request, config);
|
||||
if (result.state === `fronted`) { return };
|
||||
if (result.state === `errored`) {
|
||||
ui.notifications.error(result.error);
|
||||
return;
|
||||
};
|
||||
|
||||
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue