Feature/improve onboarding for ios (#1035)

* Improve onboarding for iOS

* Update changelog
pull/1036/head
Thomas Kaul 2 years ago committed by GitHub
parent 928a13310d
commit df6bb489c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## Unreleased
### Changed
- Improved the onboarding for iOS
## 1.162.0 - 18.06.2022
### Added

@ -32,7 +32,7 @@ import {
PortfolioSummary,
User
} from '@ghostfolio/common/interfaces';
import { permissions } from '@ghostfolio/common/permissions';
import { filterGlobalPermissions } from '@ghostfolio/common/permissions';
import { DateRange } from '@ghostfolio/common/types';
import { DataSource, Order as OrderModel } from '@prisma/client';
import { parseISO } from 'date-fns';
@ -115,12 +115,14 @@ export class DataService {
public fetchInfo(): InfoItem {
const info = cloneDeep((window as any).info);
const utmSource = <'ios' | 'trusted-web-activity'>(
window.localStorage.getItem('utm_source')
);
if (window.localStorage.getItem('utm_source') === 'trusted-web-activity') {
info.globalPermissions = info.globalPermissions.filter(
(permission) => permission !== permissions.enableSubscription
);
}
info.globalPermissions = filterGlobalPermissions(
info.globalPermissions,
utmSource
);
return info;
}

@ -3,7 +3,7 @@ import { LOCALE_ID } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { locale } from '@ghostfolio/common/config';
import { InfoItem } from '@ghostfolio/common/interfaces';
import { permissions } from '@ghostfolio/common/permissions';
import { filterGlobalPermissions } from '@ghostfolio/common/permissions';
import { AppModule } from './app/app.module';
import { environment } from './environments/environment';
@ -11,12 +11,14 @@ import { environment } from './environments/environment';
(async () => {
const response = await fetch('/api/v1/info');
const info: InfoItem = await response.json();
const utmSource = <'ios' | 'trusted-web-activity'>(
window.localStorage.getItem('utm_source')
);
if (window.localStorage.getItem('utm_source') === 'trusted-web-activity') {
info.globalPermissions = info.globalPermissions.filter(
(permission) => permission !== permissions.enableSubscription
);
}
info.globalPermissions = filterGlobalPermissions(
info.globalPermissions,
utmSource
);
(window as any).info = info;

@ -73,6 +73,28 @@ export function getPermissions(aRole: Role): string[] {
}
}
export function filterGlobalPermissions(
aGlobalPermissions: string[],
aUtmSource: 'ios' | 'trusted-web-activity'
) {
const globalPermissions = aGlobalPermissions;
if (aUtmSource === 'ios') {
return globalPermissions.filter((permission) => {
return (
permission !== permissions.enableSocialLogin &&
permission !== permissions.enableSubscription
);
});
} else if (aUtmSource === 'trusted-web-activity') {
return globalPermissions.filter((permission) => {
return permission !== permissions.enableSubscription;
});
}
return globalPermissions;
}
export function hasPermission(
aPermissions: string[] = [],
aPermission: string

Loading…
Cancel
Save