Add default connection profiles

This commit is contained in:
Thomas Nordquist
2019-02-16 18:04:40 +01:00
parent 93ea829987
commit ef6946bdd4
2 changed files with 13 additions and 7 deletions

View File

@@ -13,6 +13,12 @@ const storedConnectionsIdentifier: StorageIdentifier<{[s: string]: ConnectionOpt
} }
export const loadConnectionSettings = () => (dispatch: Dispatch<any>, getState: () => AppState) => { export const loadConnectionSettings = () => (dispatch: Dispatch<any>, getState: () => AppState) => {
const requiresMigration = true
if (requiresMigration) {
const connections = defaultConnections()
persistantStorage.store(storedConnectionsIdentifier, connections)
}
const connections = persistantStorage.load(storedConnectionsIdentifier) const connections = persistantStorage.load(storedConnectionsIdentifier)
if (!connections) { if (!connections) {
return return

View File

@@ -55,28 +55,28 @@ export function createEmptyConnection(): ConnectionOptions {
} }
export function defaultConnections() { export function defaultConnections() {
return [ return {
{ 'iot.eclipse.org': {
...createEmptyConnection(), ...createEmptyConnection(),
id: 'iot.eclipse.org', id: 'iot.eclipse.org',
name: 'iot.eclipse.org', name: 'iot.eclipse.org',
host: 'iot.eclipse.org', host: 'iot.eclipse.org',
}, },
{ 'test.mosquitto.org': {
...createEmptyConnection(), ...createEmptyConnection(),
id: 'test.mosquitto.org', id: 'test.mosquitto.org',
name: 'test.mosquitto.org', name: 'test.mosquitto.org',
host: 'test.mosquitto.org', host: 'test.mosquitto.org',
}, },
{ 'broker.hivemq.com:8000': {
...createEmptyConnection(), ...createEmptyConnection(),
id: 'wss://broker.hivemq.com:8000/mqtt', id: 'broker.hivemq.com:8000',
name: 'broker.hivemq.com', name: 'broker.hivemq.com',
host: 'broker.hivemq.com', host: 'broker.hivemq.com',
basePath: 'mqtt', basePath: 'ws',
encryption: true, encryption: true,
protocol: 'ws', protocol: 'ws',
port: 8000, port: 8000,
}, },
] }
} }