mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2025-01-09 17:57:26 +03:00
Merge pull request #551 from acelaya-forks/feature/white-screen
Ensured settings migration function does not crash if settings are no…
This commit is contained in:
commit
7794876d7c
2 changed files with 9 additions and 1 deletions
|
@ -1,6 +1,10 @@
|
||||||
import { ShlinkState } from '../../container/types';
|
import { ShlinkState } from '../../container/types';
|
||||||
|
|
||||||
export const migrateDeprecatedSettings = (state: ShlinkState): ShlinkState => {
|
export const migrateDeprecatedSettings = (state: Partial<ShlinkState>): Partial<ShlinkState> => {
|
||||||
|
if (!state.settings) {
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
// The "last180Days" interval had a typo, with a lowercase d
|
// The "last180Days" interval had a typo, with a lowercase d
|
||||||
if ((state.settings.visits?.defaultInterval as any) === 'last180days') {
|
if ((state.settings.visits?.defaultInterval as any) === 'last180days') {
|
||||||
state.settings.visits && (state.settings.visits.defaultInterval = 'last180Days');
|
state.settings.visits && (state.settings.visits.defaultInterval = 'last180Days');
|
||||||
|
|
|
@ -4,6 +4,10 @@ import { ShlinkState } from '../../../src/container/types';
|
||||||
|
|
||||||
describe('settings-helpers', () => {
|
describe('settings-helpers', () => {
|
||||||
describe('migrateDeprecatedSettings', () => {
|
describe('migrateDeprecatedSettings', () => {
|
||||||
|
it('returns object as is if settings are not set', () => {
|
||||||
|
expect(migrateDeprecatedSettings({})).toEqual({});
|
||||||
|
});
|
||||||
|
|
||||||
it('updates settings as expected', () => {
|
it('updates settings as expected', () => {
|
||||||
const state = Mock.of<ShlinkState>({
|
const state = Mock.of<ShlinkState>({
|
||||||
settings: {
|
settings: {
|
||||||
|
|
Loading…
Reference in a new issue