Files
standardnotes-app-web/packages/snjs/lib/Application/Platforms.ts
Karol Sójko 55b1409a80 feat: add subscription manager to handle subscription sharing (#1517)
* feat: add subscription manager to handle subscription sharing

* fix(services): add missing methods to the interface

* fix(services): add subscription manager specs

* feat(snjs): add subscriptions e2e tests

* fix(snjs): add wait in subscription cancelling test

* fix(snjs): checking for canceled invitations in tests

* fix(snjs): add e2e test for restored limit of subscription invitations

* chore(lint): fix linter issues
2022-09-13 10:28:11 +02:00

58 lines
1.7 KiB
TypeScript

import { Environment, Platform } from '@standardnotes/models'
export function platformFromString(string: string) {
const map: Record<string, Platform> = {
'mac-web': Platform.MacWeb,
'mac-desktop': Platform.MacDesktop,
'linux-web': Platform.LinuxWeb,
'linux-desktop': Platform.LinuxDesktop,
'windows-web': Platform.WindowsWeb,
'windows-desktop': Platform.WindowsDesktop,
ios: Platform.Ios,
android: Platform.Android,
}
return map[string]
}
export function platformToString(platform: Platform) {
const map = {
[Platform.MacWeb]: 'mac-web',
[Platform.MacDesktop]: 'mac-desktop',
[Platform.LinuxWeb]: 'linux-web',
[Platform.LinuxDesktop]: 'linux-desktop',
[Platform.WindowsWeb]: 'windows-web',
[Platform.WindowsDesktop]: 'windows-desktop',
[Platform.Ios]: 'ios',
[Platform.Android]: 'android',
}
return map[platform]
}
export function environmentFromString(string: string) {
const map: Record<string, Environment> = {
web: Environment.Web,
desktop: Environment.Desktop,
mobile: Environment.Mobile,
nativeMobileWeb: Environment.NativeMobileWeb,
}
return map[string]
}
export function environmentToString(environment: Environment) {
const map = {
[Environment.Web]: 'web',
[Environment.Desktop]: 'desktop',
[Environment.Mobile]: 'mobile',
[Environment.NativeMobileWeb]: 'native-mobile-web',
}
return map[environment]
}
export function isEnvironmentWebOrDesktop(environment: Environment) {
return environment === Environment.Web || environment === Environment.Desktop
}
export function isEnvironmentMobile(environment: Environment) {
return environment === Environment.Mobile
}