custom status char limit supported #111
This commit is contained in:
parent
04cdb6ebce
commit
b81d73f062
|
@ -106,7 +106,13 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
|
|||
private accountChanged(accounts: AccountInfo[]): void {
|
||||
if (accounts && accounts.length > 0) {
|
||||
const selectedAccount = accounts.filter(x => x.isSelected)[0];
|
||||
this.instancesInfoService.getMaxStatusChars(selectedAccount.instance)
|
||||
|
||||
const settings = this.toolsService.getAccountSettings(selectedAccount);
|
||||
if(settings.customStatusCharLengthEnabled){
|
||||
this.maxCharLength = settings.customStatusCharLength;
|
||||
this.countStatusChar(this.status);
|
||||
} else {
|
||||
this.instancesInfoService.getMaxStatusChars(selectedAccount.instance)
|
||||
.then((maxChars: number) => {
|
||||
this.maxCharLength = maxChars;
|
||||
this.countStatusChar(this.status);
|
||||
|
@ -114,6 +120,7 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
|
|||
.catch((err: HttpErrorResponse) => {
|
||||
this.notificationService.notifyHttpError(err);
|
||||
});
|
||||
}
|
||||
|
||||
if (!this.statusReplyingToWrapper) {
|
||||
this.instancesInfoService.getDefaultPrivacy(selectedAccount)
|
||||
|
|
|
@ -43,11 +43,11 @@
|
|||
|
||||
<h4 class="my-account__label my-account__margin-top">advanced settings:</h4>
|
||||
<div class="advanced-settings">
|
||||
<input class="advanced-settings__checkbox" [value]="customStatusLengthEnabled" (change)="onCustomLengthChange()"
|
||||
<input class="advanced-settings__checkbox" [(ngModel)]="customStatusLengthEnabled" (change)="onCustomLengthEnabledChanged()"
|
||||
type="checkbox" name="customCharLength" value="customCharLength" id="customCharLength"> <label class="noselect advanced-settings__label" for="customCharLength">status'
|
||||
custom length</label><br>
|
||||
<p *ngIf="customStatusLengthEnabled" class="advanced-settings__text">use this only if your instance doesn't support custom length detection (i.e. not a Pleroma or glitch-soc instance)</p>
|
||||
<input *ngIf="customStatusLengthEnabled" [value]="customStatusLength" class="themed-form advanced-settings__input" type="number" />
|
||||
<input *ngIf="customStatusLengthEnabled" [(ngModel)]="customStatusLength" class="themed-form advanced-settings__input" type="number" (keyup)="customStatusLengthChanged($event)" />
|
||||
</div>
|
||||
|
||||
<h4 class="my-account__label my-account__margin-top">remove account from sengi:</h4>
|
||||
|
|
|
@ -10,6 +10,8 @@ import { AccountWrapper } from '../../../../models/account.models';
|
|||
import { RemoveAccount } from '../../../../states/accounts.state';
|
||||
import { NavigationService } from '../../../../services/navigation.service';
|
||||
import { MastodonService } from '../../../../services/mastodon.service';
|
||||
import { ToolsService } from '../../../../services/tools.service';
|
||||
import { AccountSettings } from '../../../../states/settings.state';
|
||||
|
||||
@Component({
|
||||
selector: 'app-my-account',
|
||||
|
@ -26,6 +28,7 @@ export class MyAccountComponent implements OnInit, OnDestroy {
|
|||
|
||||
customStatusLengthEnabled: boolean;
|
||||
customStatusLength: number;
|
||||
private accountSettings: AccountSettings;
|
||||
|
||||
availableStreams: StreamWrapper[] = [];
|
||||
availableLists: StreamWrapper[] = [];
|
||||
|
@ -35,6 +38,7 @@ export class MyAccountComponent implements OnInit, OnDestroy {
|
|||
set account(acc: AccountWrapper) {
|
||||
this._account = acc;
|
||||
this.loadStreams(acc);
|
||||
this.loadAccountSettings();
|
||||
}
|
||||
get account(): AccountWrapper {
|
||||
return this._account;
|
||||
|
@ -45,6 +49,7 @@ export class MyAccountComponent implements OnInit, OnDestroy {
|
|||
|
||||
constructor(
|
||||
private readonly store: Store,
|
||||
private readonly toolsService: ToolsService,
|
||||
private readonly navigationService: NavigationService,
|
||||
private readonly mastodonService: MastodonService,
|
||||
private readonly notificationService: NotificationService) { }
|
||||
|
@ -52,7 +57,7 @@ export class MyAccountComponent implements OnInit, OnDestroy {
|
|||
ngOnInit() {
|
||||
this.streamChangedSub = this.streamElements$.subscribe((streams: StreamElement[]) => {
|
||||
this.loadStreams(this.account);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
|
@ -61,8 +66,21 @@ export class MyAccountComponent implements OnInit, OnDestroy {
|
|||
}
|
||||
}
|
||||
|
||||
onCustomLengthChange(): boolean {
|
||||
this.customStatusLengthEnabled = !this.customStatusLengthEnabled;
|
||||
private loadAccountSettings(){
|
||||
this.accountSettings = this.toolsService.getAccountSettings(this.account.info);
|
||||
|
||||
this.customStatusLengthEnabled = this.accountSettings.customStatusCharLengthEnabled; this.customStatusLength = this.accountSettings.customStatusCharLength;
|
||||
}
|
||||
|
||||
onCustomLengthEnabledChanged(): boolean {
|
||||
this.accountSettings.customStatusCharLengthEnabled = this.customStatusLengthEnabled;
|
||||
this.toolsService.saveAccountSettings(this.accountSettings);
|
||||
return false;
|
||||
}
|
||||
|
||||
customStatusLengthChanged(event): boolean{
|
||||
this.accountSettings.customStatusCharLength = this.customStatusLength;
|
||||
this.toolsService.saveAccountSettings(this.accountSettings);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,10 @@ export class ToolsService {
|
|||
accountSettings.accountId = account.id;
|
||||
this.saveAccountSettings(accountSettings);
|
||||
}
|
||||
if(!accountSettings.customStatusCharLength){
|
||||
accountSettings.customStatusCharLength = 500;
|
||||
this.saveAccountSettings(accountSettings);
|
||||
}
|
||||
return accountSettings;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue