fix #54
This commit is contained in:
parent
b4fdce6e66
commit
81ff215840
|
@ -93,6 +93,30 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
|
||||||
.then((maxChars: number) => {
|
.then((maxChars: number) => {
|
||||||
this.maxCharLength = maxChars;
|
this.maxCharLength = maxChars;
|
||||||
this.countStatusChar(this.status);
|
this.countStatusChar(this.status);
|
||||||
|
})
|
||||||
|
.catch((err: HttpErrorResponse) => {
|
||||||
|
this.notificationService.notifyHttpError(err);
|
||||||
|
});
|
||||||
|
|
||||||
|
this.instancesInfoService.getDefaultPrivacy(selectedAccount)
|
||||||
|
.then((defaultPrivacy: VisibilityEnum) => {
|
||||||
|
switch (defaultPrivacy) {
|
||||||
|
case VisibilityEnum.Public:
|
||||||
|
this.selectedPrivacy = 'Public';
|
||||||
|
break;
|
||||||
|
case VisibilityEnum.Unlisted:
|
||||||
|
this.selectedPrivacy = 'Unlisted';
|
||||||
|
break;
|
||||||
|
case VisibilityEnum.Private:
|
||||||
|
this.selectedPrivacy = 'Follows-only';
|
||||||
|
break;
|
||||||
|
case VisibilityEnum.Direct:
|
||||||
|
this.selectedPrivacy = 'DM';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((err: HttpErrorResponse) => {
|
||||||
|
this.notificationService.notifyHttpError(err);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
import { MastodonService } from './mastodon.service';
|
import { MastodonService, VisibilityEnum } from './mastodon.service';
|
||||||
import { Instance } from './models/mastodon.interfaces';
|
import { Instance, Account } from './models/mastodon.interfaces';
|
||||||
|
import { AccountInfo } from '../states/accounts.state';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
|
@ -9,6 +10,7 @@ import { Instance } from './models/mastodon.interfaces';
|
||||||
export class InstancesInfoService {
|
export class InstancesInfoService {
|
||||||
private defaultMaxChars = 500;
|
private defaultMaxChars = 500;
|
||||||
private cachedMaxInstanceChar: { [id: string]: Promise<number>; } = {};
|
private cachedMaxInstanceChar: { [id: string]: Promise<number>; } = {};
|
||||||
|
private cachedDefaultPrivacy: { [id: string]: Promise<VisibilityEnum>; } = {};
|
||||||
|
|
||||||
constructor(private mastodonService: MastodonService) { }
|
constructor(private mastodonService: MastodonService) { }
|
||||||
|
|
||||||
|
@ -28,4 +30,29 @@ export class InstancesInfoService {
|
||||||
}
|
}
|
||||||
return this.cachedMaxInstanceChar[instance];
|
return this.cachedMaxInstanceChar[instance];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getDefaultPrivacy(account: AccountInfo): Promise<VisibilityEnum> {
|
||||||
|
const instance = account.instance;
|
||||||
|
if (!this.cachedDefaultPrivacy[instance]) {
|
||||||
|
this.cachedDefaultPrivacy[instance] = this.mastodonService.retrieveAccountDetails(account)
|
||||||
|
.then((accountDetails: Account) => {
|
||||||
|
switch (accountDetails.source.privacy) {
|
||||||
|
case 'public':
|
||||||
|
return VisibilityEnum.Public;
|
||||||
|
case 'unlisted':
|
||||||
|
return VisibilityEnum.Unlisted;
|
||||||
|
case 'private':
|
||||||
|
return VisibilityEnum.Private;
|
||||||
|
case 'direct':
|
||||||
|
return VisibilityEnum.Direct;
|
||||||
|
default:
|
||||||
|
return VisibilityEnum.Public;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
return VisibilityEnum.Public;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return this.cachedDefaultPrivacy[instance];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,14 @@ export interface Account {
|
||||||
moved: boolean;
|
moved: boolean;
|
||||||
fields: Field[];
|
fields: Field[];
|
||||||
bot: boolean;
|
bot: boolean;
|
||||||
|
source: AccountInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AccountInfo {
|
||||||
|
privacy: string;
|
||||||
|
sensitive: boolean;
|
||||||
|
note: string;
|
||||||
|
fields: Field[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Emoji {
|
export interface Emoji {
|
||||||
|
|
Loading…
Reference in New Issue