chat: fixed indentation

logging for scrollback
This commit is contained in:
Logan Allen 2020-03-24 18:49:04 -04:00
parent 16b4e2e8e4
commit 8d64d9d253
5 changed files with 299 additions and 287 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -84,18 +84,24 @@ export class ChatScreen extends Component {
askForMessages() {
const { props, state } = this;
console.log('askForMessages');
if (
state.numPages * 100 < props.length - 400 ||
this.hasAskedForMessages
) {
console.log('condition 1: ', state.numPages * 100 < props.length - 400);
console.log('condition 2: ', this.hasAskedForMessages);
return;
}
console.log('length: ', props.length);
if (props.length > 0) {
let end = props.envelopes[0].number;
console.log('end: ', end);
if (end > 0) {
let start = end - 400 > 0 ? end - 400 : 0;
console.log('start: ', start);
if (start === 0 && end === 1) {
return;
}
@ -119,7 +125,9 @@ export class ChatScreen extends Component {
navigator.userAgent.includes("Chrome")
) {
// Google Chrome
console.log('scrollTop: ', e.target.scrollTop);
if (e.target.scrollTop === 0) {
console.log('google chrome');
this.setState(
{
numPages: this.state.numPages + 1,
@ -140,6 +148,7 @@ export class ChatScreen extends Component {
}
} else if (navigator.userAgent.includes("Safari")) {
// Safari
console.log('safari');
if (e.target.scrollTop === 0) {
this.setState({
numPages: 1,

View File

@ -125,7 +125,7 @@ export class ChatInput extends Component {
this.textareaInput = _.debounce(this.textareaInput.bind(this), 16);
// perf testing:
/*let closure = () => {
let closure = () => {
let x = 0;
for (var i = 0; i < 30; i++) {
x++;
@ -140,7 +140,7 @@ export class ChatInput extends Component {
}
setTimeout(closure, 1000);
};
this.closure = closure.bind(this);*/
this.closure = closure.bind(this);
moment.updateLocale('en', {
relativeTime : {
@ -400,6 +400,7 @@ export class ChatInput extends Component {
}
})
if (message.length > 0) {
message = message.join(" ");
message = this.getLetterType(message);
@ -412,7 +413,8 @@ export class ChatInput extends Component {
message = [];
}
// perf: setTimeout(this.closure, 2000);
// perf:
setTimeout(this.closure, 2000);
this.setState({
message: '',

View File

@ -69,6 +69,7 @@ export class Subscription {
fetch(`/~chat/paginate/${start}/${end}${path}`)
.then((response) => response.json())
.then((json) => {
console.log(json);
store.handleEvent({
data: json
});