misc: remove dead code 🔥🔥🔥 (#2844)

- old toolbox actions
- chat command processor
- room subject handling
This commit is contained in:
Saúl Ibarra Corretgé
2018-04-19 19:24:16 +02:00
committed by virtuacoplenny
parent 172342cac3
commit 2861d8d24e
9 changed files with 5 additions and 258 deletions

View File

@@ -444,12 +444,6 @@ UI.addRemoteStream = track => VideoLayout.onRemoteStreamAdded(track);
*/
UI.removeRemoteStream = track => VideoLayout.onRemoteStreamRemoved(track);
/**
* Update chat subject.
* @param {string} subject new chat subject
*/
UI.setSubject = subject => Chat.setSubject(subject);
/**
* Setup and show Etherpad.
* @param {string} name etherpad id

View File

@@ -1,7 +1,6 @@
/* global APP, $ */
import { processReplacements, linkify } from './Replacement';
import CommandsProcessor from './Commands';
import { processReplacements } from './Replacement';
import VideoLayout from '../../videolayout/VideoLayout';
import UIUtil from '../../util/UIUtil';
@@ -12,8 +11,7 @@ import { smileys } from './smileys';
import { addMessage, markAllRead } from '../../../../react/features/chat';
import {
dockToolbox,
getToolboxHeight,
setSubject
getToolboxHeight
} from '../../../../react/features/toolbox';
let unreadMessages = 0;
@@ -235,15 +233,10 @@ const Chat = {
usermsg.val('').trigger('autosize.resize');
this.focus();// eslint-disable-line no-invalid-this
const command = new CommandsProcessor(value, eventEmitter);
if (command.isCommand()) {
command.processCommand();
} else {
const message = UIUtil.escapeHtml(value);
const message = UIUtil.escapeHtml(value);
eventEmitter.emit(UIEvents.MESSAGE_CREATED, message);
}
eventEmitter.emit(UIEvents.MESSAGE_CREATED, message);
}
});
@@ -351,21 +344,6 @@ const Chat = {
{ scrollTop: $('#chatconversation')[0].scrollHeight }, 1000);
},
/**
* Sets the subject to the UI
* @param subject the subject
*/
setSubject(subject) {
if (subject) {
// eslint-disable-next-line no-param-reassign
subject = subject.trim();
}
const html = linkify(UIUtil.escapeHtml(subject));
APP.store.dispatch(setSubject(html));
},
/**
* Sets the chat conversation mode.
* Conversation mode is the normal chat mode, non conversation mode is

View File

@@ -1,94 +0,0 @@
import UIUtil from '../../util/UIUtil';
import UIEvents from '../../../../service/UI/UIEvents';
/**
* List with supported commands. The keys are the names of the commands and
* the value is the function that processes the message.
* @type {{String: function}}
*/
const commands = {
'topic': processTopic
};
/**
* Extracts the command from the message.
* @param message the received message
* @returns {string} the command
*/
function getCommand(message) {
if (message) {
for (const command in commands) {
if (message.indexOf(`/${command}`) === 0) {
return command;
}
}
}
return '';
}
/**
* Processes the data for topic command.
* @param commandArguments the arguments of the topic command.
*/
function processTopic(commandArguments, emitter) {
const topic = UIUtil.escapeHtml(commandArguments);
emitter.emit(UIEvents.SUBJECT_CHANGED, topic);
}
/**
* Constructs a new CommandProccessor instance from a message that
* handles commands received via chat messages.
* @param message the message
* @constructor
*/
function CommandsProcessor(message, emitter) {
const command = getCommand(message);
this.emitter = emitter;
/**
* Returns the name of the command.
* @returns {String} the command
*/
this.getCommand = function() {
return command;
};
const messageArgument = message.substr(command.length + 2);
/**
* Returns the arguments of the command.
* @returns {string}
*/
this.getArgument = function() {
return messageArgument;
};
}
/**
* Checks whether this instance is valid command or not.
* @returns {boolean}
*/
CommandsProcessor.prototype.isCommand = function() {
if (this.getCommand()) {
return true;
}
return false;
};
/**
* Processes the command.
*/
CommandsProcessor.prototype.processCommand = function() {
if (!this.isCommand()) {
return;
}
commands[this.getCommand()](this.getArgument(), this.emitter);
};
export default CommandsProcessor;