fix(core): update

This commit is contained in:
Philipp Kunz 2019-04-22 22:04:52 +02:00
parent 300d62ed12
commit 3d82038ec3
2 changed files with 18 additions and 4 deletions

View File

@ -36,6 +36,12 @@ export class ClientUniverse {
* TODO: verify channel before adding it to the channel cache
*/
public async addChannel (channelNameArg: string, passphraseArg: string) {
const existingChannel = this.getChannel(channelNameArg);
if (existingChannel) {
throw new Error('channel exists');
}
const clientUniverseChannel = await ClientUniverseChannel.createClientUniverseChannel(
this,
channelNameArg,
@ -49,8 +55,11 @@ export class ClientUniverse {
* @param channelName
* @param passphraseArg
*/
public async getChannel(channelName: string, passphraseArg?: string): Promise<ClientUniverseChannel> {
public async getChannel(channelName: string): Promise<ClientUniverseChannel> {
await this.checkConnection();
const clientUniverseChannel = this.channelCache.find(channel => {
return channel.name === channelName;
})
return clientUniverseChannel;
}

View File

@ -21,11 +21,16 @@ export class ClientUniverseChannel implements interfaces.IUniverseChannel {
// INSTANCE
// ========
public clientUniverse: ClientUniverse;
// properties
public name: string;
public passphrase: string;
constructor(clientUniverseArg: ClientUniverse, passphraseArg: string) {
// refs
public clientUniverse: ClientUniverse;
constructor(clientUniverseArg: ClientUniverse, nameArg: string, passphraseArg: string) {
this.clientUniverse = clientUniverseArg;
this.name = nameArg;
this.passphrase = passphraseArg;
}