chore: upgrade deps
This commit is contained in:
@@ -95,7 +95,9 @@ export class PreferencesMenu {
|
||||
|
||||
private loadLatestVersions(): void {
|
||||
ExtensionsLatestVersions.load(this.application).then((versions) => {
|
||||
this._extensionLatestVersions = versions;
|
||||
if (versions) {
|
||||
this._extensionLatestVersions = versions;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import { WebApplication } from '@/ui_models/application';
|
||||
import { AppState } from '@/ui_models/app_state';
|
||||
import { observer } from 'mobx-react-lite';
|
||||
import { STRING_REMOVE_OFFLINE_KEY_CONFIRMATION } from '@/strings';
|
||||
import { ButtonType } from '@standardnotes/snjs';
|
||||
import { ButtonType, ClientDisplayableError } from '@standardnotes/snjs';
|
||||
import { HorizontalSeparator } from '@/components/shared/HorizontalSeparator';
|
||||
|
||||
interface IProps {
|
||||
@@ -49,8 +49,8 @@ export const OfflineSubscription: FunctionalComponent<IProps> = observer(
|
||||
activationCode
|
||||
);
|
||||
|
||||
if (result?.error) {
|
||||
await application.alertService.alert(result.error);
|
||||
if (result instanceof ClientDisplayableError) {
|
||||
await application.alertService.alert(result.text);
|
||||
} else {
|
||||
setIsSuccessfullyActivated(true);
|
||||
setHasUserPreviouslyStoredCode(true);
|
||||
|
||||
@@ -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!);
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
StreamingFileSaver,
|
||||
ClassicFileSaver,
|
||||
} from '@standardnotes/filepicker';
|
||||
import { SNFile } from '@standardnotes/snjs';
|
||||
import { ClientDisplayableError, SNFile } from '@standardnotes/snjs';
|
||||
import { addToast, dismissToast, ToastType } from '@standardnotes/stylekit';
|
||||
|
||||
import { WebApplication } from '../application';
|
||||
@@ -87,6 +87,15 @@ export class FilesState {
|
||||
for (const file of selectedFiles) {
|
||||
const operation = await this.application.files.beginNewFileUpload();
|
||||
|
||||
if (operation instanceof ClientDisplayableError) {
|
||||
addToast({
|
||||
type: ToastType.Error,
|
||||
message: `Unable to start upload session`,
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const onChunk = async (
|
||||
chunk: Uint8Array,
|
||||
index: number,
|
||||
@@ -116,6 +125,15 @@ export class FilesState {
|
||||
{ name: fileResult.name, mimeType: fileResult.mimeType }
|
||||
);
|
||||
|
||||
if (uploadedFile instanceof ClientDisplayableError) {
|
||||
addToast({
|
||||
type: ToastType.Error,
|
||||
message: `Unable to close upload session`,
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
uploadedFiles.push(uploadedFile);
|
||||
|
||||
dismissToast(toastId);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import {
|
||||
ApplicationEvent,
|
||||
ClientDisplayableError,
|
||||
convertTimestampToMilliseconds,
|
||||
} from '@standardnotes/snjs';
|
||||
import { action, computed, makeObservable, observable } from 'mobx';
|
||||
@@ -99,7 +100,7 @@ export class SubscriptionState {
|
||||
private async getAvailableSubscriptions() {
|
||||
try {
|
||||
const subscriptions = await this.application.getAvailableSubscriptions();
|
||||
if (subscriptions) {
|
||||
if (!(subscriptions instanceof ClientDisplayableError)) {
|
||||
this.setAvailableSubscriptions(subscriptions);
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -110,7 +111,7 @@ export class SubscriptionState {
|
||||
private async getSubscription() {
|
||||
try {
|
||||
const subscription = await this.application.getUserSubscription();
|
||||
if (subscription) {
|
||||
if (!(subscription instanceof ClientDisplayableError)) {
|
||||
this.setUserSubscription(subscription);
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user