diff --git a/build/index.html b/build/index.html
index a8f668f..a14a855 100644
--- a/build/index.html
+++ b/build/index.html
@@ -4,10 +4,10 @@
-
+
-
+
Carbon
diff --git a/build/static/chat-input.js b/build/static/chat-input.js
index a245c52..d8c0a35 100644
--- a/build/static/chat-input.js
+++ b/build/static/chat-input.js
@@ -1,29 +1,36 @@
import {q} from "./basic.js"
import {store} from "./store/store.js"
import * as lsm from "./lsm.js"
+import {chat} from "./chat.js"
let sentIndex = 0
-const chat = q("#c-chat-textarea")
+const input = q("#c-chat-textarea")
-chat.addEventListener("keydown", event => {
+store.activeRoom.subscribe("changeSelf", () => {
+ if (store.activeRoom.exists()) {
+ input.focus()
+ }
+})
+
+input.addEventListener("keydown", event => {
if (event.key === "Enter" && !event.shiftKey && !event.ctrlKey) {
event.preventDefault()
- const body = chat.value
- send(chat.value)
- chat.value = ""
+ const body = input.value
+ send(input.value)
+ input.value = ""
fixHeight()
}
})
-chat.addEventListener("input", () => {
+input.addEventListener("input", () => {
fixHeight()
})
function fixHeight() {
- chat.style.height = "0px"
- console.log(chat.clientHeight, chat.scrollHeight)
- chat.style.height = (chat.scrollHeight + 1) + "px"
+ input.style.height = "0px"
+ // console.log(input.clientHeight, input.scrollHeight)
+ input.style.height = (input.scrollHeight + 1) + "px"
}
function getTxnId() {
diff --git a/build/static/chat.js b/build/static/chat.js
index 38c4684..9958dc3 100644
--- a/build/static/chat.js
+++ b/build/static/chat.js
@@ -34,7 +34,7 @@ class Chat extends ElemJS {
let oldDifference = chatMessages.scrollHeight - chatMessages.clientHeight
setTimeout(() => {
let newDifference = chatMessages.scrollHeight - chatMessages.clientHeight
- console.log("height difference", oldDifference, newDifference)
+ // console.log("height difference", oldDifference, newDifference)
if (oldDifference < 24) { // this is jank
this.element.parentElement.scrollBy(0, 1000)
}
diff --git a/build/static/store/SubscribeMapList.js b/build/static/store/SubscribeMapList.js
index e5ae4ed..b26d58c 100644
--- a/build/static/store/SubscribeMapList.js
+++ b/build/static/store/SubscribeMapList.js
@@ -54,7 +54,6 @@ class SubscribeMapList extends Subscribable {
}
sort() {
- console.log("sorting")
this.list.sort((a, b) => {
const orderA = this.map.get(a).value().order
const orderB = this.map.get(b).value().order
diff --git a/src/js/chat-input.js b/src/js/chat-input.js
index e06db8a..d8c0a35 100644
--- a/src/js/chat-input.js
+++ b/src/js/chat-input.js
@@ -7,6 +7,12 @@ let sentIndex = 0
const input = q("#c-chat-textarea")
+store.activeRoom.subscribe("changeSelf", () => {
+ if (store.activeRoom.exists()) {
+ input.focus()
+ }
+})
+
input.addEventListener("keydown", event => {
if (event.key === "Enter" && !event.shiftKey && !event.ctrlKey) {
event.preventDefault()
@@ -23,7 +29,7 @@ input.addEventListener("input", () => {
function fixHeight() {
input.style.height = "0px"
- console.log(input.clientHeight, input.scrollHeight)
+ // console.log(input.clientHeight, input.scrollHeight)
input.style.height = (input.scrollHeight + 1) + "px"
}
diff --git a/src/js/chat.js b/src/js/chat.js
index 38c4684..9958dc3 100644
--- a/src/js/chat.js
+++ b/src/js/chat.js
@@ -34,7 +34,7 @@ class Chat extends ElemJS {
let oldDifference = chatMessages.scrollHeight - chatMessages.clientHeight
setTimeout(() => {
let newDifference = chatMessages.scrollHeight - chatMessages.clientHeight
- console.log("height difference", oldDifference, newDifference)
+ // console.log("height difference", oldDifference, newDifference)
if (oldDifference < 24) { // this is jank
this.element.parentElement.scrollBy(0, 1000)
}