added some translation cleanup
This commit is contained in:
parent
92a3ac6ae3
commit
4a2b408c1b
@ -205,6 +205,10 @@ export class DatabindedTextComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngAfterViewInit() {
|
ngAfterViewInit() {
|
||||||
|
this.processEventBindings();
|
||||||
|
}
|
||||||
|
|
||||||
|
processEventBindings(){
|
||||||
for (const hashtag of this.hashtags) {
|
for (const hashtag of this.hashtags) {
|
||||||
let classname = this.getClassNameForHastag(hashtag);
|
let classname = this.getClassNameForHastag(hashtag);
|
||||||
let els = <Element[]>this.contentElement.nativeElement.querySelectorAll(`.${classname}`);
|
let els = <Element[]>this.contentElement.nativeElement.querySelectorAll(`.${classname}`);
|
||||||
|
@ -109,7 +109,7 @@
|
|||||||
<span class="status__content-warning--title">sensitive content</span>
|
<span class="status__content-warning--title">sensitive content</span>
|
||||||
<span innerHTML="{{ contentWarningText }}"></span>
|
<span innerHTML="{{ contentWarningText }}"></span>
|
||||||
</a>
|
</a>
|
||||||
<app-databinded-text class="status__content" *ngIf="!isContentWarned" [text]="statusContent" [selected]="isSelected"
|
<app-databinded-text #databindedtext class="status__content" *ngIf="!isContentWarned" [text]="statusContent" [selected]="isSelected"
|
||||||
(accountSelected)="accountSelected($event)" (hashtagSelected)="hashtagSelected($event)"
|
(accountSelected)="accountSelected($event)" (hashtagSelected)="hashtagSelected($event)"
|
||||||
(textSelected)="textSelected()"></app-databinded-text>
|
(textSelected)="textSelected()"></app-databinded-text>
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ import { StatusWrapper } from '../../../models/common.model';
|
|||||||
import { EmojiConverter, EmojiTypeEnum } from '../../../tools/emoji.tools';
|
import { EmojiConverter, EmojiTypeEnum } from '../../../tools/emoji.tools';
|
||||||
import { ContentWarningPolicyEnum } from '../../../states/settings.state';
|
import { ContentWarningPolicyEnum } from '../../../states/settings.state';
|
||||||
import { StatusesStateService, StatusState } from "../../../services/statuses-state.service";
|
import { StatusesStateService, StatusState } from "../../../services/statuses-state.service";
|
||||||
|
import { DatabindedTextComponent } from "./databinded-text/databinded-text.component";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: "app-status",
|
selector: "app-status",
|
||||||
@ -107,27 +107,27 @@ export class StatusComponent implements OnInit {
|
|||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.statusesStateServiceSub = this.statusesStateService.stateNotification.subscribe(notification => {
|
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;
|
this.statusWrapper = notification.editedStatus;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy(){
|
ngOnDestroy() {
|
||||||
if(this.statusesStateServiceSub) this.statusesStateServiceSub.unsubscribe();
|
if (this.statusesStateServiceSub) this.statusesStateServiceSub.unsubscribe();
|
||||||
}
|
}
|
||||||
|
|
||||||
private ensureMentionAreDisplayed(data: string): string {
|
private ensureMentionAreDisplayed(data: string): string {
|
||||||
const mentions = this.displayedStatus.mentions;
|
const mentions = this.displayedStatus.mentions;
|
||||||
if(!mentions || mentions.length === 0) return data;
|
if (!mentions || mentions.length === 0) return data;
|
||||||
|
|
||||||
let textMentions = '';
|
let textMentions = '';
|
||||||
for (const m of mentions) {
|
for (const m of mentions) {
|
||||||
if(!data.includes(m.url)){
|
if (!data.includes(m.url)) {
|
||||||
textMentions += `<span class="h-card"><a class="u-url mention" data-user="${m.id}" href="${m.url}" rel="ugc">@<span>${m.username}</span></a></span> `
|
textMentions += `<span class="h-card"><a class="u-url mention" data-user="${m.id}" href="${m.url}" rel="ugc">@<span>${m.username}</span></a></span> `
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(textMentions !== ''){
|
if (textMentions !== '') {
|
||||||
data = textMentions + data;
|
data = textMentions + data;
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
@ -158,8 +158,29 @@ export class StatusComponent implements OnInit {
|
|||||||
this.isContentWarned = cwIsActive;
|
this.isContentWarned = cwIsActive;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ViewChild('databindedtext') public databindedText: DatabindedTextComponent;
|
||||||
|
|
||||||
onTranslation(translation: Translation) {
|
onTranslation(translation: Translation) {
|
||||||
this.statusContent = translation.content;
|
let statusContent = translation.content;
|
||||||
|
|
||||||
|
// clean up a bit some issues (not reliable)
|
||||||
|
while (statusContent.includes('<span>@')) {
|
||||||
|
statusContent = statusContent.replace('<span>@', '@<span>');
|
||||||
|
}
|
||||||
|
while (statusContent.includes('h<span class="invisible">')){
|
||||||
|
statusContent = statusContent.replace('h<span class="invisible">', '<span class="invisible">h');
|
||||||
|
}
|
||||||
|
while (statusContent.includes('<span>#')){
|
||||||
|
statusContent = statusContent.replace('<span>#', '#<span>');
|
||||||
|
}
|
||||||
|
|
||||||
|
statusContent = this.emojiConverter.applyEmojis(this.displayedStatus.emojis, statusContent, EmojiTypeEnum.medium);
|
||||||
|
this.statusContent = this.ensureMentionAreDisplayed(statusContent);
|
||||||
|
|
||||||
|
setTimeout(x => {
|
||||||
|
this.databindedText.processEventBindings();
|
||||||
|
}, 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
private checkLabels(status: Status) {
|
private checkLabels(status: Status) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user