本文整理汇总了TypeScript中main/butlerd/mcall.mcall函数的典型用法代码示例。如果您正苦于以下问题:TypeScript mcall函数的具体用法?TypeScript mcall怎么用?TypeScript mcall使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mcall函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: async
watcher.on(actions.checkForGameUpdate, async (store, action) => {
const { caveId } = action.payload;
logger.info(`Looking for updates for cave ${caveId}`);
const { cave } = await mcall(messages.FetchCave, { caveId });
let res: CheckUpdateResult;
try {
// cf. https://github.com/itchio/itch/issues/2128
await mcall(messages.CavesSetPinned, {
caveId,
pinned: false,
});
res = await mcall(messages.CheckUpdate, {
caveIds: [caveId],
verbose: true,
});
} catch (e) {
logger.error(`While checking for game update: ${e.stack}`);
if (!res) {
res = {
updates: [],
warnings: [String(e)],
};
}
}
if (res && !isEmpty(res.updates)) {
for (const update of res.updates) {
store.dispatch(actions.gameUpdateAvailable({ update }));
}
}
dispatchUpdateNotification(store, cave, res);
});
示例2: async
watcher.on(actions.manageGame, async (store, action) => {
const { game } = action.payload;
const caves = (await mcall(messages.FetchCaves, {
filters: { gameId: game.id },
})).items;
const widgetParams: ManageGameParams = {
game,
caves,
allUploads: [],
loadingUploads: true,
};
const openModal = actions.openModal(
modals.manageGame.make({
wind: "root",
title: game.title,
message: "",
buttons: [
{
label: ["prompt.action.close"],
className: "secondary",
},
],
widgetParams,
})
);
store.dispatch(openModal);
const modalId = openModal.payload.id;
try {
try {
const { uploads } = await mcall(messages.GameFindUploads, { game });
widgetParams.allUploads = uploads;
} catch (e) {
console.log(`Could not fetch compatible uploads: ${e.stack}`);
}
} catch (e) {
logger.warn(`could not list uploads: ${e.message}`);
} finally {
widgetParams.loadingUploads = false;
store.dispatch(
actions.updateModalWidgetParams(
modals.manageGame.update({
id: modalId,
widgetParams,
})
)
);
}
});
示例3: async
watcher.on(actions.queueGame, async (store, action) => {
const { game, caveId } = action.payload;
let caves: Cave[];
if (caveId) {
const { cave } = await mcall(messages.FetchCave, { caveId });
if (cave) {
caves = [cave];
}
} else {
caves = (await mcall(messages.FetchCaves, {
filters: { gameId: game.id },
})).items;
}
if (isEmpty(caves)) {
logger.info(
`No cave for ${game.title} (#${game.id}), attempting install`
);
await queueInstall(store, game);
return;
}
logger.info(
`Have ${caves.length} caves for game ${game.title} (#${game.id})`
);
if (caves.length === 1) {
const cave = caves[0];
store.dispatch(actions.queueLaunch({ cave }));
return;
}
store.dispatch(
actions.openModal(
modals.naked.make({
wind: "root",
title: ["prompt.launch.title", { title: game.title }],
message: ["prompt.launch.message"],
bigButtons: map(caves, cave => {
return {
...makeUploadButton(cave.upload),
action: actions.queueLaunch({ cave }),
};
}),
buttons: ["cancel"],
widgetParams: null,
})
)
);
});
示例4: syncInstallLocations
async function syncInstallLocations(store: Store) {
const { installLocations } = await mcall(messages.InstallLocationsList, {});
const newLocationsById = indexBy(installLocations, "id");
const { preferences } = store.getState();
if (!preferences.importedOldInstallLocations) {
await mkdirp(appdataLocationPath());
let oldLocations = {
...preferences.installLocations,
appdata: {
id: "appdata",
path: appdataLocationPath(),
},
} as { [key: string]: { id: string; path: string } };
let numAdded = 0;
if (!isEmpty(oldLocations)) {
for (const id of Object.keys(oldLocations)) {
logger.debug(`Checking install location ${id}...`);
const oldLoc = oldLocations[id];
const newLoc = newLocationsById[id];
if (newLoc) {
logger.debug(`Has on butler side too!`);
} else {
logger.debug(`Synchronizing ${id}...`);
numAdded++;
try {
await mcall(messages.InstallLocationsAdd, {
id,
path: oldLoc.path,
});
} catch (e) {
logger.warn(`Could not add ${oldLoc.path}: ${e.stack}`);
}
}
}
}
if (numAdded > 0) {
logger.info(`Registered ${numAdded} install locations with butler`);
} else {
logger.info(`All install locations synchronized with butler`);
}
store.dispatch(
actions.updatePreferences({ importedOldInstallLocations: true })
);
}
}
示例5: 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}`);
}
},
示例6: async
work: async (ctx, logger) => {
await mcall(
messages.InstallVersionSwitchQueue,
{ caveId: cave.id },
client => {
client.on(
messages.InstallVersionSwitchPick,
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 };
}
);
}
);
},
示例7: updateCommonsNowThrows
async function updateCommonsNowThrows(store: Store) {
if (!store.getState().setup.done) {
return;
}
const { caves, downloadKeys, installLocations } = await mcall(
messages.FetchCommons,
{}
);
let locationSizes: { [key: string]: number } = {};
if (!isEmpty(installLocations)) {
for (const x of installLocations) {
locationSizes[x.id] = x.sizeInfo.installedSize;
}
}
push(store, {
caves: indexBy(caves, "id"),
caveIdsByGameId: groupIdBy(caves, "gameId"),
downloadKeys: indexBy(downloadKeys, "id"),
downloadKeyIdsByGameId: groupIdBy(downloadKeys, "gameId"),
locationSizes,
});
}
示例8: async
watcher.on(actions.requestCaveUninstall, async (store, action) => {
const { caveId } = action.payload;
const { cave } = await mcall(messages.FetchCave, { caveId });
const { game } = cave;
// FIXME: i18n - plus, that's generally bad
const title = game ? game.title : "this";
store.dispatch(
actions.openModal(
modals.naked.make({
wind: "root",
title: "",
message: ["prompt.uninstall.message", { title }],
buttons: [
{
label: ["prompt.uninstall.reinstall"],
id: "modal-reinstall",
action: actions.queueCaveReinstall({ caveId }),
icon: "repeat",
},
{
label: ["prompt.uninstall.uninstall"],
id: "modal-uninstall",
action: actions.queueCaveUninstall({ caveId }),
icon: "uninstall",
},
"cancel",
],
widgetParams: null,
})
)
);
});
示例9: doAsync
doAsync(async () => {
try {
const dkIdString = details.responseHeaders["X-Itch-Download-Key-Id"];
const pIdString =
details.responseHeaders["X-Itch-Download-Key-Owner-Id"];
if (dkIdString && pIdString) {
const downloadKeyId = parseInt(dkIdString, 10);
const profileId = parseInt(pIdString, 10);
const { downloadKeys } = store.getState().commons;
logger.info(
`Visiting download key page, has key ${downloadKeyId} (owner ${profileId})`
);
if (!downloadKeys[downloadKeyId]) {
logger.info(`That's a new key, fetching...`);
await mcall(messages.FetchDownloadKey, {
downloadKeyId,
profileId,
});
store.dispatch(actions.ownedKeysFetched({}));
}
}
} catch (e) {
logger.warn(`While sniffing headers: ${e.stack}`);
}
});