mirror of
https://github.com/bpatrik/pigallery2.git
synced 2024-12-23 01:27:14 +02:00
Messenger handler should override when adding #784
This commit is contained in:
parent
79817820c9
commit
f551509fee
@ -17,7 +17,12 @@ export class ExtensionMessengerHandler implements IExtensionMessengers {
|
||||
addMessenger<C extends Record<string, unknown>>(name: string, config: DynamicConfig[], callbacks: {
|
||||
sendMedia: (config: C, media: MediaDTOWithThPath[]) => Promise<void>
|
||||
}): void {
|
||||
this.extLogger.silly('Adding new Messenger:', name);
|
||||
if (MessengerRepository.Instance.get(name)) {
|
||||
this.extLogger.silly('Messenger already exist. Overriding it:', name);
|
||||
MessengerRepository.Instance.remove({Name: name});
|
||||
} else {
|
||||
this.extLogger.silly('Adding new Messenger:', name);
|
||||
}
|
||||
const em = new ExtensionMessenger(name, config, callbacks);
|
||||
this.messengers.push(em);
|
||||
MessengerRepository.Instance.register(em);
|
||||
|
@ -18,7 +18,7 @@ export class MessengerRepository {
|
||||
return Object.values(this.messengers);
|
||||
}
|
||||
|
||||
remove(m: Messenger<Record<string, unknown>>): void {
|
||||
remove(m: { Name: string }): void {
|
||||
if (!this.messengers[m.Name]) {
|
||||
throw new Error('Messenger does not exist:' + m.Name);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user