本文整理汇总了TypeScript中common/actions.actions.installLocationsChanged方法的典型用法代码示例。如果您正苦于以下问题:TypeScript actions.installLocationsChanged方法的具体用法?TypeScript actions.installLocationsChanged怎么用?TypeScript actions.installLocationsChanged使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common/actions.actions
的用法示例。
在下文中一共展示了actions.installLocationsChanged方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: async
watcher.on(actions.addInstallLocation, async (store, action) => {
const { window } = action.payload;
const i18n = store.getState().i18n;
const nativeWindow = getNativeWindow(store.getState(), window);
if (!nativeWindow) {
return;
}
const dialogOpts = {
title: t(i18n, ["prompt.install_location_add.title"]),
// crazy typescript workaround, avert your eyes
properties: ["openDirectory", "createDirectory"] as (
| "openDirectory"
| "createDirectory")[],
};
const promise = new ItchPromise<string>((resolve, reject) => {
const callback = (response: string[]) => {
if (!response) {
return resolve();
}
return resolve(response[0]);
};
dialog.showOpenDialog(nativeWindow, dialogOpts, callback);
});
const path = await promise;
if (path) {
await call(messages.InstallLocationsAdd, { path });
store.dispatch(actions.installLocationsChanged({}));
}
});
示例2: async
watcher.on(actions.removeInstallLocation, async (store, action) => {
const { id } = action.payload;
const { installLocations } = await mcall(messages.InstallLocationsList, {});
if (installLocations.length <= 1) {
// refuse to remove the last one
return;
}
const { installLocation } = await mcall(messages.InstallLocationsGetByID, {
id,
});
if (!installLocation) {
return;
}
{
const res = await promisedModal(
store,
modals.naked.make({
wind: "root",
title: ["prompt.install_location_remove.title"],
message: ["prompt.install_location_remove.message"],
detail: [
"prompt.install_location_remove.detail",
{
location: installLocation.path,
},
],
buttons: [
{
label: ["prompt.action.confirm_removal"],
action: actions.modalResponse({}),
},
"cancel",
],
widgetParams: null,
})
);
if (!res) {
// modal was closed
return;
}
const logger = recordingLogger(mainLogger);
try {
await mcall(messages.InstallLocationsRemove, { id }, convo => {
hookLogging(convo, logger);
});
store.dispatch(actions.installLocationsChanged({}));
} catch (e) {
store.dispatch(
actions.openModal(
modals.showError.make({
wind: "root",
title: _("prompt.show_error.generic_message"),
message: t(store.getState().i18n, formatError(e)),
widgetParams: {
rawError: e,
log: logger.getLog(),
forceDetails: true,
},
buttons: ["ok"],
})
)
);
}
}
});