当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript mcall.mcall函数代码示例

本文整理汇总了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);
  });
开发者ID:itchio,项目名称:itch,代码行数:34,代码来源:updater.ts

示例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,
          })
        )
      );
    }
  });
开发者ID:itchio,项目名称:itch,代码行数:53,代码来源:manage-game.ts

示例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,
        })
      )
    );
  });
开发者ID:itchio,项目名称:itch,代码行数:51,代码来源:queue-game.ts

示例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 })
    );
  }
}
开发者ID:itchio,项目名称:itch,代码行数:48,代码来源:setup.ts

示例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}`);
        }
      },
开发者ID:itchio,项目名称:itch,代码行数:31,代码来源:queue-cave-uninstall.ts

示例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 };
              }
            );
          }
        );
      },
开发者ID:itchio,项目名称:itch,代码行数:30,代码来源:switch-version-cave.ts

示例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,
  });
}
开发者ID:itchio,项目名称:itch,代码行数:25,代码来源:commons.ts

示例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,
        })
      )
    );
  });
开发者ID:itchio,项目名称:itch,代码行数:35,代码来源:request-cave-uninstall.ts

示例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}`);
        }
      });
开发者ID:itchio,项目名称:itch,代码行数:27,代码来源:register-itch-protocol.ts


注:本文中的main/butlerd/mcall.mcall函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。