diff --git a/shared/css/static/channel-tree.scss b/shared/css/static/channel-tree.scss index 630f400e..2f34657d 100644 --- a/shared/css/static/channel-tree.scss +++ b/shared/css/static/channel-tree.scss @@ -98,6 +98,9 @@ justify-content: left; + max-width: 100%; /* important for the repetitive channel name! */ + overflow: hidden; + &.align-right { justify-content: right; } diff --git a/shared/js/ui/channel.ts b/shared/js/ui/channel.ts index eed6675e..4b794681 100644 --- a/shared/js/ui/channel.ts +++ b/shared/js/ui/channel.ts @@ -562,26 +562,38 @@ class ChannelEntry { if(this._channel_name_formatted !== undefined) { tag_container_name.addClass(this._channel_name_alignment); - if(this._channel_name_alignment == "*") { - let lastSuccess = ""; - let index = 6; + if(this._channel_name_alignment == "align-repetitive") { + if(tag_name.parent().width() != 0) { + let lastSuccess = ""; + let index = 6; - let name = this.formattedChannelName(); - while(index-- > 0) - name = name + name; - tag_name.text(name); - do { - tag_name.text(name = name + name); - } while (tag_name.parent().width() >= tag_name.width() && ++index < 64); - if(index == 64) console.warn(LogCategory.CHANNEL, tr("Repeating spacer took too much repeats!")); - if(lastSuccess.length > 0) { - tag_name.text(lastSuccess); + let name = this._channel_name_formatted; + if(name.length < 1) throw "invalid name!"; + + while(index-- > 0) + name = name + name; + tag_name.text(name); + do { + tag_name.text(name = name + name); + if(name.length > 1024 * 8) + index = 63; + } while (tag_name.parent().width() >= tag_name.width() && ++index < 64); + if(index == 64) + console.warn(LogCategory.CHANNEL, tr("Repeating spacer took too much repeats!")); + if(lastSuccess.length > 0) { + tag_name.text(lastSuccess); + } } } } console.log(tr("Align: %s"), this._channel_name_alignment); } + recalculate_repetitive_name() { + if(this._channel_name_alignment == "align-repetitive") + this.__updateChannelName(); + } + updateVariables(...variables: {key: string, value: string}[]) { let group = log.group(log.LogType.DEBUG, LogCategory.CHANNEL_PROPERTIES, tr("Update properties (%i) of %s (%i)"), variables.length, this.channelName(), this.getChannelId()); diff --git a/shared/js/ui/view.ts b/shared/js/ui/view.ts index 5f0dd6cb..fe065ddd 100644 --- a/shared/js/ui/view.ts +++ b/shared/js/ui/view.ts @@ -75,6 +75,8 @@ class ChannelTree { show_channel_tree() { this._tree_detached = false; this.htmlTree.appendTo(this.htmlTree_parent); + + this.channels.forEach(e => e.recalculate_repetitive_name()); } showContextMenu(x: number, y: number, on_close: () => void = undefined) {