* Fixing EventEmitter import
+ More safety checks in Cache.update_channels
This commit is contained in:
parent
3472e4d7c7
commit
68198cd300
@ -1,4 +1,5 @@
|
|||||||
import * as EventEmitter from 'events'; // unused for now but maybe useful later
|
import { EventEmitter } from 'events';
|
||||||
|
//import * as EventEmitter from 'events'; // unused for now but maybe useful later
|
||||||
import { ServerConfig, Message, Channel } from './types';
|
import { ServerConfig, Message, Channel } from './types';
|
||||||
import { Event } from './events';
|
import { Event } from './events';
|
||||||
|
|
||||||
@ -46,7 +47,7 @@ class ServerCache {
|
|||||||
export class Cache extends EventEmitter {
|
export class Cache extends EventEmitter {
|
||||||
// hostname -> Cache
|
// hostname -> Cache
|
||||||
private servers: Map<String, ServerCache>
|
private servers: Map<String, ServerCache>
|
||||||
public active_host: String
|
public active_host: String|null
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super()
|
super()
|
||||||
@ -61,7 +62,8 @@ export class Cache extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
update_channels(hostname: String, channels: Array<Channel>) : void {
|
update_channels(hostname: String, channels: Array<Channel>) : void {
|
||||||
this.servers.get(hostname).channels = channels
|
let ref = this.servers.get(hostname)
|
||||||
|
if(ref != undefined) { ref.channels = channels }
|
||||||
}
|
}
|
||||||
|
|
||||||
last_id(hostname: String, channel_id: BigInt) : BigInt|null {
|
last_id(hostname: String, channel_id: BigInt) : BigInt|null {
|
||||||
|
Loading…
Reference in New Issue
Block a user