added pin/mute/delete status in context-menu
This commit is contained in:
parent
74de21f5e6
commit
69cb670dcc
|
@ -39,21 +39,36 @@
|
|||
Copy link to status
|
||||
</ng-template>
|
||||
<ng-template contextMenuItem divider="true"></ng-template>
|
||||
<ng-template contextMenuItem (execute)="mentionAccount()">
|
||||
<ng-template contextMenuItem (execute)="mentionAccount()" *ngIf="!isOwnerSelected">
|
||||
Mention @{{ this.username }}
|
||||
</ng-template>
|
||||
<ng-template contextMenuItem (execute)="dmAccount()">
|
||||
<ng-template contextMenuItem (execute)="dmAccount()" *ngIf="!isOwnerSelected">
|
||||
Direct message @{{ this.username }}
|
||||
</ng-template>
|
||||
<ng-template contextMenuItem (execute)="muteConversation()" *ngIf="isOwnerSelected && !displayedStatus.muted">
|
||||
Mute conversation
|
||||
</ng-template>
|
||||
<ng-template contextMenuItem (execute)="unmuteConversation()" *ngIf="isOwnerSelected && displayedStatus.muted">
|
||||
Unmute conversation
|
||||
</ng-template>
|
||||
<ng-template contextMenuItem divider="true"></ng-template>
|
||||
<ng-template contextMenuItem (execute)="muteAccount()">
|
||||
<ng-template contextMenuItem (execute)="muteAccount()" *ngIf="!isOwnerSelected">
|
||||
Mute @{{ this.username }}
|
||||
</ng-template>
|
||||
<ng-template contextMenuItem (execute)="blockAccount()">
|
||||
<ng-template contextMenuItem (execute)="blockAccount()" *ngIf="!isOwnerSelected">
|
||||
Block @{{ this.username }}
|
||||
</ng-template>
|
||||
<!-- <ng-template contextMenuItem (execute)="showMessage('Hi, ' + $event.item.name)">
|
||||
Mute @account
|
||||
</ng-template> -->
|
||||
<ng-template contextMenuItem (execute)="pinOnProfile()" *ngIf="isOwnerSelected && !displayedStatus.pinned && displayedStatus.visibility === 'public'">
|
||||
Pin on profile
|
||||
</ng-template>
|
||||
<ng-template contextMenuItem (execute)="unpinFromProfile()" *ngIf="isOwnerSelected && displayedStatus.pinned && displayedStatus.visibility === 'public'">
|
||||
Unpin from profile
|
||||
</ng-template>
|
||||
<ng-template contextMenuItem (execute)="delete(false)" *ngIf="isOwnerSelected">
|
||||
Delete
|
||||
</ng-template>
|
||||
<ng-template contextMenuItem (execute)="delete(true)" *ngIf="isOwnerSelected">
|
||||
Delete & re-draft
|
||||
</ng-template>
|
||||
</context-menu>
|
||||
</div>
|
|
@ -53,9 +53,16 @@ export class ActionBarComponent implements OnInit, OnDestroy {
|
|||
|
||||
isContentWarningActive: boolean = false;
|
||||
|
||||
isOwnerSelected: boolean;
|
||||
|
||||
private isProviderSelected: boolean;
|
||||
private selectedAccounts: AccountInfo[];
|
||||
|
||||
username: string;
|
||||
displayedStatus: Status;
|
||||
private fullHandle: string;
|
||||
private loadedAccounts: AccountInfo[];
|
||||
|
||||
private favoriteStatePerAccountId: { [id: string]: boolean; } = {};
|
||||
private bootedStatePerAccountId: { [id: string]: boolean; } = {};
|
||||
|
||||
|
@ -73,11 +80,6 @@ export class ActionBarComponent implements OnInit, OnDestroy {
|
|||
this.accounts$ = this.store.select(state => state.registeredaccounts.accounts);
|
||||
}
|
||||
|
||||
username: string;
|
||||
private fullHandle: string;
|
||||
private displayedStatus: Status;
|
||||
private loadedAccounts: AccountInfo[];
|
||||
|
||||
ngOnInit() {
|
||||
const status = this.statusWrapper.status;
|
||||
const account = this.statusWrapper.provider;
|
||||
|
@ -123,6 +125,9 @@ export class ActionBarComponent implements OnInit, OnDestroy {
|
|||
this.selectedAccounts = accounts.filter(x => x.isSelected);
|
||||
this.isProviderSelected = this.selectedAccounts.filter(x => x.id === provider.id).length > 0;
|
||||
|
||||
this.isOwnerSelected = this.selectedAccounts[0].username === this.displayedStatus.account.username
|
||||
&& this.selectedAccounts[0].instance === this.displayedStatus.account.url.replace('https://', '').split('/')[0];
|
||||
|
||||
if (status.visibility === 'direct' || status.visibility === 'private') {
|
||||
this.isBoostLocked = true;
|
||||
} else {
|
||||
|
@ -323,4 +328,71 @@ export class ActionBarComponent implements OnInit, OnDestroy {
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
muteConversation(): boolean {
|
||||
const selectedAccount = this.selectedAccounts[0];
|
||||
this.mastodonService.muteConversation(selectedAccount, this.displayedStatus.id)
|
||||
.then((status: Status) => {
|
||||
this.displayedStatus.muted = status.muted;
|
||||
})
|
||||
.catch(err => {
|
||||
this.notificationService.notifyHttpError(err);
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
unmuteConversation(): boolean {
|
||||
const selectedAccount = this.selectedAccounts[0];
|
||||
this.mastodonService.unmuteConversation(selectedAccount, this.displayedStatus.id)
|
||||
.then((status: Status) => {
|
||||
this.displayedStatus.muted = status.muted;
|
||||
})
|
||||
.catch(err => {
|
||||
this.notificationService.notifyHttpError(err);
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
pinOnProfile(): boolean {
|
||||
const selectedAccount = this.selectedAccounts[0];
|
||||
this.mastodonService.pinOnProfile(selectedAccount, this.displayedStatus.id)
|
||||
.then((status: Status) => {
|
||||
this.displayedStatus.pinned = status.pinned;
|
||||
})
|
||||
.catch(err => {
|
||||
this.notificationService.notifyHttpError(err);
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
unpinFromProfile(): boolean {
|
||||
const selectedAccount = this.selectedAccounts[0];
|
||||
this.mastodonService.unpinFromProfile(selectedAccount, this.displayedStatus.id)
|
||||
.then((status: Status) => {
|
||||
this.displayedStatus.pinned = status.pinned;
|
||||
})
|
||||
.catch(err => {
|
||||
this.notificationService.notifyHttpError(err);
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
delete(redraft: boolean): boolean {
|
||||
const selectedAccount = this.selectedAccounts[0];
|
||||
this.mastodonService.deleteStatus(selectedAccount, this.displayedStatus.id)
|
||||
.then(() => {
|
||||
if(redraft){
|
||||
//TODO
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
this.notificationService.notifyHttpError(err);
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -331,7 +331,37 @@ export class MastodonService {
|
|||
let route = `https://${account.instance}${this.apiRoutes.block}`.replace('{0}', accounId.toString());
|
||||
const headers = new HttpHeaders({ 'Authorization': `Bearer ${account.token.access_token}` });
|
||||
return this.httpClient.post<Relationship>(route, null, { headers: headers }).toPromise();
|
||||
}
|
||||
}
|
||||
|
||||
pinOnProfile(account: AccountInfo, statusId: string): Promise<Status> {
|
||||
let route = `https://${account.instance}${this.apiRoutes.pinStatus}`.replace('{0}', statusId.toString());
|
||||
const headers = new HttpHeaders({ 'Authorization': `Bearer ${account.token.access_token}` });
|
||||
return this.httpClient.post<Status>(route, null, { headers: headers }).toPromise();
|
||||
}
|
||||
|
||||
unpinFromProfile(account: AccountInfo, statusId: string): Promise<Status> {
|
||||
let route = `https://${account.instance}${this.apiRoutes.unpinStatus}`.replace('{0}', statusId.toString());
|
||||
const headers = new HttpHeaders({ 'Authorization': `Bearer ${account.token.access_token}` });
|
||||
return this.httpClient.post<Status>(route, null, { headers: headers }).toPromise();
|
||||
}
|
||||
|
||||
muteConversation(account: AccountInfo, statusId: string): Promise<Status> {
|
||||
let route = `https://${account.instance}${this.apiRoutes.muteStatus}`.replace('{0}', statusId.toString());
|
||||
const headers = new HttpHeaders({ 'Authorization': `Bearer ${account.token.access_token}` });
|
||||
return this.httpClient.post<Status>(route, null, { headers: headers }).toPromise();
|
||||
}
|
||||
|
||||
unmuteConversation(account: AccountInfo, statusId: string): Promise<Status> {
|
||||
let route = `https://${account.instance}${this.apiRoutes.unmuteStatus}`.replace('{0}', statusId.toString());
|
||||
const headers = new HttpHeaders({ 'Authorization': `Bearer ${account.token.access_token}` });
|
||||
return this.httpClient.post<Status>(route, null, { headers: headers }).toPromise();
|
||||
}
|
||||
|
||||
deleteStatus(account: AccountInfo, statusId: string): Promise<any> {
|
||||
let route = `https://${account.instance}${this.apiRoutes.deleteStatus}`.replace('{0}', statusId.toString());
|
||||
const headers = new HttpHeaders({ 'Authorization': `Bearer ${account.token.access_token}` });
|
||||
return this.httpClient.delete<any>(route, { headers: headers }).toPromise();
|
||||
}
|
||||
}
|
||||
|
||||
export enum VisibilityEnum {
|
||||
|
|
|
@ -13,6 +13,8 @@ export class ApiRoutes {
|
|||
unblock = '/api/v1/accounts/{0}/unblock';
|
||||
mute = '/api/v1/accounts/{0}/mute';
|
||||
unmute = '/api/v1/accounts/{0}/unmute';
|
||||
muteStatus = '/api/v1/statuses/{0}/mute';
|
||||
unmuteStatus = '/api/v1/statuses/{0}/unmute';
|
||||
getAccountRelationships = '/api/v1/accounts/relationships';
|
||||
searchForAccounts = '/api/v1/accounts/search';
|
||||
getBlocks = '/api/v1/blocks';
|
||||
|
@ -43,6 +45,8 @@ export class ApiRoutes {
|
|||
unreblogStatus = '/api/v1/statuses/{0}/unreblog';
|
||||
favouritingStatus = '/api/v1/statuses/{0}/favourite';
|
||||
unfavouritingStatus = '/api/v1/statuses/{0}/unfavourite';
|
||||
pinStatus = '/api/v1/statuses/{0}/pin';
|
||||
unpinStatus = '/api/v1/statuses/{0}/unpin';
|
||||
getHomeTimeline = '/api/v1/timelines/home';
|
||||
getPublicTimeline = '/api/v1/timelines/public';
|
||||
getHastagTimeline = '/api/v1/timelines/tag/{0}';
|
||||
|
|
|
@ -181,8 +181,9 @@ export interface Status {
|
|||
emojis: Emoji[];
|
||||
language: string;
|
||||
pinned: boolean;
|
||||
muted: boolean;
|
||||
card: Card;
|
||||
poll: Poll;
|
||||
poll: Poll;
|
||||
|
||||
pleroma: PleromaStatusInfo;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue