Fix stacking scheduled post loop when reloading
This commit is contained in:
parent
51b104a096
commit
930296973a
1 changed files with 7 additions and 1 deletions
|
@ -40,6 +40,8 @@ export class PostPlugin extends ZeppelinPlugin<IPostPluginConfig> {
|
||||||
protected scheduledPosts: GuildScheduledPosts;
|
protected scheduledPosts: GuildScheduledPosts;
|
||||||
protected logs: GuildLogs;
|
protected logs: GuildLogs;
|
||||||
|
|
||||||
|
private scheduledPostLoopTimeout;
|
||||||
|
|
||||||
onLoad() {
|
onLoad() {
|
||||||
this.savedMessages = GuildSavedMessages.getInstance(this.guildId);
|
this.savedMessages = GuildSavedMessages.getInstance(this.guildId);
|
||||||
this.scheduledPosts = GuildScheduledPosts.getInstance(this.guildId);
|
this.scheduledPosts = GuildScheduledPosts.getInstance(this.guildId);
|
||||||
|
@ -48,6 +50,10 @@ export class PostPlugin extends ZeppelinPlugin<IPostPluginConfig> {
|
||||||
this.scheduledPostLoop();
|
this.scheduledPostLoop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onUnload() {
|
||||||
|
clearTimeout(this.scheduledPostLoopTimeout);
|
||||||
|
}
|
||||||
|
|
||||||
getDefaultOptions(): IPluginOptions<IPostPluginConfig> {
|
getDefaultOptions(): IPluginOptions<IPostPluginConfig> {
|
||||||
return {
|
return {
|
||||||
config: {
|
config: {
|
||||||
|
@ -183,7 +189,7 @@ export class PostPlugin extends ZeppelinPlugin<IPostPluginConfig> {
|
||||||
await this.scheduledPosts.delete(post.id);
|
await this.scheduledPosts.delete(post.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
setTimeout(() => this.scheduledPostLoop(), SCHEDULED_POST_CHECK_INTERVAL);
|
this.scheduledPostLoopTimeout = setTimeout(() => this.scheduledPostLoop(), SCHEDULED_POST_CHECK_INTERVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue