small bug fix with async socket
This commit is contained in:
@@ -235,7 +235,7 @@ export default {
|
|||||||
if (!conversationDiv) throw new Error('wtf');
|
if (!conversationDiv) throw new Error('wtf');
|
||||||
conversationDiv.scrollTo(0, conversationDiv.scrollHeight);
|
conversationDiv.scrollTo(0, conversationDiv.scrollHeight);
|
||||||
},
|
},
|
||||||
typing(event: KeyboardEvent) {
|
async typing(event: KeyboardEvent) {
|
||||||
const { $io } = useNuxtApp();
|
const { $io } = useNuxtApp();
|
||||||
|
|
||||||
const specialKeys = [
|
const specialKeys = [
|
||||||
@@ -252,7 +252,7 @@ export default {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$io.emit('typing', this.channel.id);
|
(await $io).emit('typing', this.channel.id);
|
||||||
},
|
},
|
||||||
mouseEnter() {
|
mouseEnter() {
|
||||||
document.body.addEventListener('keydown', this.keyPressed, false);
|
document.body.addEventListener('keydown', this.keyPressed, false);
|
||||||
@@ -344,12 +344,12 @@ export default {
|
|||||||
this.search.show = false;
|
this.search.show = false;
|
||||||
this.$refs.messageBox.focus();
|
this.$refs.messageBox.focus();
|
||||||
},
|
},
|
||||||
listenToWebsocket(conversationDiv: HTMLElement) {
|
async listenToWebsocket(conversationDiv: HTMLElement) {
|
||||||
const { $io } = useNuxtApp();
|
let { $io } = useNuxtApp();
|
||||||
|
|
||||||
$io.removeAllListeners();
|
(await $io).removeAllListeners();
|
||||||
|
|
||||||
$io.on(`message-${this.channel.id}`, (ev: { message: IMessage, deleted?: boolean }) => {
|
(await $io).on(`message-${this.channel.id}`, (ev: { message: IMessage, deleted?: boolean }) => {
|
||||||
let { message, deleted } = ev;
|
let { message, deleted } = ev;
|
||||||
|
|
||||||
if (deleted) {
|
if (deleted) {
|
||||||
@@ -384,7 +384,7 @@ export default {
|
|||||||
});
|
});
|
||||||
|
|
||||||
let timeout: NodeJS.Timeout;
|
let timeout: NodeJS.Timeout;
|
||||||
$io.on(`typing-${this.channel.id}`, (ev: string) => {
|
(await $io).on(`typing-${this.channel.id}`, (ev: string) => {
|
||||||
if (ev === this.user?.username) return;
|
if (ev === this.user?.username) return;
|
||||||
clearTimeout(timeout);
|
clearTimeout(timeout);
|
||||||
timeout = setTimeout(() => {
|
timeout = setTimeout(() => {
|
||||||
|
|||||||
@@ -75,10 +75,10 @@ export default {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted() {
|
async mounted() {
|
||||||
const { $io } = useNuxtApp();
|
const { $io } = useNuxtApp();
|
||||||
|
|
||||||
$io.on(`addChannel-${this.server.id}`, (ev) => {
|
(await $io).on(`addChannel-${this.server.id}`, (ev) => {
|
||||||
const newChannel = ev as IChannel;
|
const newChannel = ev as IChannel;
|
||||||
useServerStore().addChannel(this.server.id, newChannel);
|
useServerStore().addChannel(this.server.id, newChannel);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -12,8 +12,6 @@ export default defineEventHandler(({ node }) => {
|
|||||||
global.io.on('connection', async (socket: Socket) => {
|
global.io.on('connection', async (socket: Socket) => {
|
||||||
const token = socket.handshake.auth.token;
|
const token = socket.handshake.auth.token;
|
||||||
|
|
||||||
console.log(token);
|
|
||||||
|
|
||||||
if (!token) {
|
if (!token) {
|
||||||
socket.disconnect();
|
socket.disconnect();
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user