本文整理汇总了TypeScript中common/actions.actions.updatePreferences方法的典型用法代码示例。如果您正苦于以下问题:TypeScript actions.updatePreferences方法的具体用法?TypeScript actions.updatePreferences怎么用?TypeScript actions.updatePreferences使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common/actions.actions
的用法示例。
在下文中一共展示了actions.updatePreferences方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: async
watcher.on(actions.makeInstallLocationDefault, async (store, action) => {
const { id } = action.payload;
store.dispatch(
actions.updatePreferences({
defaultInstallLocation: id,
})
);
store.dispatch(actions.installLocationsChanged({}));
});
示例2: async
watcher.on(actions.clearFilters, async (store, action) => {
store.dispatch(
actions.updatePreferences({
onlyCompatibleGames: false,
onlyInstalledGames: false,
onlyOwnedGames: false,
})
);
});
示例3: t
nativeWindow.on("close", (e: any) => {
const rs = store.getState();
if (wind === "root") {
const prefs =
rs.preferences || ({ closeToTray: true } as PreferencesState);
let { closeToTray } = prefs;
if (rs.system.macos) {
closeToTray = true;
}
if (env.integrationTests) {
// always let app close in testing
closeToTray = false;
}
if (store.getState().system.quitting) {
logger.debug("On window.close: quitting, letting it close");
return;
}
if (closeToTray) {
logger.debug("On window.close: close to tray enabled");
} else {
logger.debug("On window.close: close to tray disabled, quitting!");
process.nextTick(() => {
store.dispatch(actions.quit({}));
});
return;
}
// hide, never destroy
e.preventDefault();
nativeWindow.hide();
if (!prefs.gotMinimizeNotification && !store.getState().system.macos) {
store.dispatch(
actions.updatePreferences({
gotMinimizeNotification: true,
})
);
const i18n = store.getState().i18n;
store.dispatch(
actions.notify({
title: t(i18n, ["notification.see_you_soon.title"]),
body: t(i18n, ["notification.see_you_soon.message"]),
})
);
}
} else {
store.dispatch(actions.windClosed({ wind }));
}
});
示例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: t
nativeWindow.on("close", (e: any) => {
const prefs = store.getState().preferences || { closeToTray: true };
let { closeToTray } = prefs;
if (env.integrationTests) {
// always let app close in testing
closeToTray = false;
}
if (closeToTray) {
logger.debug("Close to tray enabled");
} else {
logger.debug("Close to tray disabled, quitting!");
process.nextTick(() => {
store.dispatch(actions.quit({}));
});
return;
}
if (!nativeWindow.isVisible()) {
logger.info("Main window hidden, letting it close");
return;
}
if (!prefs.gotMinimizeNotification) {
store.dispatch(
actions.updatePreferences({
gotMinimizeNotification: true,
})
);
const i18n = store.getState().i18n;
store.dispatch(
actions.notify({
title: t(i18n, ["notification.see_you_soon.title"]),
body: t(i18n, ["notification.see_you_soon.message"]),
})
);
}
// hide, never destroy
e.preventDefault();
logger.info("Hiding main window");
nativeWindow.hide();
});
示例6: async
watcher.on(actions.addInstallLocation, async (store, action) => {
const { wind } = action.payload;
const i18n = store.getState().i18n;
const nativeWindow = getNativeWindow(store.getState(), wind);
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) {
const { installLocation } = await mcall(
messages.InstallLocationsAdd,
{ path },
convo => {
hookLogging(convo, logger);
}
);
store.dispatch(
actions.updatePreferences({
defaultInstallLocation: installLocation.id,
})
);
store.dispatch(actions.installLocationsChanged({}));
store.dispatch(actions.silentlyScanInstallLocations({}));
}
});
示例7: loadPreferences
async function loadPreferences(store: Store) {
const prefs = loadPreferencesSync();
store.dispatch(actions.updatePreferences(prefs));
store.dispatch(actions.preferencesLoaded(prefs));
}
示例8: initialSetup
async function initialSetup(store: Store, { retry }: { retry: boolean }) {
try {
logger.info(`Setup starting...`);
store.dispatch(
actions.setupStatus({
icon: "install",
message: ["login.status.finalizing_installation"],
})
);
if (!manager) {
logger.info(`Creating broth manager`);
manager = new Manager(store);
}
const prefs = store.getState().preferences;
const setUpVersionOnceBefore =
app.getVersion() === prefs.lastSuccessfulSetupVersion;
logger.info(`Ensuring broth dependencies, for startup`);
await manager.ensure({
startup: true,
logger,
});
if (env.development) {
logger.info(`In development, forcing components upgrade check`);
await manager.upgrade({ logger });
} else if (!setUpVersionOnceBefore) {
logger.info(
`Never set up ${app.getVersion()} successfully before, forcing components upgrade check`
);
await manager.upgrade({ logger });
store.dispatch(
actions.updatePreferences({
lastSuccessfulSetupVersion: app.getVersion(),
})
);
} else {
logger.info(
`Already set up ${app.getVersion()} once, delaying components upgrade check`
);
}
logger.debug(`Waiting for butler promise...`);
await Promise.race([
initialButlerdPromise,
new ItchPromise((resolve, reject) => {
setTimeout(() => {
reject(new Error("Timed out while connecting to butlerd"));
}, 5000);
}),
]);
logger.debug(`Syncing install locations...`);
await syncInstallLocations(store);
logger.debug(`Dispatching setup done!`);
store.dispatch(actions.setupDone({}));
logger.info(`Setup done`);
} catch (e) {
logger.error(`setup got error: ${e.stack}`);
if (retry) {
// UX trick #239408: sometimes setup is so fast,
// it does't feel like anything happened,
// so let the user see that we tried.
await delay(1000);
}
store.dispatch(
actions.setupStatus({
icon: "error",
message: ["login.status.setup_failure", { error: e.message || "" + e }],
rawError: e,
log: logger.getLog(),
})
);
}
}