Merge pull request #4323 from KDSBrowne/x2.0-replace-getElementById-instances
[HTML5] - Replace Instances of getElementById
This commit is contained in:
commit
50c7974a30
@ -2,7 +2,6 @@ import { Meteor } from 'meteor/meteor';
|
||||
import { check } from 'meteor/check';
|
||||
import Logger from '/imports/startup/server/logger';
|
||||
import RedisPubSub from '/imports/startup/server/redis';
|
||||
import { translateHTML5ToFlash } from '/imports/api/common/server/helpers';
|
||||
import RegexWebUrl from '/imports/utils/regex-weburl';
|
||||
|
||||
const HTML_SAFE_MAP = {
|
||||
|
@ -1,16 +1,3 @@
|
||||
import { logger } from '/imports/startup/server/logger';
|
||||
import { redisPubSub } from '/imports/startup/server';
|
||||
import { BREAK_LINE, CARRIAGE_RETURN, NEW_LINE } from '/imports/utils/lineEndings.js';
|
||||
|
||||
export function appendMessageHeader(eventName, messageObj) {
|
||||
let header;
|
||||
header = {
|
||||
timestamp: new Date().getTime(),
|
||||
name: eventName,
|
||||
};
|
||||
messageObj.header = header;
|
||||
return messageObj;
|
||||
}
|
||||
|
||||
export const indexOf = [].indexOf || function (item) {
|
||||
for (let i = 0, l = this.length; i < l; i++) {
|
||||
@ -22,19 +9,7 @@ export const indexOf = [].indexOf || function (item) {
|
||||
return -1;
|
||||
};
|
||||
|
||||
export function publish(channel, message) {
|
||||
return redisPubSub.publish(channel, message.header.name, message.payload, message.header);
|
||||
}
|
||||
|
||||
// translate '\n' newline character and '\r' carriage
|
||||
// returns to '<br/>' breakline character for Flash
|
||||
export const translateHTML5ToFlash = function (message) {
|
||||
let result = message;
|
||||
result = result.replace(new RegExp(CARRIAGE_RETURN, 'g'), BREAK_LINE);
|
||||
result = result.replace(new RegExp(NEW_LINE, 'g'), BREAK_LINE);
|
||||
return result;
|
||||
};
|
||||
|
||||
//used in 1.1
|
||||
export const inReplyToHTML5Client = function (arg) {
|
||||
return arg.routing.userId === 'nodeJSapp';
|
||||
};
|
||||
|
@ -181,6 +181,7 @@ class MessageList extends Component {
|
||||
time={message.time}
|
||||
chatAreaId={this.props.id}
|
||||
lastReadMessageTime={this.props.lastReadMessageTime}
|
||||
scrollArea={this.scrollArea}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
|
@ -54,20 +54,26 @@ export default class MessageListItem extends Component {
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
const scrollArea = document.getElementById(this.props.chatAreaId);
|
||||
const { scrollArea } = this.props;
|
||||
|
||||
if (scrollArea) {
|
||||
eventsToBeBound.forEach(
|
||||
e => scrollArea.addEventListener(e, this.handleMessageInViewport, false),
|
||||
e => { scrollArea.addEventListener(e, this.handleMessageInViewport, false) },
|
||||
);
|
||||
}
|
||||
|
||||
this.handleMessageInViewport();
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
const scrollArea = document.getElementById(this.props.chatAreaId);
|
||||
const { scrollArea } = this.props;
|
||||
|
||||
if (scrollArea) {
|
||||
eventsToBeBound.forEach(
|
||||
e => scrollArea.removeEventListener(e, this.handleMessageInViewport, false),
|
||||
e => { scrollArea.removeEventListener(e, this.handleMessageInViewport, false) },
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps, prevState) {
|
||||
if (prevState.preventRender && !this.state.preventRender && this.state.pendingChanges) {
|
||||
@ -158,6 +164,7 @@ export default class MessageListItem extends Component {
|
||||
chatAreaId={this.props.chatAreaId}
|
||||
lastReadMessageTime={this.props.lastReadMessageTime}
|
||||
handleReadMessage={this.props.handleReadMessage}
|
||||
scrollArea={this.props.scrollArea}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
|
@ -41,7 +41,7 @@ export default class MessageListItem extends Component {
|
||||
if (!this.ticking) {
|
||||
window.requestAnimationFrame(() => {
|
||||
const node = this.text;
|
||||
const scrollArea = document.getElementById(this.props.chatAreaId);
|
||||
const { scrollArea } = this.props;
|
||||
|
||||
if (isElementInViewport(node)) {
|
||||
this.props.handleReadMessage(this.props.time);
|
||||
@ -63,28 +63,34 @@ export default class MessageListItem extends Component {
|
||||
}
|
||||
|
||||
const node = this.text;
|
||||
const { scrollArea } = this.props;
|
||||
|
||||
if (isElementInViewport(node)) {
|
||||
this.props.handleReadMessage(this.props.time);
|
||||
} else {
|
||||
const scrollArea = document.getElementById(this.props.chatAreaId);
|
||||
if (scrollArea){
|
||||
eventsToBeBound.forEach(
|
||||
e => scrollArea.addEventListener(e, this.handleMessageInViewport, false),
|
||||
e => { scrollArea.addEventListener(e, this.handleMessageInViewport, false) },
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
if (!this.props.lastReadMessageTime > this.props.time) {
|
||||
return;
|
||||
}
|
||||
|
||||
const scrollArea = document.getElementById(this.props.chatAreaId);
|
||||
const { scrollArea } = this.props;
|
||||
|
||||
if (scrollArea) {
|
||||
eventsToBeBound.forEach(
|
||||
e => scrollArea.removeEventListener(e, this.handleMessageInViewport, false),
|
||||
e => { scrollArea.removeEventListener(e, this.handleMessageInViewport, false) },
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
render() {
|
||||
const {
|
||||
text,
|
||||
|
Loading…
Reference in New Issue
Block a user