take CW length in status char count, fix #122
This commit is contained in:
parent
6c9653f945
commit
8ad9ecb95b
|
@ -20,7 +20,14 @@ import { identifierModuleUrl } from '@angular/compiler';
|
|||
styleUrls: ['./create-status.component.scss']
|
||||
})
|
||||
export class CreateStatusComponent implements OnInit, OnDestroy {
|
||||
title: string;
|
||||
private _title: string;
|
||||
set title(value: string){
|
||||
this._title = value;
|
||||
this.countStatusChar(this.status);
|
||||
}
|
||||
get title(): string {
|
||||
return this._title;
|
||||
}
|
||||
|
||||
private _status: string = '';
|
||||
set status(value: string) {
|
||||
|
@ -108,7 +115,7 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
|
|||
const selectedAccount = accounts.filter(x => x.isSelected)[0];
|
||||
|
||||
const settings = this.toolsService.getAccountSettings(selectedAccount);
|
||||
if(settings.customStatusCharLengthEnabled){
|
||||
if (settings.customStatusCharLengthEnabled) {
|
||||
this.maxCharLength = settings.customStatusCharLength;
|
||||
this.countStatusChar(this.status);
|
||||
} else {
|
||||
|
@ -176,10 +183,18 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
|
|||
const statusExtraChars = this.getMentionExtraChars(status);
|
||||
|
||||
const statusLength = currentStatus.length - statusExtraChars;
|
||||
this.charCountLeft = this.maxCharLength - statusLength;
|
||||
this.charCountLeft = this.maxCharLength - statusLength - this.getCwLength();
|
||||
this.postCounts = parseStatus.length;
|
||||
}
|
||||
|
||||
private getCwLength(): number {
|
||||
let cwLength = 0;
|
||||
if (this.title) {
|
||||
cwLength = this.title.length;
|
||||
}
|
||||
return cwLength;
|
||||
}
|
||||
|
||||
private getMentions(status: Status, providerInfo: AccountInfo): string[] {
|
||||
const mentions = [...status.mentions.map(x => x.acct), status.account.acct];
|
||||
|
||||
|
@ -305,7 +320,7 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
|
|||
aggregateMention += `${x} `;
|
||||
});
|
||||
|
||||
const currentMaxCharLength = this.maxCharLength + mentionExtraChars;
|
||||
const currentMaxCharLength = this.maxCharLength + mentionExtraChars - this.getCwLength();
|
||||
const maxChars = currentMaxCharLength - 6;
|
||||
|
||||
while (trucatedStatus.length > currentMaxCharLength) {
|
||||
|
|
Loading…
Reference in New Issue