language posting working
This commit is contained in:
parent
91b2f4a0f0
commit
32efac5aa4
|
@ -93,6 +93,6 @@
|
||||||
{{ l.name }}
|
{{ l.name }}
|
||||||
</ng-template>
|
</ng-template>
|
||||||
</context-menu>
|
</context-menu>
|
||||||
|
|
||||||
<app-media></app-media>
|
<app-media></app-media>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -155,6 +155,8 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
|
||||||
instanceSupportsScheduling = true;
|
instanceSupportsScheduling = true;
|
||||||
isEditing: boolean;
|
isEditing: boolean;
|
||||||
editingStatusId: string;
|
editingStatusId: string;
|
||||||
|
configuredLanguages: ILanguage[] = [];
|
||||||
|
selectedLanguage: ILanguage;
|
||||||
private statusLoaded: boolean;
|
private statusLoaded: boolean;
|
||||||
private hasSuggestions: boolean;
|
private hasSuggestions: boolean;
|
||||||
|
|
||||||
|
@ -222,9 +224,6 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
|
||||||
this.accounts$ = this.store.select(state => state.registeredaccounts.accounts);
|
this.accounts$ = this.store.select(state => state.registeredaccounts.accounts);
|
||||||
}
|
}
|
||||||
|
|
||||||
configuredLanguages: ILanguage[] = [];
|
|
||||||
selectedLanguage: ILanguage;
|
|
||||||
|
|
||||||
private initLanguages(){
|
private initLanguages(){
|
||||||
this.configuredLanguages = this.languageService.getConfiguredLanguages();
|
this.configuredLanguages = this.languageService.getConfiguredLanguages();
|
||||||
this.selectedLanguage = this.languageService.getSelectedLanguage();
|
this.selectedLanguage = this.languageService.getSelectedLanguage();
|
||||||
|
@ -652,6 +651,14 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private currentLang(): string {
|
||||||
|
if(this.selectedLanguage){
|
||||||
|
return this.selectedLanguage.iso639;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private sendStatus(account: AccountInfo, status: string, visibility: VisibilityEnum, title: string, previousStatus: Status, attachments: Attachment[], poll: PollParameters, scheduledAt: string, editingStatusId: string): Promise<Status> {
|
private sendStatus(account: AccountInfo, status: string, visibility: VisibilityEnum, title: string, previousStatus: Status, attachments: Attachment[], poll: PollParameters, scheduledAt: string, editingStatusId: string): Promise<Status> {
|
||||||
let parsedStatus = this.parseStatus(status);
|
let parsedStatus = this.parseStatus(status);
|
||||||
let resultPromise = Promise.resolve(previousStatus);
|
let resultPromise = Promise.resolve(previousStatus);
|
||||||
|
@ -669,9 +676,9 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
|
||||||
let postPromise: Promise<Status>;
|
let postPromise: Promise<Status>;
|
||||||
|
|
||||||
if (this.isEditing) {
|
if (this.isEditing) {
|
||||||
postPromise = this.mastodonService.editStatus(account, editingStatusId, s, visibility, title, inReplyToId, attachments, poll, scheduledAt);
|
postPromise = this.mastodonService.editStatus(account, editingStatusId, s, visibility, title, inReplyToId, attachments, poll, scheduledAt, this.currentLang());
|
||||||
} else {
|
} else {
|
||||||
postPromise = this.mastodonService.postNewStatus(account, s, visibility, title, inReplyToId, attachments.map(x => x.id), poll, scheduledAt);
|
postPromise = this.mastodonService.postNewStatus(account, s, visibility, title, inReplyToId, attachments.map(x => x.id), poll, scheduledAt, this.currentLang());
|
||||||
}
|
}
|
||||||
|
|
||||||
return postPromise
|
return postPromise
|
||||||
|
@ -681,9 +688,9 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
if (this.isEditing) {
|
if (this.isEditing) {
|
||||||
return this.mastodonService.editStatus(account, editingStatusId, s, visibility, title, inReplyToId, [], null, scheduledAt);
|
return this.mastodonService.editStatus(account, editingStatusId, s, visibility, title, inReplyToId, [], null, scheduledAt, this.currentLang());
|
||||||
} else {
|
} else {
|
||||||
return this.mastodonService.postNewStatus(account, s, visibility, title, inReplyToId, [], null, scheduledAt);
|
return this.mastodonService.postNewStatus(account, s, visibility, title, inReplyToId, [], null, scheduledAt, this.currentLang());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -117,17 +117,17 @@ export class MastodonWrapperService {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
postNewStatus(account: AccountInfo, status: string, visibility: VisibilityEnum, spoiler: string = null, in_reply_to_id: string = null, mediaIds: string[], poll: PollParameters = null, scheduled_at: string = null): Promise<Status> {
|
postNewStatus(account: AccountInfo, status: string, visibility: VisibilityEnum, spoiler: string = null, in_reply_to_id: string = null, mediaIds: string[], poll: PollParameters = null, scheduled_at: string = null, lang: string = null): Promise<Status> {
|
||||||
return this.refreshAccountIfNeeded(account)
|
return this.refreshAccountIfNeeded(account)
|
||||||
.then((refreshedAccount: AccountInfo) => {
|
.then((refreshedAccount: AccountInfo) => {
|
||||||
return this.mastodonService.postNewStatus(refreshedAccount, status, visibility, spoiler, in_reply_to_id, mediaIds, poll, scheduled_at);
|
return this.mastodonService.postNewStatus(refreshedAccount, status, visibility, spoiler, in_reply_to_id, mediaIds, poll, scheduled_at, lang);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
editStatus(account: AccountInfo, statusId: string, status: string, visibility: VisibilityEnum, spoiler: string = null, in_reply_to_id: string = null, attachements: Attachment[], poll: PollParameters = null, scheduled_at: string = null): Promise<Status> {
|
editStatus(account: AccountInfo, statusId: string, status: string, visibility: VisibilityEnum, spoiler: string = null, in_reply_to_id: string = null, attachements: Attachment[], poll: PollParameters = null, scheduled_at: string = null, lang: string = null): Promise<Status> {
|
||||||
return this.refreshAccountIfNeeded(account)
|
return this.refreshAccountIfNeeded(account)
|
||||||
.then((refreshedAccount: AccountInfo) => {
|
.then((refreshedAccount: AccountInfo) => {
|
||||||
return this.mastodonService.editStatus(refreshedAccount, statusId, status, visibility, spoiler, in_reply_to_id, attachements, poll, scheduled_at);
|
return this.mastodonService.editStatus(refreshedAccount, statusId, status, visibility, spoiler, in_reply_to_id, attachements, poll, scheduled_at, lang);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -88,7 +88,7 @@ export class MastodonService {
|
||||||
return origString.replace(regEx, "");
|
return origString.replace(regEx, "");
|
||||||
};
|
};
|
||||||
|
|
||||||
postNewStatus(account: AccountInfo, status: string, visibility: VisibilityEnum, spoiler: string = null, in_reply_to_id: string = null, mediaIds: string[], poll: PollParameters = null, scheduled_at: string = null): Promise<Status> {
|
postNewStatus(account: AccountInfo, status: string, visibility: VisibilityEnum, spoiler: string = null, in_reply_to_id: string = null, mediaIds: string[], poll: PollParameters = null, scheduled_at: string = null, lang: string = null): Promise<Status> {
|
||||||
const url = `https://${account.instance}${this.apiRoutes.postNewStatus}`;
|
const url = `https://${account.instance}${this.apiRoutes.postNewStatus}`;
|
||||||
|
|
||||||
const statusData = new StatusData();
|
const statusData = new StatusData();
|
||||||
|
@ -106,10 +106,16 @@ export class MastodonService {
|
||||||
if (in_reply_to_id) {
|
if (in_reply_to_id) {
|
||||||
statusData.in_reply_to_id = in_reply_to_id;
|
statusData.in_reply_to_id = in_reply_to_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (spoiler) {
|
if (spoiler) {
|
||||||
statusData.sensitive = true;
|
statusData.sensitive = true;
|
||||||
statusData.spoiler_text = spoiler;
|
statusData.spoiler_text = spoiler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(lang) {
|
||||||
|
statusData.language = lang;
|
||||||
|
}
|
||||||
|
|
||||||
switch (visibility) {
|
switch (visibility) {
|
||||||
case VisibilityEnum.Public:
|
case VisibilityEnum.Public:
|
||||||
statusData.visibility = 'public';
|
statusData.visibility = 'public';
|
||||||
|
@ -132,7 +138,7 @@ export class MastodonService {
|
||||||
return this.httpClient.post<Status>(url, statusData, { headers: headers }).toPromise();
|
return this.httpClient.post<Status>(url, statusData, { headers: headers }).toPromise();
|
||||||
}
|
}
|
||||||
|
|
||||||
editStatus(account: AccountInfo, statusId: string, status: string, visibility: VisibilityEnum, spoiler: string = null, in_reply_to_id: string = null, attachements: Attachment[], poll: PollParameters = null, scheduled_at: string = null): Promise<Status> {
|
editStatus(account: AccountInfo, statusId: string, status: string, visibility: VisibilityEnum, spoiler: string = null, in_reply_to_id: string = null, attachements: Attachment[], poll: PollParameters = null, scheduled_at: string = null, lang: string = null): Promise<Status> {
|
||||||
const url = `https://${account.instance}${this.apiRoutes.editStatus.replace('{0}', statusId)}`;
|
const url = `https://${account.instance}${this.apiRoutes.editStatus.replace('{0}', statusId)}`;
|
||||||
|
|
||||||
const statusData = new StatusData();
|
const statusData = new StatusData();
|
||||||
|
@ -151,10 +157,16 @@ export class MastodonService {
|
||||||
if (in_reply_to_id) {
|
if (in_reply_to_id) {
|
||||||
statusData.in_reply_to_id = in_reply_to_id;
|
statusData.in_reply_to_id = in_reply_to_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (spoiler) {
|
if (spoiler) {
|
||||||
statusData.sensitive = true;
|
statusData.sensitive = true;
|
||||||
statusData.spoiler_text = spoiler;
|
statusData.spoiler_text = spoiler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(lang) {
|
||||||
|
statusData.language = lang;
|
||||||
|
}
|
||||||
|
|
||||||
switch (visibility) {
|
switch (visibility) {
|
||||||
case VisibilityEnum.Public:
|
case VisibilityEnum.Public:
|
||||||
statusData.visibility = 'public';
|
statusData.visibility = 'public';
|
||||||
|
@ -651,6 +663,8 @@ class StatusData {
|
||||||
spoiler_text: string;
|
spoiler_text: string;
|
||||||
visibility: string;
|
visibility: string;
|
||||||
// scheduled_at: string;
|
// scheduled_at: string;
|
||||||
|
|
||||||
|
language: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
class MediaAttributes {
|
class MediaAttributes {
|
||||||
|
|
Loading…
Reference in New Issue