本文整理匯總了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 };
}
});