Merge branch 'master' into mp/chat/input-autofocus

This commit is contained in:
Matilde Park 2020-04-29 16:27:29 -04:00
commit 34b234b652
4 changed files with 20 additions and 13 deletions

View File

@ -178,8 +178,11 @@ class Channel {
this.lastEventId = e.lastEventId; this.lastEventId = e.lastEventId;
let obj = JSON.parse(e.data); let obj = JSON.parse(e.data);
if (obj.response == "poke") { let pokeFuncs = this.outstandingPokes.get(obj.id);
let funcs = this.outstandingPokes.get(obj.id); let subFuncs = this.outstandingSubscriptions.get(obj.id);
if (obj.response == "poke" && !!pokeFuncs) {
let funcs = pokeFuncs;
if (obj.hasOwnProperty("ok")) { if (obj.hasOwnProperty("ok")) {
funcs["success"](); funcs["success"]();
} else if (obj.hasOwnProperty("err")) { } else if (obj.hasOwnProperty("err")) {
@ -189,19 +192,20 @@ class Channel {
} }
this.outstandingPokes.delete(obj.id); this.outstandingPokes.delete(obj.id);
} else if (obj.response == "subscribe") { } else if (obj.response == "subscribe" ||
(obj.response == "poke" && !!subFuncs)) {
let funcs = subFuncs;
// on a response to a subscribe, we only notify the caller on err // on a response to a subscribe, we only notify the caller on err
// //
let funcs = this.outstandingSubscriptions.get(obj.id);
if (obj.hasOwnProperty("err")) { if (obj.hasOwnProperty("err")) {
funcs["err"](obj.err); funcs["err"](obj.err);
this.outstandingSubscriptions.delete(obj.id); this.outstandingSubscriptions.delete(obj.id);
} }
} else if (obj.response == "diff") { } else if (obj.response == "diff") {
let funcs = this.outstandingSubscriptions.get(obj.id); let funcs = subFuncs;
funcs["event"](obj.json); funcs["event"](obj.json);
} else if (obj.response == "quit") { } else if (obj.response == "quit") {
let funcs = this.outstandingSubscriptions.get(obj.id); let funcs = subFuncs;
funcs["quit"](obj); funcs["quit"](obj);
this.outstandingSubscriptions.delete(obj.id); this.outstandingSubscriptions.delete(obj.id);
} else { } else {

View File

@ -71,7 +71,7 @@ h2 {
} }
.clamp-attachment { .clamp-attachment {
overflow: scroll; overflow: auto;
max-height: 10em; max-height: 10em;
max-width: 100%; max-width: 100%;
} }

View File

@ -2,6 +2,7 @@ import React, { Component } from 'react';
import _ from 'lodash'; import _ from 'lodash';
import moment from 'moment'; import moment from 'moment';
import { UnControlled as CodeEditor } from 'react-codemirror2'; import { UnControlled as CodeEditor } from 'react-codemirror2';
import CodeMirror from 'codemirror';
import 'codemirror/mode/markdown/markdown'; import 'codemirror/mode/markdown/markdown';
import 'codemirror/addon/display/placeholder'; import 'codemirror/addon/display/placeholder';
@ -173,7 +174,7 @@ export class ChatInput extends Component {
isUrl(string) { isUrl(string) {
try { try {
const websiteTest = new RegExp(String(/((\w+:\/\/)[-a-zA-Z0-9:@;?&=\/%\+\.\*!'\(\),\$_\{\}\^~\[\]`#|]+)/.source) const websiteTest = new RegExp(String(/^((\w+:\/\/)[-a-zA-Z0-9:@;?&=\/%\+\.\*!'\(\),\$_\{\}\^~\[\]`#|]+)/.source)
); );
return websiteTest.test(string); return websiteTest.test(string);
} catch (e) { } catch (e) {
@ -306,7 +307,9 @@ export class ChatInput extends Component {
'Enter': cm => 'Enter': cm =>
this.messageSubmit(), this.messageSubmit(),
'Shift-3': cm => 'Shift-3': cm =>
this.toggleCode() cm.getValue().length === 0
? this.toggleCode()
: CodeMirror.Pass
} }
}; };

View File

@ -65,17 +65,17 @@ export class Message extends Component {
(!!letter.code.output && (!!letter.code.output &&
letter.code.output.length && letter.code.output.length > 0) ? letter.code.output.length && letter.code.output.length > 0) ?
( (
<pre className="f7 clamp-attachment pa1 mt0 mb0"> <pre className="f7 clamp-attachment pa1 mt0 mb0 b--gray4 b--gray1-d bl br bb">
{letter.code.output[0].join('\n')} {letter.code.output[0].join('\n')}
</pre> </pre>
) : null; ) : null;
return ( return (
<span> <div className="mv2">
<pre className="f7 clamp-attachment pa1 mt0 mb0 bg-light-gray"> <pre className="f7 clamp-attachment pa1 mt0 mb0 bg-light-gray b--gray4 b--gray1-d ba">
{letter.code.expression} {letter.code.expression}
</pre> </pre>
{outputElement} {outputElement}
</span> </div>
); );
} else if ('url' in letter) { } else if ('url' in letter) {
let imgMatch = let imgMatch =