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) => {
const requiresMigration = true
if (requiresMigration) {
const connections = defaultConnections()
persistantStorage.store(storedConnectionsIdentifier, connections)
}
const connections = persistantStorage.load(storedConnectionsIdentifier)
if (!connections) {
return

View File

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