-import { ref, computed, inject } from 'vue';
-import useTextInputAnims from "./textAnime";
-import { Ref } from "@/types/vueRef/index";
/*
* text rendering logic used by inputController
*/
+
+import { ref, computed, onMounted, onUnmounted } from 'vue';
+import useTextInputAnims from "./textAnime";
+import { Ref } from "@/types/vueRef/index";
+import useMitt from "@/modules/mitt";
+
export default function useTextVisualizer(input: Ref<string>) {
const inputHeight = ref(42);
const inputWidth = ref(0);
-
- const emitter: any = inject("mitt");
+ const { emitter } = useMitt();
const { animateSend, verticalShiftInput, inputAppear } = useTextInputAnims();
async function renderTextInput() {
}
}
- emitter.on("user-message", () => {
- const inputEl = document.getElementsByClassName("inputContainer");
- const foreignEl = inputEl[0] as HTMLElement;
- animateSend(foreignEl, inputHeight.value, input);
+ onMounted(() => {
+ emitter.on("user-message", () => {
+ const inputEl = document.getElementsByClassName("inputContainer");
+ const foreignEl = inputEl[0] as HTMLElement;
+ animateSend(foreignEl, inputHeight.value, input);
+ });
+ });
+
+ onUnmounted(() => {
+ emitter.all.clear();
});
const textInputXoffset = computed(() => {
ws.on("message", function incoming(message) {
console.log(message)
- if (message === 'no-token' || message === 'undefined') {
- console.log('no token to authenticate');
- ws.send('locked');
- }
+ if (message === 'no-token' || message === 'undefined') {
+ console.log('no token to authenticate');
+ ws.send('success');
+ }
});