if password changed, other users cannot continue to send message
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
import { msgs, layout, allowed_chars } from './Store_chat';
|
||||
import { change_room, create_room } from './Request_rooms';
|
||||
import { onMount } from 'svelte';
|
||||
import { FetchResponse } from './Types_chat';
|
||||
import type { FetchResponse } from './Types_chat';
|
||||
import Button from './Element_button.svelte';
|
||||
import Warning from './Element_warning.svelte';
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import { layout, current_room } from './Store_chat';
|
||||
import { change_room, validate_password, change_password, add_password, remove_password } from './Request_rooms';
|
||||
import { FetchResponse } from './Types_chat';
|
||||
import type { FetchResponse } from './Types_chat';
|
||||
import Button from './Element_button.svelte';
|
||||
import Warning from './Element_warning.svelte';
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
if (msg.length > 0) {
|
||||
socket.emit('message', msg);
|
||||
add_msg("me", msg);
|
||||
console.log(msgs);
|
||||
}
|
||||
|
||||
msg = "";
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { msgs, user, layout, socket, current_room } from './Store_chat';
|
||||
import { Room, FetchResponse, FetchMethod } from './Types_chat';
|
||||
import type { Room, FetchResponse } from './Types_chat';
|
||||
import { FetchMethod } from './Utils_chat';
|
||||
import { fetch_chat_request, set_client_name_on_room, fill_fetch_response } from './Request_utils';
|
||||
|
||||
export async function get_room_messages()
|
||||
@@ -9,7 +10,6 @@ export async function get_room_messages()
|
||||
let response: FetchResponse = await fetch_chat_request('messages', FetchMethod.GET);
|
||||
|
||||
const messages = response.messages;
|
||||
|
||||
if (messages === null)
|
||||
return;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { user } from './Store_chat';
|
||||
import { Room, FetchResponse, FetchInit, FetchMethod } from './Types_chat';
|
||||
import type { Room, FetchResponse, FetchInit } from './Types_chat';
|
||||
import type { FetchMethod } from './Utils_chat';
|
||||
|
||||
export async function fetch_chat_request(route: string, fetchMethod: FetchMethod, param?: any)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import io from 'socket.io-client';
|
||||
import { set_socket, set_user } from './Store_chat';
|
||||
import { user, msgs } from './Store_chat';
|
||||
import { user, msgs, layout } from './Store_chat';
|
||||
|
||||
const address = `http://${process.env.WEBSITE_HOST}:${process.env.WEBSITE_PORT}`;
|
||||
|
||||
@@ -34,6 +34,12 @@ function socket_events(socket)
|
||||
from = "me";
|
||||
msgs.update(msgs => [...msgs, { name: from, message: message }]);
|
||||
});
|
||||
|
||||
socket.on('new_password', function()
|
||||
{
|
||||
console.log("notification new password:");
|
||||
layout.set("password");
|
||||
});
|
||||
}
|
||||
|
||||
function socket_states(socket)
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { writable } from 'svelte/store';
|
||||
import { Room } from './Types_chat';
|
||||
import type { Room, Message } from './Types_chat';
|
||||
|
||||
export let msgs = writable([]);
|
||||
export let layout = writable("close");
|
||||
export let current_room: Room = writable({
|
||||
export let current_room = writable({
|
||||
name: "",
|
||||
type: "",
|
||||
protection: false,
|
||||
|
||||
@@ -8,13 +8,22 @@ export interface Room
|
||||
allowed?: boolean;
|
||||
}
|
||||
|
||||
export interface Message
|
||||
{
|
||||
name: string;
|
||||
type: string;
|
||||
}
|
||||
|
||||
export interface FetchResponse
|
||||
{
|
||||
status: number;
|
||||
error?: boolean;
|
||||
code?: string;
|
||||
message?: string;
|
||||
messages?: Message[];
|
||||
users?: string[];
|
||||
room?: Room;
|
||||
rooms?: Room[];
|
||||
}
|
||||
|
||||
export interface FetchInit
|
||||
@@ -24,10 +33,3 @@ export interface FetchInit
|
||||
body?: string;
|
||||
}
|
||||
|
||||
export enum FetchMethod
|
||||
{
|
||||
POST = 'POST',
|
||||
GET = 'GET',
|
||||
DELETE = 'DELETE',
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
export enum FetchMethod
|
||||
{
|
||||
POST = 'POST',
|
||||
GET = 'GET',
|
||||
DELETE = 'DELETE',
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user