Properly returning no description if the channel description is empty

master
WolverinDEV 2021-04-25 11:52:03 +02:00
parent 4c1774a394
commit b9f23ca6cc
3 changed files with 10 additions and 10 deletions

View File

@ -346,10 +346,15 @@ export class ChannelEntry extends ChannelTreeEntry<ChannelEvents> {
}
}
if(!this.properties.channel_description) {
return { status: "empty" };
}
return {
status: "success",
description: this.properties.channel_description
}
description: this.properties.channel_description,
handlerId: this.channelTree.client.handlerId
};
}
isDescriptionCached() {

View File

@ -1,6 +1,8 @@
export type ChannelDescriptionResult = {
status: "success",
description: string,
/* The handler id is required for BBCode renderers */
handlerId: string
} | {
status: "empty"

View File

@ -112,14 +112,7 @@ class Controller {
}));
this.variables.setVariableProvider("password", () => this.channel.properties.channel_flag_password);
this.variables.setVariableProvider("topic", () => this.channel.properties.channel_topic);
this.variables.setVariableProvider("description", async () => {
const result = _.cloneDeep(await this.channel.getChannelDescription(false));
if(result.status === "success") {
result.handlerId = this.channel.channelTree.client.handlerId;
return result;
}
return result;
});
this.variables.setVariableProvider("description", async () => await this.channel.getChannelDescription(false));
this.events.on("action_reload_description", () => {
this.channel.clearDescriptionCache();