diff --git a/src/app/components/stream/status/databinded-text/databinded-text.component.ts b/src/app/components/stream/status/databinded-text/databinded-text.component.ts index 1740bf32..f5de70de 100644 --- a/src/app/components/stream/status/databinded-text/databinded-text.component.ts +++ b/src/app/components/stream/status/databinded-text/databinded-text.component.ts @@ -205,6 +205,10 @@ export class DatabindedTextComponent implements OnInit { } ngAfterViewInit() { + this.processEventBindings(); + } + + processEventBindings(){ for (const hashtag of this.hashtags) { let classname = this.getClassNameForHastag(hashtag); let els = this.contentElement.nativeElement.querySelectorAll(`.${classname}`); diff --git a/src/app/components/stream/status/status.component.html b/src/app/components/stream/status/status.component.html index 9db3c0e2..7257da73 100644 --- a/src/app/components/stream/status/status.component.html +++ b/src/app/components/stream/status/status.component.html @@ -109,7 +109,7 @@ sensitive content - diff --git a/src/app/components/stream/status/status.component.ts b/src/app/components/stream/status/status.component.ts index 8b08b397..6782037f 100644 --- a/src/app/components/stream/status/status.component.ts +++ b/src/app/components/stream/status/status.component.ts @@ -9,7 +9,7 @@ import { StatusWrapper } from '../../../models/common.model'; import { EmojiConverter, EmojiTypeEnum } from '../../../tools/emoji.tools'; import { ContentWarningPolicyEnum } from '../../../states/settings.state'; import { StatusesStateService, StatusState } from "../../../services/statuses-state.service"; - +import { DatabindedTextComponent } from "./databinded-text/databinded-text.component"; @Component({ selector: "app-status", @@ -107,27 +107,27 @@ export class StatusComponent implements OnInit { ngOnInit() { this.statusesStateServiceSub = this.statusesStateService.stateNotification.subscribe(notification => { - if(this._statusWrapper.status.url === notification.statusId && notification.isEdited) { + if (this._statusWrapper.status.url === notification.statusId && notification.isEdited) { this.statusWrapper = notification.editedStatus; } }); } - ngOnDestroy(){ - if(this.statusesStateServiceSub) this.statusesStateServiceSub.unsubscribe(); + ngOnDestroy() { + if (this.statusesStateServiceSub) this.statusesStateServiceSub.unsubscribe(); } - + private ensureMentionAreDisplayed(data: string): string { const mentions = this.displayedStatus.mentions; - if(!mentions || mentions.length === 0) return data; - + if (!mentions || mentions.length === 0) return data; + let textMentions = ''; for (const m of mentions) { - if(!data.includes(m.url)){ + if (!data.includes(m.url)) { textMentions += `@${m.username} ` } } - if(textMentions !== ''){ + if (textMentions !== '') { data = textMentions + data; } return data; @@ -157,9 +157,30 @@ export class StatusComponent implements OnInit { changeCw(cwIsActive: boolean) { this.isContentWarned = cwIsActive; } + + + @ViewChild('databindedtext') public databindedText: DatabindedTextComponent; onTranslation(translation: Translation) { - this.statusContent = translation.content; + let statusContent = translation.content; + + // clean up a bit some issues (not reliable) + while (statusContent.includes('@')) { + statusContent = statusContent.replace('@', '@'); + } + while (statusContent.includes('h