-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #277 from sos-lapsikyla/felix/minimum-version-hand…
…ling Minimum version handling
- Loading branch information
Showing
18 changed files
with
299 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import * as t from 'io-ts'; | ||
import * as TE from 'fp-ts/lib/TaskEither'; | ||
|
||
import * as http from '../lib/http'; | ||
|
||
import * as config from './config'; | ||
import * as authApi from './auth'; | ||
import { ValidVersion } from '../lib/validators'; | ||
|
||
const client = t.strict({ | ||
client: t.string, | ||
version: ValidVersion, | ||
}); | ||
|
||
type Client = t.TypeOf<typeof client>; | ||
|
||
const clientVersions = t.array(client); | ||
|
||
const versionsResponse = t.strict({ | ||
resources: clientVersions, | ||
}); | ||
|
||
export type AppClient = { | ||
client: string; | ||
major: number; | ||
minor: number; | ||
patch: number; | ||
}; | ||
|
||
export const toAppClient = (value: Client): AppClient => { | ||
const [major, minor, patch] = value.version.split('.').map(Number); | ||
|
||
return { | ||
client: value.client, | ||
major, | ||
minor, | ||
patch, | ||
}; | ||
}; | ||
|
||
export const fetchVersions = ( | ||
token: authApi.AccessToken, | ||
): TE.TaskEither<string, Array<AppClient>> => | ||
http.validateResponse( | ||
http.get(`${config.baseUrl}/version/clients`, { | ||
headers: authApi.authHeader(token), | ||
}), | ||
versionsResponse, | ||
response => response.resources.map(toAppClient), | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,16 @@ | ||
import RN from 'react-native'; | ||
import { PlatformOSType } from 'react-native/types'; | ||
import Device from 'react-native-device-info'; | ||
import { toAppClient } from '../api/minimumVersion'; | ||
|
||
export const isDevice = (platform: PlatformOSType) => | ||
platform === RN.Platform.OS; | ||
|
||
export const hasNotch = () => Device.hasNotch(); | ||
|
||
export const getClient = () => { | ||
const version = Device.getVersion(); | ||
const client = RN.Platform.OS === 'android' ? 'ylitse_android' : 'ylitse_ios'; | ||
|
||
return toAppClient({ version, client }); | ||
}; |
Oops, something went wrong.