import { ChangeDetectionStrategy , Component , OnInit } from '@angular/core' ; import { ChannelsV2Service } from '../channels-v2.service' ; import { PostMenuService } from '../../../../common/components/post-menu/post-menu.service' ; import { ActivityService } from '../../../../common/services/activity.service' ; import { OverlayModalService } from '../../../../services/ux/overlay-modal' ; import { Router } from '@angular/router' ; import { Client } from '../../../../services/api/client' ; import { ChannelAdminConfirmationService } from './admin-confirmation/admin-confirmation.service' ; import { AbstractSubscriberComponent } from '../../../../common/components/abstract-subscriber/abstract-subscriber.component' ; export interface ProToggleResponse { status ? : string ; } /**
 * Extra actions dropdown menu
 */ @ Component ( { selector : 'm-channelActions__menu' , changeDetection : ChangeDetectionStrategy . OnPush , templateUrl : 'menu.component.html' , providers : [ PostMenuService , ActivityService ] , } ) export class ChannelActionsMenuComponent extends AbstractSubscriberComponent implements OnInit { param service param overlayModalService param postMenu param router param activity constructor ( public service , protected overlayModalService , protected postMenu , protected router , private client , private adminConfirmation , activity ) { super ( ) ; } ngOnInit ( ) { this . subscriptions . push ( this . adminConfirmation . completed$ . subscribe ( payload => { if ( payload ) { let channel = this . service . channel$ . getValue ( ) ; const nextState = payload . action === 'make' ? true : false ; if ( payload . type === 'plus' ) { channel . plus = nextState ; } if ( payload . type === 'pro' ) { channel . pro = nextState ; } this . service . load ( channel ) ; } } ) ) ; } todo async subscribe ( ) { const channel = { ... this . service . channel$ . getValue ( ) } ; this . service . setChannel ( { ... channel , subscribed : false } ) ; await this . postMenu . setEntityOwner ( channel ) . subscribe ( ) ; this . service . setChannel ( { ... channel } ) ; } todo async unsubscribe ( ) { const channel = { ... this . service . channel$ . getValue ( ) } ; this . service . setChannel ( { ... channel , subscribed : false } ) ; await this . postMenu . setEntityOwner ( channel ) . unSubscribe ( ) ; this . service . setChannel ( { ... channel } ) ; } todo async unBan ( ) { const channel = { ... this . service . channel$ . getValue ( ) } ; this . service . setChannel ( { ... channel , banned : 'no' , subscribed : false } ) ; await this . postMenu . setEntity ( { ownerObj : channel } ) . unBan ( ) ; } viewLedger ( ) { this . router . navigate ( [ '/wallet/tokens/transactions' , { remote : this . service . channel$ . getValue ( ) . username } , ] ) ; } viewWithdrawals ( ) { this . router . navigate ( [ '/admin/withdrawals' , { user : this . service . channel$ . getValue ( ) . username } , ] ) ; } param { 'newsfeed' | 'content' } type public viewBoosts ( type ) { this . router . navigate ( [ `/boost/console/${ type }/history` , { remote : this . service . channel$ . getValue ( ) . username . toLowerCase ( ) } , ] ) ; } async viewEmail ( ) { const channel = { ... this . service . channel$ . getValue ( ) } ; const email = await this . postMenu . setEntity ( { ownerObj : channel } ) . getEmail ( ) ; this . service . setChannel ( { ... channel , email : email , subscribed : false } ) ; } async setExplicit ( explicit ) { const channel = { ... this . service . channel$ . getValue ( ) } ; this . service . setChannel ( { ... channel , is_mature : true , subscribed : false } ) ; await this . postMenu . setEntity ( { ownerObj : channel } ) . setExplicit ( explicit ) ; } async setNSFWLock ( reasons ) { const channel = { ... this . service . channel$ . getValue ( ) } ; const nsfw = reasons . map ( reason => reason . value ) ; this . service . setChannel ( { ... channel , nsfw : nsfw , subscribed : false } ) ; await this . postMenu . setEntity ( { ownerObj : channel } ) . setNsfw ( nsfw ) ; } async reIndex ( ) { const channel = { ... this . service . channel$ . getValue ( ) } ; this . postMenu . setEntity ( { ownerObj : channel } ) . reIndex ( ) ; } async setRating ( rating ) { const channel = { ... this . service . channel$ . getValue ( ) } ; this . service . setChannel ( { ... channel , rating : rating , subscribed : false } ) ; await this . postMenu . setEntity ( { ownerObj : channel } ) . setRating ( rating ) ; } todo async block ( ) { const channel = { ... this . service . channel$ . getValue ( ) } ; try { const response = await this . postMenu . setEntity ( { ownerObj : channel } ) . block ( ) ; if ( response && response . errorId === 'Minds::Core::Security::Block::BlockLimitException' ) { return ; } } catch ( e ) { return ; } this . service . setChannel ( { ... channel , blocked : true , subscribed : false , } ) ; } todo async unblock ( ) { const channel = { ... this . service . channel$ . getValue ( ) } ; this . service . setChannel ( { ... channel , blocked : false } ) ; await this . postMenu . setEntity ( { ownerObj : channel } ) . unBlock ( ) ; } todo report ( ) { const channel = { ... this . service . channel$ . getValue ( ) } ; this . postMenu . setEntity ( channel ) . openReportModal ( ) ; } returns { Promise < void > } async proAdminToggle ( ) { const channel = this . service . channel$ . getValue ( ) ; this . adminConfirmation . toggle ( 'pro' , channel . pro ? 'remove' : 'make' , channel . guid ) ; } returns { Promise < void > } async plusAdminToggle ( ) { const channel = this . service . channel$ . getValue ( ) ; this . adminConfirmation . toggle ( 'plus' , channel . plus ? 'remove' : 'make' , channel . guid ) ; } param boolean async setSeed ( seed ) { const channel = { ... this . service . channel$ . getValue ( ) } ; this . service . setChannel ( { ... channel , seed } ) ; try { await this . postMenu . setEntity ( { ownerObj : channel } ) . setSeed ( seed ) ; } catch ( e ) { this . service . setChannel ( { ... channel , seed : ! seed } ) ; } } }