本文整理汇总了TypeScript中main/reactors/modals.promisedModal函数的典型用法代码示例。如果您正苦于以下问题:TypeScript promisedModal函数的具体用法?TypeScript promisedModal怎么用?TypeScript promisedModal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了promisedModal函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: async
watcher.on(actions.clearBrowsingDataRequest, async (store, action) => {
const { wind } = action.payload;
const response = await promisedModal(
store,
modals.clearBrowsingData.make({
wind,
title: ["preferences.advanced.clear_browsing_data"],
message: "",
buttons: [
{
label: ["prompt.clear_browsing_data.clear"],
id: "modal-clear-data",
action: "widgetResponse",
},
"cancel",
],
widgetParams: {},
})
);
if (!response) {
// modal was closed
return;
}
store.dispatch(
actions.clearBrowsingData({
cache: response.cache,
cookies: response.cookies,
})
);
});
示例2: async
onError: async (e, log) => {
const response = await promisedModal(
store,
modals.showError.make({
wind: "root",
title: ["prompt.uninstall_error.title"],
message: ["prompt.uninstall_error.message"],
buttons: [
{
label: ["prompt.action.ok"],
action: actions.modalResponse({}),
},
"cancel",
],
widgetParams: { rawError: e, log },
})
);
if (!response) {
// modal was closed
return;
}
logger.info(`Should remove entry anyway, performing hard uninstall`);
try {
await mcall(messages.UninstallPerform, { caveId, hard: true });
store.dispatch(actions.uninstallEnded({}));
} catch (e) {
logger.error(`Well, even hard uninstall didn't work: ${e.stack}`);
}
},
示例3: pickManifestAction
export async function pickManifestAction(
store: Store,
manifestActions: Action[],
game: Game
): Promise<number> {
const buttons: ModalButtonSpec[] = [];
const bigButtons: ModalButtonSpec[] = [];
for (let index = 0; index < manifestActions.length; index++) {
const action = manifestActions[index];
if (!action.name) {
throw new Error(`in manifest, action ${index} is missing a name`);
}
const icon = action.icon || defaultManifestIcons[action.name] || "star";
bigButtons.push({
label: [`action.name.${action.name}`, { defaultValue: action.name }],
action: modals.pickManifestAction.action({ index }),
icon,
className: `action-${action.name}`,
});
}
buttons.push("cancel");
const response = await promisedModal(
store,
modals.pickManifestAction.make({
wind: "root",
title: game.title,
stillCoverUrl: game.stillCoverUrl,
coverUrl: game.coverUrl,
message: "",
bigButtons,
buttons,
widgetParams: {},
})
);
if (response) {
return response.index;
}
// as per butlerd spec, negative index means abort launch
return -1;
}
示例4: performInstallQueue
async function performInstallQueue({
store,
game,
uploadId,
}: PerformInstallQueueOpts) {
await promisedModal(
store,
modals.planInstall.make({
wind: "root",
title: game.title,
widgetParams: {
game,
uploadId,
},
buttons: [],
})
);
}
示例5: async
async ({ cave, upload, builds }) => {
const response = await promisedModal(
store,
modals.switchVersionCave.make({
wind: "root",
title: ["prompt.revert.title", { title: cave.game.title }],
message: "",
widgetParams: { cave, upload, builds },
buttons: ["cancel"],
})
);
if (!response) {
// modal was closed
return { index: -1 };
}
return { index: response.index };
}
示例6: async
convo.on(messages.PrereqsFailed, async ({ errorStack, error }) => {
closePrereqsModal();
const { title } = game;
let errorMessage = error;
errorMessage = errorMessage.split("\n")[0];
let log = logger.getLog();
const res = await promisedModal(
store,
modals.showError.make({
wind: "root",
title: ["game.install.could_not_launch", { title }],
message: [
"game.install.could_not_launch.message",
{ title, errorMessage },
],
detail: ["game.install.could_not_launch.detail"],
widgetParams: {
game,
rawError: { stack: errorStack },
log,
},
buttons: [
{
label: ["prompt.action.continue"],
action: actions.modalResponse({
continue: true,
}),
},
"cancel",
],
})
);
if (res) {
return { continue: true };
}
return { continue: false };
});
示例7: async
watcher.on(actions.quit, async (store, action) => {
const { tasks } = store.getState().tasks;
let runningGameIds: number[] = [];
for (const taskId of Object.keys(tasks)) {
const task = tasks[taskId];
if (task.name === "launch") {
runningGameIds.push(task.gameId);
}
}
if (runningGameIds.length > 0) {
const res = await promisedModal(
store,
modals.confirmQuit.make({
wind: "root",
title: ["prompt.confirm_quit.title"],
message: ["prompt.confirm_quit.message"],
buttons: [
{
label: ["prompt.action.quit_and_close_all"],
action: actions.modalResponse({}),
},
"cancel",
],
widgetParams: {
gameIds: runningGameIds,
},
})
);
if (!res) {
store.dispatch(actions.cancelQuit({}));
return;
}
}
store.dispatch(actions.performQuit({}));
});
示例8: async
client.on(messages.ProfileRequestTOTP, async () => {
logger.info(`Showing TOTP`);
const modalRes = await promisedModal(
store,
modals.twoFactorInput.make({
wind: "root",
title: ["login.two_factor.title"],
message: "",
widgetParams: {
username,
},
})
);
if (modalRes) {
logger.info(`TOTP answered`);
return { code: modalRes.totpCode };
} else {
// abort
logger.info(`TOTP cancelled`);
return { code: null };
}
});