custom status char limit supported #111
This commit is contained in:
parent
04cdb6ebce
commit
b81d73f062
|
@ -106,6 +106,12 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
|
||||||
private accountChanged(accounts: AccountInfo[]): void {
|
private accountChanged(accounts: AccountInfo[]): void {
|
||||||
if (accounts && accounts.length > 0) {
|
if (accounts && accounts.length > 0) {
|
||||||
const selectedAccount = accounts.filter(x => x.isSelected)[0];
|
const selectedAccount = accounts.filter(x => x.isSelected)[0];
|
||||||
|
|
||||||
|
const settings = this.toolsService.getAccountSettings(selectedAccount);
|
||||||
|
if(settings.customStatusCharLengthEnabled){
|
||||||
|
this.maxCharLength = settings.customStatusCharLength;
|
||||||
|
this.countStatusChar(this.status);
|
||||||
|
} else {
|
||||||
this.instancesInfoService.getMaxStatusChars(selectedAccount.instance)
|
this.instancesInfoService.getMaxStatusChars(selectedAccount.instance)
|
||||||
.then((maxChars: number) => {
|
.then((maxChars: number) => {
|
||||||
this.maxCharLength = maxChars;
|
this.maxCharLength = maxChars;
|
||||||
|
@ -114,6 +120,7 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
|
||||||
.catch((err: HttpErrorResponse) => {
|
.catch((err: HttpErrorResponse) => {
|
||||||
this.notificationService.notifyHttpError(err);
|
this.notificationService.notifyHttpError(err);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (!this.statusReplyingToWrapper) {
|
if (!this.statusReplyingToWrapper) {
|
||||||
this.instancesInfoService.getDefaultPrivacy(selectedAccount)
|
this.instancesInfoService.getDefaultPrivacy(selectedAccount)
|
||||||
|
|
|
@ -43,11 +43,11 @@
|
||||||
|
|
||||||
<h4 class="my-account__label my-account__margin-top">advanced settings:</h4>
|
<h4 class="my-account__label my-account__margin-top">advanced settings:</h4>
|
||||||
<div class="advanced-settings">
|
<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'
|
type="checkbox" name="customCharLength" value="customCharLength" id="customCharLength"> <label class="noselect advanced-settings__label" for="customCharLength">status'
|
||||||
custom length</label><br>
|
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>
|
<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>
|
</div>
|
||||||
|
|
||||||
<h4 class="my-account__label my-account__margin-top">remove account from sengi:</h4>
|
<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 { RemoveAccount } from '../../../../states/accounts.state';
|
||||||
import { NavigationService } from '../../../../services/navigation.service';
|
import { NavigationService } from '../../../../services/navigation.service';
|
||||||
import { MastodonService } from '../../../../services/mastodon.service';
|
import { MastodonService } from '../../../../services/mastodon.service';
|
||||||
|
import { ToolsService } from '../../../../services/tools.service';
|
||||||
|
import { AccountSettings } from '../../../../states/settings.state';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-my-account',
|
selector: 'app-my-account',
|
||||||
|
@ -26,6 +28,7 @@ export class MyAccountComponent implements OnInit, OnDestroy {
|
||||||
|
|
||||||
customStatusLengthEnabled: boolean;
|
customStatusLengthEnabled: boolean;
|
||||||
customStatusLength: number;
|
customStatusLength: number;
|
||||||
|
private accountSettings: AccountSettings;
|
||||||
|
|
||||||
availableStreams: StreamWrapper[] = [];
|
availableStreams: StreamWrapper[] = [];
|
||||||
availableLists: StreamWrapper[] = [];
|
availableLists: StreamWrapper[] = [];
|
||||||
|
@ -35,6 +38,7 @@ export class MyAccountComponent implements OnInit, OnDestroy {
|
||||||
set account(acc: AccountWrapper) {
|
set account(acc: AccountWrapper) {
|
||||||
this._account = acc;
|
this._account = acc;
|
||||||
this.loadStreams(acc);
|
this.loadStreams(acc);
|
||||||
|
this.loadAccountSettings();
|
||||||
}
|
}
|
||||||
get account(): AccountWrapper {
|
get account(): AccountWrapper {
|
||||||
return this._account;
|
return this._account;
|
||||||
|
@ -45,6 +49,7 @@ export class MyAccountComponent implements OnInit, OnDestroy {
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly store: Store,
|
private readonly store: Store,
|
||||||
|
private readonly toolsService: ToolsService,
|
||||||
private readonly navigationService: NavigationService,
|
private readonly navigationService: NavigationService,
|
||||||
private readonly mastodonService: MastodonService,
|
private readonly mastodonService: MastodonService,
|
||||||
private readonly notificationService: NotificationService) { }
|
private readonly notificationService: NotificationService) { }
|
||||||
|
@ -61,8 +66,21 @@ export class MyAccountComponent implements OnInit, OnDestroy {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onCustomLengthChange(): boolean {
|
private loadAccountSettings(){
|
||||||
this.customStatusLengthEnabled = !this.customStatusLengthEnabled;
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,10 @@ export class ToolsService {
|
||||||
accountSettings.accountId = account.id;
|
accountSettings.accountId = account.id;
|
||||||
this.saveAccountSettings(accountSettings);
|
this.saveAccountSettings(accountSettings);
|
||||||
}
|
}
|
||||||
|
if(!accountSettings.customStatusCharLength){
|
||||||
|
accountSettings.customStatusCharLength = 500;
|
||||||
|
this.saveAccountSettings(accountSettings);
|
||||||
|
}
|
||||||
return accountSettings;
|
return accountSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue