當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。