Skip to content

Commit

Permalink
fix: Исправлен асинхронный сбор меты background_apps
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeniysemin committed Dec 12, 2021
1 parent a8a53d1 commit c3573ff
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/assistantSdk/assistant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,13 @@ export const createAssistant = ({ getMeta, ...configuration }: VpsConfiguration
};

const getBackgroundAppsMeta = async () => {
const backgroundAppsIds = Object.keys(backgroundApps);
const apps = { ...backgroundApps };
const backgroundAppsIds = Object.keys(apps);
const backgroundAppsMeta: { app_info: AppInfo; state: Record<string, unknown> }[] = [];

await Promise.allSettled(
backgroundAppsIds.map(async (applicationId) => {
const { getState = null } = backgroundApps[applicationId];
const { getState = null } = apps[applicationId];

return typeof getState === 'function'
? promiseTimeout(getState(), STATE_UPDATE_TIMEOUT).catch(() => ({}))
Expand All @@ -163,7 +164,7 @@ export const createAssistant = ({ getMeta, ...configuration }: VpsConfiguration
const applicationId = backgroundAppsIds[index];

backgroundAppsMeta.push({
app_info: backgroundApps[applicationId].appInfo,
app_info: apps[applicationId].appInfo,
state,
});
});
Expand Down

0 comments on commit c3573ff

Please sign in to comment.