This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/plugins/chat/assets/javascripts/discourse/components/chat-retention-reminder-text.js
Joffrey JAFFEUX 075af7ba84
REFACTOR: channel retention reminder text (#20310)
- Moves logic into one specialised component
- Adds more tests
- Removes duplicate key
- Uses pluralization
- Handles 0 case properly

Co-authored-by: Gerhard Schlager <mail@gerhard-schlager.at>
2023-02-15 14:50:01 +01:00

34 lines
1014 B
JavaScript

import Component from "@glimmer/component";
import I18n from "I18n";
import { inject as service } from "@ember/service";
export default class ChatRetentionReminderText extends Component {
@service siteSettings;
get text() {
if (this.args.channel.isDirectMessageChannel) {
if (this.#countForChannelType > 0) {
return I18n.t("chat.retention_reminders.dm", {
count: this.siteSettings.chat_dm_retention_days,
});
} else {
return I18n.t("chat.retention_reminders.dm_none");
}
} else {
if (this.#countForChannelType > 0) {
return I18n.t("chat.retention_reminders.public", {
count: this.siteSettings.chat_channel_retention_days,
});
} else {
return I18n.t("chat.retention_reminders.public_none");
}
}
}
get #countForChannelType() {
return this.args.channel.isDirectMessageChannel
? this.siteSettings.chat_dm_retention_days
: this.siteSettings.chat_channel_retention_days;
}
}