You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			65 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			JavaScript
		
	
			
		
		
	
	
			65 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			JavaScript
		
	
/* global Whisper */
 | 
						|
 | 
						|
// eslint-disable-next-line func-names
 | 
						|
(function() {
 | 
						|
  'use strict';
 | 
						|
 | 
						|
  window.Whisper = window.Whisper || {};
 | 
						|
 | 
						|
  Whisper.RemoveModeratorsDialogView = Whisper.View.extend({
 | 
						|
    className: 'loki-dialog modal',
 | 
						|
    async initialize(convo) {
 | 
						|
      this.close = this.close.bind(this);
 | 
						|
      this.onSubmit = this.onSubmit.bind(this);
 | 
						|
 | 
						|
      this.chatName = convo.get('name');
 | 
						|
      this.chatServer = convo.get('server');
 | 
						|
      this.channelId = convo.get('channelId');
 | 
						|
 | 
						|
      // get current list of moderators
 | 
						|
      this.channelAPI = await convo.getPublicSendData();
 | 
						|
      const modPubKeys = await this.channelAPI.getModerators();
 | 
						|
      const convos = window.getConversations().models;
 | 
						|
      const moderators = modPubKeys
 | 
						|
        .map(
 | 
						|
          pubKey =>
 | 
						|
            convos.find(c => c.id === pubKey) || {
 | 
						|
              id: pubKey, // memberList need a key
 | 
						|
              authorPhoneNumber: pubKey,
 | 
						|
            }
 | 
						|
        )
 | 
						|
        .filter(c => !!c);
 | 
						|
 | 
						|
      this.mods = moderators;
 | 
						|
 | 
						|
      this.$el.focus();
 | 
						|
      this.render();
 | 
						|
    },
 | 
						|
    render() {
 | 
						|
      const view = new Whisper.ReactWrapperView({
 | 
						|
        className: 'remove-moderators-dialog',
 | 
						|
        Component: window.Signal.Components.RemoveModeratorsDialog,
 | 
						|
        props: {
 | 
						|
          modList: this.mods,
 | 
						|
          onSubmit: this.onSubmit,
 | 
						|
          onClose: this.close,
 | 
						|
          chatName: this.chatName,
 | 
						|
        },
 | 
						|
      });
 | 
						|
 | 
						|
      this.$el.append(view.el);
 | 
						|
      return this;
 | 
						|
    },
 | 
						|
    close() {
 | 
						|
      this.remove();
 | 
						|
    },
 | 
						|
    async onSubmit(pubKeys) {
 | 
						|
      const res = await this.channelAPI.serverAPI.removeModerators(pubKeys);
 | 
						|
      if (res !== true) {
 | 
						|
        // we have errors, deal with them...
 | 
						|
        // how?
 | 
						|
      }
 | 
						|
    },
 | 
						|
  });
 | 
						|
})();
 |