Пример #1
0
  async work(): Promise<void> {
    // first, filter what we already got
    const cachedGames = getByIds(
      this.space().games().set,
      this.space().games().allIds
    );
    const dataGamesCount = cachedGames.length;

    if (dataGamesCount > 0) {
      this.pushUnfilteredGames(cachedGames);
      if (!this.warrantsRemote()) {
        return;
      }
    }

    const call = withLogger(this.logger);
    await call(
      messages.FetchProfileGames,
      {
        profileId: this.profileId(),
      },
      client => {
        client.on(messages.FetchProfileGamesYield, async ({ items }) => {
          const games = map(items, i => i.game);
          this.pushUnfilteredGames(games);
        });
      }
    );
  }
Пример #2
0
  async work(): Promise<void> {
    const installLocationId = this.space().firstPathElement();

    let call = withLogger(this.logger);

    const { caves, installLocationPath, installLocationSize } = await call(
      messages.FetchCavesByInstallLocationID,
      { installLocationId }
    );

    let games: Game[] = [];
    if (!isEmpty(caves)) {
      for (const c of caves) {
        games.push(c.game);
      }
      games = uniq(games, g => g.id);
    }

    this.pushUnfilteredGames(games, { disableFilters: true });
    this.push({
      location: {
        path: installLocationPath,
        size: installLocationSize,
      },
    });
  }
Пример #3
0
  async work(): Promise<void> {
    let call = withLogger(this.logger);

    // first, filter what we already got
    const cachedGames = getByIds(
      this.space().games().set,
      this.space().games().allIds
    );
    const dataGamesCount = cachedGames.length;

    if (dataGamesCount > 0) {
      this.debug(`Pushing ${dataGamesCount} from cachedGames`);
      this.pushUnfilteredGames(cachedGames);
      if (!this.warrantsRemote()) {
        return;
      }
    }

    let games: Game[] = [];

    const push = () => {
      games = uniq(games, g => g.id);
      this.pushUnfilteredGames(games);
    };

    const { caves } = await call(messages.FetchCaves, {});
    if (caves) {
      for (const cave of caves) {
        games.push(cave.game);
      }
    }

    await call(
      messages.FetchProfileOwnedKeys,
      {
        profileId: this.profileId(),
      },
      client => {
        client.on(messages.FetchProfileOwnedKeysYield, async ({ items }) => {
          if (items) {
            for (const dk of items) {
              games.push(dk.game);
            }
            push();
          }
        });
      }
    );
  }
Пример #4
0
  async work(): Promise<void> {
    if (!this.warrantsRemote()) {
      return;
    }

    const call = withLogger(this.logger);
    await call(
      messages.FetchProfileCollections,
      {
        profileId: this.profileId(),
      },
      client => {
        client.on(messages.FetchProfileCollectionsYield, async ({ items }) => {
          this.push({
            collections: {
              set: indexBy(items, "id"),
              ids: pluck(items, "id"),
            },
          });
        });
      }
    );
  }
Пример #5
0
  async work(): Promise<void> {
    // first, filter what we already got
    const cachedGames = getByIds(
      this.space().games().set,
      this.space().games().allIds
    );
    const dataGamesCount = cachedGames.length;

    if (dataGamesCount > 0) {
      this.pushUnfilteredGames(cachedGames);
      if (!this.warrantsRemote()) {
        return;
      }
    }

    const collectionId = this.space().firstPathNumber();
    const call = withLogger(this.logger);
    await call(
      messages.FetchCollection,
      {
        profileId: this.profileId(),
        collectionId,
      },
      client => {
        client.on(messages.FetchCollectionYield, async ({ collection }) => {
          const games: Game[] = [];
          for (const cg of collection.collectionGames) {
            games.push(cg.game);
          }

          this.pushCollection(collection);
          this.pushUnfilteredGames(games);
        });
      }
    );
  }
Пример #6
0
import { Watcher } from "common/util/watcher";
import { actions } from "common/actions";
import fs from "fs";
import { dirname } from "path";

import rootLogger from "common/logger";
const logger = rootLogger.child({ name: "explore-cave" });

import * as explorer from "../../os/explorer";

import { withLogger, messages } from "common/butlerd";
const call = withLogger(logger);

export default function(watcher: Watcher) {
  watcher.on(actions.exploreCave, async (store, action) => {
    const { caveId } = action.payload;

    const { cave } = await call(messages.FetchCave, { caveId });
    const installFolder = cave.installInfo.installFolder;
    try {
      fs.accessSync(installFolder);
      explorer.open(installFolder);
    } catch (e) {
      explorer.open(dirname(installFolder));
    }
  });
}
Пример #7
0
async function performInstallQueue({
  store,
  logger,
  game,
  upload,
  build,
}: {
  store: IStore;
  logger: Logger;
  game: Game;
  upload: Upload;
  build: Build;
}) {
  const installLocationId = defaultInstallLocation(store);

  await withLogger(logger)(
    messages.InstallQueue,
    {
      game,
      upload,
      build,
      installLocationId,
      queueDownload: true,
    },
    client => {
      client.on(messages.PickUpload, async ({ uploads }) => {
        const { title } = game;

        const modalRes = await promisedModal(
          store,
          modalWidgets.pickUpload.make({
            window: "root",
            title: ["pick_install_upload.title", { title }],
            message: ["pick_install_upload.message", { title }],
            coverUrl: game.coverUrl,
            stillCoverUrl: game.stillCoverUrl,
            bigButtons: map(uploads, (candidate, index) => {
              return {
                ...makeUploadButton(candidate),
                action: modalWidgets.pickUpload.action({
                  pickedUploadIndex: index,
                }),
              };
            }),
            buttons: ["cancel"],
            widgetParams: {},
          })
        );

        if (modalRes) {
          return { index: modalRes.pickedUploadIndex };
        } else {
          // that tells butler to abort
          return { index: -1 };
        }
      });

      client.on(messages.ExternalUploadsAreBad, async () => {
        const modalRes = await promisedModal(
          store,
          modalWidgets.naked.make({
            window: "root",
            title: "Dragons be thar",
            message:
              "You've chosen to install an external upload. Those are supported poorly.",
            detail:
              "There's a chance it won't install at all.\n\nAlso, we won't be able to check for updates.",
            bigButtons: [
              {
                label: "Install it anyway",
                tags: [{ label: "Consequences be damned" }],
                icon: "fire",
                action: actions.modalResponse({}),
              },
              "nevermind",
            ],
            widgetParams: null,
          })
        );

        if (!modalRes) {
          return { whatever: false };
        }

        // ahh damn.
        return { whatever: true };
      });
    }
  );
  store.dispatch(actions.downloadQueued({}));
}