ws
This commit is contained in:
1 parent
0bf75d7faa
commit
65d37eeb61
11 files changed
+708
-19
No files matched your search
+3
-1
@@ -3,7 +3,7 @@ import { useState, useEffect } from 'preact/hooks';
|
||||
import { Route, Router, route } from 'preact-router';
|
||||
import { Provider, connect } from 'unistore/preact'
|
||||
|
||||
import { createStore, actions } from './store';
|
||||
import createStore from './store';
|
||||
import createWs from './ws';
|
||||
import http from './http';
|
||||
|
||||
@@ -19,6 +19,8 @@ import List from './routes/list';
|
||||
const store = createStore();
|
||||
const ws = createWs(store);
|
||||
|
||||
ws.connect();
|
||||
|
||||
async function init() {
|
||||
const [error, user] = await http.getLogin();
|
||||
if (error) return route('/login');
|
||||
|
||||
@@ -3,7 +3,7 @@ import { route } from 'preact-router';
|
||||
import { connect } from 'unistore/preact'
|
||||
|
||||
import http from './../http';
|
||||
import { actions } from './../actions';
|
||||
import actions from './../actions';
|
||||
|
||||
const Header = ({ user, logout }) => {
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import { route } from 'preact-router';
|
||||
import { connect } from 'unistore/preact'
|
||||
|
||||
import http from './../http';
|
||||
import { actions } from './../actions';
|
||||
import actions from './../actions';
|
||||
|
||||
import Offer from './../components/offer';
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import { useState, useEffect, useRef } from 'preact/hooks';
|
||||
import { connect } from 'unistore/preact'
|
||||
|
||||
import http from './../http';
|
||||
import { actions } from './../actions';
|
||||
import actions from './../actions';
|
||||
|
||||
const Login = ({ setUser, mode }) => {
|
||||
const [email, setEmail] = useState('')
|
||||
|
||||
+5
-3
@@ -1,6 +1,8 @@
|
||||
const SOCKET_URL = (window.location.host.includes('localhost') || window.location.host === '' || window.location.host.includes('192.168.0'))
|
||||
? `ws://${window.location.hostname}:40080`
|
||||
: `${window.location.protocol === 'https:' ? 'wss://' : 'ws://'}${window.location.host}/api/ws`;
|
||||
// const SOCKET_URL = (window.location.host.includes('localhost') || window.location.host === '' || window.location.host.includes('192.168.0'))
|
||||
// ? `ws://${window.location.hostname}:40080`
|
||||
// : `${window.location.protocol === 'https:' ? 'wss://' : 'ws://'}${window.location.host}/api/ws`;
|
||||
|
||||
const SOCKET_URL = `${window.location.protocol === 'https:' ? 'wss://' : 'ws://'}${window.location.host}/api/ws`;
|
||||
|
||||
export default function createSocket(store) {
|
||||
let ws;
|
||||
|
||||
Reference in new issue
Block a user