Implemented first elements of short codes list

This commit is contained in:
Alejandro Celaya
2018-06-16 11:24:42 +02:00
parent f4c48bc94f
commit b008c37a5b
10 changed files with 134 additions and 24 deletions

View File

@@ -1,18 +1,10 @@
import ServersService from '../services';
import { LOAD_SERVER } from '../../reducers/types';
import { LIST_SHORT_URLS } from '../../reducers/types';
export default function selectedServerReducer(state = null, action) {
switch (action.type) {
case LOAD_SERVER:
case LIST_SHORT_URLS:
return action.selectedServer;
default:
return state;
}
}
export const loadServer = serverId => {
return {
type: LOAD_SERVER,
selectedServer: ServersService.findServerById(serverId),
};
};

View File

@@ -1,5 +1,4 @@
const PREFIX = 'shlink';
const buildPath = path => `${PREFIX}.${path}`;
import Storage from '../../utils/Storage';
export class ServersService {
constructor(storage) {
@@ -7,7 +6,7 @@ export class ServersService {
}
listServers = () => {
return JSON.parse(this.storage.getItem(buildPath('servers')) || '{}');
return this.storage.get('servers');
};
findServerById = serverId => {
@@ -16,4 +15,4 @@ export class ServersService {
}
}
export default new ServersService(localStorage);
export default new ServersService(Storage);