本文整理匯總了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}`);
}
}