Implement input history per channel
This commit is contained in:
parent
b6e07a43f5
commit
4c103b467b
@ -115,6 +115,29 @@ export default {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
inputTrap.bind(["up", "down"], (e, key) => {
|
||||||
|
if (e.target.selectionStart !== e.target.selectionEnd) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.channel.inputHistoryPosition === 0) {
|
||||||
|
this.channel.inputHistory[this.channel.inputHistoryPosition] = this.channel.pendingMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (key === "up") {
|
||||||
|
if (this.channel.inputHistoryPosition < this.channel.inputHistory.length - 1) {
|
||||||
|
this.channel.inputHistoryPosition++;
|
||||||
|
}
|
||||||
|
} else if (this.channel.inputHistoryPosition > 0) {
|
||||||
|
this.channel.inputHistoryPosition--;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.channel.pendingMessage = this.$refs.input.value = this.channel.inputHistory[this.channel.inputHistoryPosition];
|
||||||
|
this.setInputSize();
|
||||||
|
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
if (this.$root.fileUploadEnabled) {
|
if (this.$root.fileUploadEnabled) {
|
||||||
upload.initialize();
|
upload.initialize();
|
||||||
}
|
}
|
||||||
@ -125,6 +148,7 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
setPendingMessage(e) {
|
setPendingMessage(e) {
|
||||||
this.channel.pendingMessage = e.target.value;
|
this.channel.pendingMessage = e.target.value;
|
||||||
|
this.channel.inputHistoryPosition = 0;
|
||||||
this.setInputSize();
|
this.setInputSize();
|
||||||
},
|
},
|
||||||
setInputSize() {
|
setInputSize() {
|
||||||
@ -166,10 +190,16 @@ export default {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.channel.inputHistoryPosition = 0;
|
||||||
this.channel.pendingMessage = "";
|
this.channel.pendingMessage = "";
|
||||||
this.$refs.input.value = "";
|
this.$refs.input.value = "";
|
||||||
this.setInputSize();
|
this.setInputSize();
|
||||||
|
|
||||||
|
// Store new message in history if last message isn't already equal
|
||||||
|
if (this.channel.inputHistory[1] !== text) {
|
||||||
|
this.channel.inputHistory.splice(1, 0, text);
|
||||||
|
}
|
||||||
|
|
||||||
if (text[0] === "/") {
|
if (text[0] === "/") {
|
||||||
const args = text.substr(1).split(" ");
|
const args = text.substr(1).split(" ");
|
||||||
const cmd = args.shift().toLowerCase();
|
const cmd = args.shift().toLowerCase();
|
||||||
|
@ -71,6 +71,9 @@ function findChannel(id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function initChannel(channel) {
|
function initChannel(channel) {
|
||||||
|
channel.pendingMessage = "";
|
||||||
|
channel.inputHistoryPosition = 0;
|
||||||
|
channel.inputHistory = [""];
|
||||||
channel.historyLoading = false;
|
channel.historyLoading = false;
|
||||||
channel.scrolledToBottom = true;
|
channel.scrolledToBottom = true;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user