UNPKG

552 BPlain TextView Raw
1import { ROARR_VERSION } from '../config';
2import { type RoarrGlobalState } from '../types';
3import compareSemver from 'semver-compare';
4
5export const createRoarrInitialGlobalStateBrowser = (
6 currentState: any,
7): RoarrGlobalState => {
8 const versions = (currentState.versions || []).concat();
9
10 if (versions.length > 1) {
11 versions.sort(compareSemver);
12 }
13
14 if (!versions.includes(ROARR_VERSION)) {
15 versions.push(ROARR_VERSION);
16 }
17
18 versions.sort(compareSemver);
19
20 return {
21 sequence: 0,
22 ...currentState,
23 versions,
24 };
25};