chore: upgrade deps

This commit is contained in:
Mo
2022-03-16 15:53:47 -05:00
parent 87480d2ff5
commit 28c08a178f
7 changed files with 151 additions and 113 deletions

View File

@@ -1,33 +1,50 @@
import { WebApplication } from "@/ui_models/application";
import { FeatureDescription } from "@standardnotes/features";
import { SNComponent } from "@standardnotes/snjs/dist/@types";
import { makeAutoObservable, observable } from "mobx";
import { WebApplication } from '@/ui_models/application';
import { FeatureDescription } from '@standardnotes/features';
import { SNComponent, ClientDisplayableError } from '@standardnotes/snjs';
import { makeAutoObservable, observable } from 'mobx';
export class ExtensionsLatestVersions {
static async load(application: WebApplication): Promise<ExtensionsLatestVersions> {
const map = await application.getAvailableSubscriptions()
.then(subscriptions => {
const versionMap: Map<string, string> = new Map();
collectFeatures(subscriptions?.CORE_PLAN?.features as FeatureDescription[], versionMap);
collectFeatures(subscriptions?.PLUS_PLAN?.features as FeatureDescription[], versionMap);
collectFeatures(subscriptions?.PRO_PLAN?.features as FeatureDescription[], versionMap);
return versionMap;
});
return new ExtensionsLatestVersions(map);
static async load(
application: WebApplication
): Promise<ExtensionsLatestVersions | undefined> {
const response = await application.getAvailableSubscriptions();
if (response instanceof ClientDisplayableError) {
return undefined;
}
const versionMap: Map<string, string> = new Map();
collectFeatures(
response.CORE_PLAN?.features as FeatureDescription[],
versionMap
);
collectFeatures(
response.PLUS_PLAN?.features as FeatureDescription[],
versionMap
);
collectFeatures(
response.PRO_PLAN?.features as FeatureDescription[],
versionMap
);
return new ExtensionsLatestVersions(versionMap);
}
constructor(private readonly latestVersionsMap: Map<string, string>) {
makeAutoObservable<ExtensionsLatestVersions, 'latestVersionsMap'>(
this, { latestVersionsMap: observable.ref });
makeAutoObservable<ExtensionsLatestVersions, 'latestVersionsMap'>(this, {
latestVersionsMap: observable.ref,
});
}
getVersion(extension: SNComponent): string | undefined {
return this.latestVersionsMap.get(extension.package_info.identifier);
}
}
function collectFeatures(features: FeatureDescription[] | undefined, versionMap: Map<string, string>) {
function collectFeatures(
features: FeatureDescription[] | undefined,
versionMap: Map<string, string>
) {
if (features == undefined) return;
for (const feature of features) {
versionMap.set(feature.identifier, feature.version!);