убрал console.log,, фикс реги, фикк отображение чатов при создании
This commit is contained in:
parent
9569071a2a
commit
206d850f03
10 changed files with 43 additions and 1390 deletions
|
@ -15,7 +15,7 @@ export async function getLastMessages(chatId,msgLoaded){
|
|||
if(response.ok){
|
||||
let data = await response.json()
|
||||
let msgMassive = data.messages
|
||||
console.log(msgMassive, " аа сообщения", chatId, " - айди")
|
||||
//console.log(msgMassive, " аа сообщения", chatId, " - айди")
|
||||
|
||||
if(msgMassive === null){
|
||||
return []
|
||||
|
@ -73,7 +73,7 @@ export async function getLastMessages(chatId,msgLoaded){
|
|||
|
||||
if(response.ok){
|
||||
const data = await response.json();
|
||||
console.log("картинка принята")
|
||||
//console.log("картинка принята")
|
||||
return data.image_url;
|
||||
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ export async function getLastMessages(chatId,msgLoaded){
|
|||
if(response.ok){
|
||||
let data = await response.json();
|
||||
data = data.allowed_chats
|
||||
console.log(data)
|
||||
//console.log(data)
|
||||
|
||||
if(data == null)
|
||||
return []
|
||||
|
@ -209,7 +209,9 @@ export async function getLastMessages(chatId,msgLoaded){
|
|||
if(response.ok){
|
||||
let data = await response.json()
|
||||
let id = data.chat_id
|
||||
return id
|
||||
let chats = await getAllChats(token)
|
||||
window.location.href = `/c#id=${id}`
|
||||
return chats
|
||||
}
|
||||
else{
|
||||
console.log(response)
|
||||
|
|
|
@ -23,7 +23,7 @@ export async function handleLogin(username, password) {
|
|||
const data = await response.json()
|
||||
const token = data.authorization
|
||||
localStorage.setItem('BPChat', token)
|
||||
window.location.href = '/'
|
||||
window.location.href = '/c'
|
||||
return "" // чтобы ничего не выводилось в качестве ошибки
|
||||
}
|
||||
else if(response.status === 401)
|
||||
|
|
|
@ -21,7 +21,7 @@ export async function checkExsistingUser(username, email) {
|
|||
}
|
||||
else if(response.status === 422){
|
||||
let data = await response.json();
|
||||
return data
|
||||
return "не похоже на почту"
|
||||
}
|
||||
else{
|
||||
console.log(response.status)
|
||||
|
|
|
@ -19,7 +19,6 @@ export async function getAvatarHistory(token){
|
|||
}
|
||||
|
||||
export async function getConfirmationCode(token, email){
|
||||
console.log(token, email, "<-- лох")
|
||||
const response = await fetch(`${PUBLIC_URL}/api/users/send_confirmation_code`,{
|
||||
method: 'POST',
|
||||
credentials:'include',
|
||||
|
|
|
@ -14,9 +14,8 @@ export default function createWebSocket(url, token, onMessageCallback) {
|
|||
});
|
||||
|
||||
socket.onopen = () => {
|
||||
console.log('WebSocket is open now.')
|
||||
console.log(socket)
|
||||
retries = 0 //сброс попыток
|
||||
//console.log('WebSocket is open .')
|
||||
//console.log(socket)
|
||||
|
||||
while (messageQueue.length > 0) {
|
||||
socket.send(messageQueue.shift());
|
||||
|
@ -24,11 +23,11 @@ export default function createWebSocket(url, token, onMessageCallback) {
|
|||
};
|
||||
|
||||
socket.onclose = (event) => {
|
||||
console.log('WebSocket is closed now.', event)
|
||||
//console.log('WebSocket is closed .', event)
|
||||
};
|
||||
|
||||
socket.onerror = (error) => {
|
||||
console.error('WebSocket error observed:', error)
|
||||
//console.error('WebSocket error observed:', error)
|
||||
};
|
||||
|
||||
|
||||
|
|
7
src/routes/+error.svelte
Normal file
7
src/routes/+error.svelte
Normal file
|
@ -0,0 +1,7 @@
|
|||
<script>
|
||||
import { onMount } from "svelte";
|
||||
|
||||
onMount(() => {
|
||||
window.location.assign('/c');
|
||||
})
|
||||
</script>
|
File diff suppressed because it is too large
Load diff
|
@ -8,7 +8,6 @@
|
|||
|
||||
let Nickname;
|
||||
let userImage;
|
||||
let jopa = 0;
|
||||
|
||||
onMount(async () => {
|
||||
const UserData = await UserCheck();
|
||||
|
@ -24,7 +23,7 @@
|
|||
</script>
|
||||
|
||||
<header>
|
||||
<a href="/" class="avatarDiv">
|
||||
<a href="/c" class="avatarDiv">
|
||||
<img class="siteAvatar" src="./image/BP-NEON.png" alt="лого"/>
|
||||
<h2>BP Chat</h2>
|
||||
</a>
|
||||
|
|
|
@ -188,7 +188,6 @@
|
|||
|
||||
const emailPattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
||||
let isValidEmail = emailPattern.test(newEmail)
|
||||
console.log(isValidEmail)
|
||||
|
||||
if((newEmail != "") && (isValidEmail == true)){
|
||||
emailError = await checkExsistingUser(null, newEmail)
|
||||
|
|
|
@ -56,7 +56,7 @@
|
|||
window.addEventListener('keydown', onEnterPress);
|
||||
|
||||
chats = await getAllChats(token)
|
||||
console.log([] == false)
|
||||
//console.log([] == false) // true
|
||||
if(chats === false){
|
||||
chats = []
|
||||
warningMessage = "чтобы пользоваться чатом, подтверди почту"
|
||||
|
@ -66,16 +66,16 @@
|
|||
|
||||
async function handleChatUrlChange() {
|
||||
if (window.location.hash.startsWith('#id=')) {
|
||||
console.log(location.hash.substring(1), "FFFFFFFFFFFFFFFFFFFFFFFFFFFF")
|
||||
chatId = window.location.hash.slice(4);
|
||||
msgLoaded = 0
|
||||
//console.log(chatId, " chatId")
|
||||
|
||||
msgLoaded = 0
|
||||
|
||||
currentChat = chats.find(chat => chat.chat_id == chatId)
|
||||
|
||||
if(currentChat == undefined){
|
||||
window.location.href = '/'
|
||||
}
|
||||
//if(currentChat == undefined){
|
||||
// window.location.href = '/c'
|
||||
//}
|
||||
//console.log(currentChat, " текущий чат")
|
||||
pickedChatName = currentChat.chat_name
|
||||
pickedChatImg = currentChat.avatar_image
|
||||
|
@ -87,7 +87,7 @@
|
|||
const websocketUrl = `${PUBLIC_WSS}/api/chat/ws/${chatId}`
|
||||
|
||||
if (socket){
|
||||
console.log("Сокет есть")
|
||||
//console.log("Сокет есть")
|
||||
socket.close();
|
||||
socket = null
|
||||
}
|
||||
|
@ -122,6 +122,8 @@
|
|||
messages = messages
|
||||
|
||||
})
|
||||
} else {
|
||||
messages = []
|
||||
}
|
||||
}
|
||||
handleChatUrlChange();
|
||||
|
@ -182,6 +184,7 @@
|
|||
if(!isLoaded)
|
||||
sendMessage()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
let rows = 1
|
||||
|
@ -191,9 +194,9 @@
|
|||
const textarea = document.getElementById("msg");
|
||||
//console.log(textarea.scrollHeight)
|
||||
if (textarea) {
|
||||
textarea.style.height = '1em'; //??
|
||||
textarea.style.height = '20px'; //??
|
||||
textarea.style.height = (textarea.scrollHeight > maxRows * 18) ? `${maxRows * 18}px` : `${textarea.scrollHeight}px`;
|
||||
console.log(textarea.scrollHeight)
|
||||
//console.log(textarea.scrollHeight)
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -380,15 +383,8 @@ let pinOrNot = false
|
|||
}
|
||||
|
||||
async function submtiCreateNewChat(){
|
||||
token = localStorage.getItem('BPChat')
|
||||
let newChatId = await createNewChat(newChatName, selectedUserId, token)
|
||||
window.location.href = `/#id=${newChatId}`
|
||||
|
||||
//createNewChatShow = false
|
||||
|
||||
//history.pushState(null, null, `/#id=${newChatId}`);
|
||||
//handleRouteChange();
|
||||
//chats = await getAllChats()
|
||||
chats = await createNewChat(newChatName, selectedUserId, token)
|
||||
createNewChatShow = false
|
||||
}
|
||||
|
||||
function cancelCreateNewChat(){
|
||||
|
@ -426,11 +422,11 @@ let pinOrNot = false
|
|||
|
||||
async function deleteChatButt(chatId){
|
||||
let result = await deleteChat(chatId,token)
|
||||
const index = chats.findIndex(chat => chat.chat_id === chatId);
|
||||
chats.splice(index, 1);
|
||||
//const index = chats.findIndex(chat => chat.chat_id === chatId);
|
||||
//chats.splice(index, 1);
|
||||
//console.log(index)
|
||||
//console.log(result)
|
||||
chats = await getAllChats()
|
||||
//chats = await getAllChats(token)
|
||||
}
|
||||
</script>
|
||||
|
||||
|
@ -494,7 +490,7 @@ let pinOrNot = false
|
|||
{#each chats as chat}
|
||||
<div class="chatDivLeft" class:chatDivLeftSelected="{chat.chat_id == chatId}"
|
||||
transition:fade={{ duration: 800 }}>
|
||||
<a class="aChatDivLeft" href={`/chat#id=${chat.chat_id}`}>
|
||||
<a class="aChatDivLeft" href={`/c#id=${chat.chat_id}`}>
|
||||
<img class="chatImage" src="{chat.avatar_image}" alt="аватарка">
|
||||
<h2 class="chatName">{chat.chat_name}</h2>
|
||||
{#if chat.created_by == userId}
|
||||
|
@ -958,9 +954,12 @@ let pinOrNot = false
|
|||
}
|
||||
|
||||
.textMsg{
|
||||
//min-height: calc(48px);
|
||||
//max-height: 180px;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
|
||||
}
|
||||
|
||||
.imageFile{
|
Loading…
Add table
Reference in a new issue