Spaces:
Runtime error
Runtime error
Miguel Diaz commited on
Commit ·
cb68eff
1
Parent(s): 97752e5
fix: statics load conversation
Browse files- static/js/chatHandler.js +1 -0
- static/js/windowHandler.js +34 -5
static/js/chatHandler.js
CHANGED
|
@@ -108,6 +108,7 @@ class ChatGPT{
|
|
| 108 |
this.token = data.token;
|
| 109 |
data.execTime = performance.now() - this.execStart;
|
| 110 |
$(this.evCtx).trigger("enviar:exito", data);
|
|
|
|
| 111 |
})
|
| 112 |
.fail(( jqXHR, status, error ) => {
|
| 113 |
console.log("enviado fallido")
|
|
|
|
| 108 |
this.token = data.token;
|
| 109 |
data.execTime = performance.now() - this.execStart;
|
| 110 |
$(this.evCtx).trigger("enviar:exito", data);
|
| 111 |
+
localStorage.setItem("convesacion", JSON.stringify(this.convesacion))
|
| 112 |
})
|
| 113 |
.fail(( jqXHR, status, error ) => {
|
| 114 |
console.log("enviado fallido")
|
static/js/windowHandler.js
CHANGED
|
@@ -9,6 +9,16 @@ class WindowHandler{
|
|
| 9 |
$(this.evCtx).on("chat:cargar", (event, params) => this.cargarChat(params));
|
| 10 |
$(this.evCtx).on("chat:enviar", (event, params) => this.recalcularTextarea());
|
| 11 |
$(this.evCtx).on("chat:limpiar", () => this.limpiarChat());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
}
|
| 13 |
|
| 14 |
limpiarChat(){
|
|
@@ -91,12 +101,31 @@ class WindowHandler{
|
|
| 91 |
|
| 92 |
}
|
| 93 |
|
|
|
|
|
|
|
| 94 |
precargaMensaje(mensaje, role){
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
}
|
| 101 |
|
| 102 |
|
|
|
|
| 9 |
$(this.evCtx).on("chat:cargar", (event, params) => this.cargarChat(params));
|
| 10 |
$(this.evCtx).on("chat:enviar", (event, params) => this.recalcularTextarea());
|
| 11 |
$(this.evCtx).on("chat:limpiar", () => this.limpiarChat());
|
| 12 |
+
$(this.evCtx).on("enviar:reintentar", (event, params) => {
|
| 13 |
+
this.precargaMensaje(params.mensaje, "reenvio")
|
| 14 |
+
});
|
| 15 |
+
$(this.evCtx).on("enviar:fallido", (event, params) => {
|
| 16 |
+
if(params.jqXHR.status == 404){
|
| 17 |
+
this.precargaMensaje(params.mensaje, "token vencido")
|
| 18 |
+
}else{
|
| 19 |
+
this.precargaMensaje(params.mensaje, "fallido")
|
| 20 |
+
}
|
| 21 |
+
});
|
| 22 |
}
|
| 23 |
|
| 24 |
limpiarChat(){
|
|
|
|
| 101 |
|
| 102 |
}
|
| 103 |
|
| 104 |
+
|
| 105 |
+
|
| 106 |
precargaMensaje(mensaje, role){
|
| 107 |
+
if(role=="reenvio"){
|
| 108 |
+
$("message.precarga").find("div p").text("Algo sucedió, estoy reintentando...");
|
| 109 |
+
if(!$("message.precarga").hasClass("warning")){
|
| 110 |
+
$("message.precarga").addClass("warning");
|
| 111 |
+
}
|
| 112 |
+
}else if(role="fallido"){
|
| 113 |
+
$("message.precarga").removeClass("warning");
|
| 114 |
+
$("message.precarga").addClass("error");
|
| 115 |
+
$("message.precarga").find("div p").text("Algo muy malo pasó 🤷♂️");
|
| 116 |
+
$("message.precarga").removeClass("precarga");
|
| 117 |
+
}else if(role="token vencido"){
|
| 118 |
+
$("message.precarga").removeClass("warning");
|
| 119 |
+
$("message.precarga").addClass("error");
|
| 120 |
+
$("message.precarga").find("div p").text("El token se venció 🤦♂️, recarga la pagina");
|
| 121 |
+
$("message.precarga").removeClass("precarga");
|
| 122 |
+
}else{
|
| 123 |
+
let clone = this.template.clone();
|
| 124 |
+
clone.addClass("precarga");
|
| 125 |
+
clone.find("div p").html("Cargando...");
|
| 126 |
+
this.chatbox.append(clone);
|
| 127 |
+
this.chatbox.scrollTop(this.chatbox[0].scrollHeight);
|
| 128 |
+
}
|
| 129 |
}
|
| 130 |
|
| 131 |
|