Move the query event handlers into a subfolder and name them in a consistent way
This commit is contained in:
parent
6a2cc1170d
commit
c113c326c6
6 changed files with 38 additions and 32 deletions
|
|
@ -1,51 +0,0 @@
|
|||
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 (users != null && !Array.isArray(users)) {
|
||||
ui.notifications.error(game.i18n.format(
|
||||
`taf.notifs.error.malformed-socket-payload`,
|
||||
{
|
||||
event: `query.prompt`,
|
||||
details: `A list of users must be provided`,
|
||||
}),
|
||||
);
|
||||
return;
|
||||
};
|
||||
|
||||
if (users != null && !users.includes(game.user.id)) { return };
|
||||
|
||||
request.id = id;
|
||||
const result = await DialogManager.ask(request, config);
|
||||
if (result.state === `fronted`) {
|
||||
return;
|
||||
} else if (result.state === `errored`) {
|
||||
ui.notifications.error(result.error);
|
||||
} else if (result.state === `prompted`) {
|
||||
game.socket.emit(`system.taf`, {
|
||||
event: `query.submit`,
|
||||
payload: {
|
||||
id: request.id,
|
||||
answers: result.answers,
|
||||
},
|
||||
});
|
||||
};
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue