hide pixelfed unsupported polls/scheduling

This commit is contained in:
Nicolas Constant 2019-10-01 22:24:00 -04:00
parent 5b6b463b90
commit 58414baa8e
No known key found for this signature in database
GPG Key ID: 1E9F677FB01A5688
2 changed files with 22 additions and 5 deletions

View File

@ -21,9 +21,9 @@
(suggestionSelectedEvent)="suggestionSelected($event)" (hasSuggestionsEvent)="suggestionsChanged($event)">
</app-autosuggest>
<app-poll-editor *ngIf="pollIsActive"></app-poll-editor>
<app-poll-editor *ngIf="instanceSupportsPoll && pollIsActive"></app-poll-editor>
<app-status-scheduler class="scheduler" *ngIf="scheduleIsActive"></app-status-scheduler>
<app-status-scheduler class="scheduler" *ngIf="instanceSupportsScheduling && scheduleIsActive"></app-status-scheduler>
<div class="status-editor__footer" #footer>
<button type="submit" title="reply" class="status-editor__footer--send-button" *ngIf="statusReplyingToWrapper">
@ -54,11 +54,13 @@
<fa-icon [icon]="faEnvelope" *ngIf="selectedPrivacy === 'DM'"></fa-icon>
</a>
<a href class="status-editor__footer--link status-editor__footer--add-poll" title="add poll" (click)="addPoll()">
<a href *ngIf="instanceSupportsPoll"
class="status-editor__footer--link status-editor__footer--add-poll" title="add poll" (click)="addPoll()">
<fa-icon [icon]="faPollH"></fa-icon>
</a>
<a href class="status-editor__footer--link" title="schedule" (click)="schedule()">
<a href *ngIf="instanceSupportsScheduling"
class="status-editor__footer--link" title="schedule" (click)="schedule()">
<fa-icon [icon]="faClock"></fa-icon>
</a>
</div>

View File

@ -9,7 +9,7 @@ import { ContextMenuService, ContextMenuComponent } from 'ngx-contextmenu';
import { MastodonService, VisibilityEnum, PollParameters } from '../../services/mastodon.service';
import { Status, Attachment } from '../../services/models/mastodon.interfaces';
import { ToolsService } from '../../services/tools.service';
import { ToolsService, InstanceInfo, InstanceType } from '../../services/tools.service';
import { NotificationService } from '../../services/notification.service';
import { StatusWrapper } from '../../models/common.model';
import { AccountInfo } from '../../states/accounts.state';
@ -109,6 +109,8 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
isSending: boolean;
mentionTooFarAwayError: boolean;
autosuggestData: string = null;
instanceSupportsPoll = true;
instanceSupportsScheduling = true;
private statusLoaded: boolean;
private hasSuggestions: boolean;
@ -295,6 +297,19 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
if (!this.statusReplyingToWrapper && !this.replyingUserHandle) {
this.getDefaultPrivacy();
}
this.toolsService.getInstanceInfo(this.selectedAccount)
.then((instance: InstanceInfo) => {
if(instance.type === InstanceType.Pixelfed){
this.instanceSupportsPoll = false;
this.instanceSupportsScheduling = false;
this.pollIsActive = false;
this.scheduleIsActive = false;
} else {
this.instanceSupportsPoll = true;
this.instanceSupportsScheduling = true;
}
});
}
}