本文整理汇总了TypeScript中common/actions.actions.ownedKeysFetched方法的典型用法代码示例。如果您正苦于以下问题:TypeScript actions.ownedKeysFetched方法的具体用法?TypeScript actions.ownedKeysFetched怎么用?TypeScript actions.ownedKeysFetched使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common/actions.actions
的用法示例。
在下文中一共展示了actions.ownedKeysFetched方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: 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}`);
}
});
示例2: loginSucceeded
async function loginSucceeded(store: Store, profile: Profile) {
logger.info(`Login succeeded, setting up session`);
try {
const userId = profile.id;
const partition = partitionForUser(String(userId));
const customSession = session.fromPartition(partition, { cache: true });
logger.info(`Registering itch protocol for session ${partition}`);
registerItchProtocol(store, customSession);
} catch (e) {
logger.warn(`Could not register itch protocol for session: ${e.stack}`);
}
try {
logger.info(`Restoring tabs...`);
await restoreTabs(store, profile);
} catch (e) {
logger.warn(`Could not restore tabs: ${e.stack}`);
}
logger.info(`Dispatching login succeeded`);
store.dispatch(actions.loginSucceeded({ profile }));
try {
logger.info(`Fetching owned keys...`);
let t1 = Date.now();
await mcall(
messages.FetchProfileOwnedKeys,
{
profileId: profile.id,
fresh: true,
limit: 1,
},
convo => {
hookLogging(convo, logger);
}
);
let t2 = Date.now();
logger.info(`Fetched owned keys in ${elapsed(t1, t2)}`);
store.dispatch(actions.ownedKeysFetched({}));
} catch (e) {
logger.warn(`In initial owned keys fetch: ${e.stack}`);
}
}