Compare commits

..

No commits in common. '1f41ec6a12bbfa970584e1118f9fbe2f84092b54' and '087526d1c620c02f6bdde544b0c6d5e66cac4c9c' have entirely different histories.

  1. 1
      package.json
  2. 9
      src/App.js
  3. 22
      src/Redux/proxy.js
  4. 2
      src/Redux/reducers/user.js
  5. 34
      src/Router.js
  6. 3
      src/history.js
  7. 2
      src/views/Auth/Auth.js
  8. 36
      src/views/ChatRoom/Body/Body.js
  9. 11
      src/views/ChatRoom/Body/Message/Message2D/Message2D.js
  10. 2
      src/views/ChatRoom/Body/Message/NormalMessage/NormalMessage.js
  11. 2
      src/views/ChatRoom/Body/Message/RadioMessage/RadioMessage.js
  12. 2
      src/views/ChatRoom/Body/Message/SliderMessage/SliderMessage.js
  13. 5
      src/views/ChatRoom/ChatRoom.js
  14. 2
      src/views/Home/Header/NavbarDrawer/NavbarDrawer.js
  15. 9
      yarn.lock

@ -16,7 +16,6 @@
"babel-plugin-wildcard": "^7.0.0",
"bootstrap": "^4.6.0",
"create-index": "^2.6.0",
"history": "^5.0.0",
"jalali-moment": "^3.3.10",
"leaflet": "^1.7.1",
"node-sass": "^5.0.0",

@ -1,14 +1,9 @@
import React, { Component } from 'react';
import AppRouter from './Router';
import store from './Redux/store';
import { Provider } from 'react-redux';
class App extends Component {
render() {
return (
<Provider store={store}>
<AppRouter />
</Provider>
);
return <AppRouter />;
}
}

@ -4,7 +4,6 @@ const baseURL = 'https://chatstory.ir/api/v1'; //"https://chatstory.ir/api/v1";
const token = '';
const loginURL = 'user/otp/login';
const logoutURL = 'user/logout';
window.baseURL = baseURL;
const Axios = axios.create({
withCredentials: true,
validateStatus: null,
@ -44,31 +43,18 @@ class Proxy {
};
login = async (data, opt = { headers: { Authorization: `Bearer ${token}` } }) => {
const login = await this.post(loginURL, data, opt);
if (!login || !login.refreshToken) return this.result('login', false);
if (!login || !login.refreshToken) this.result('login', false);
localStorage.setItem('refresh', login.refreshToken);
delete login.refreshToken;
localStorage.setItem('userData', JSON.stringify(login));
if (data != {}) window.router.setState({ islogin: true });
if (data != {}) setTimeout(() => (window.location.href = '/'), 100);
return this.result('login', login);
};
logout = async () => {
this.post(logoutURL);
localStorage.removeItem('refresh');
localStorage.removeItem('userData');
window.router.setState({ islogin: false });
return this.result('logout', {});
};
status = () => {
let refresh = localStorage.getItem('refresh');
let userData = localStorage.getItem('userData');
if (!refresh) return false;
if (refresh == 'undefined') {
localStorage.removeItem('refresh');
localStorage.removeItem('userData');
return false;
}
return JSON.parse(userData);
window.location.href = '/';
};
status = () => (localStorage.getItem('refresh') ? true : false);
}
const _proxy = new Proxy();

@ -6,7 +6,7 @@ export default function user(state = initialState, action) {
let { type, data } = action;
switch (type) {
case 'login':
return { ...state, ...proxy.status(), islogin: proxy.status(), ...data };
return { ...state, ...data, islogin: proxy.status() };
case 'logout':
return { ...state, islogin: proxy.status() };
default:

@ -1,32 +1,40 @@
import React, { Component } from 'react';
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';
import proxy from './Redux/proxy';
import store from './Redux/store';
import { Provider } from 'react-redux';
import Home from './views/Home/Home';
import ChatRoom from './views/ChatRoom/ChatRoom';
import Auth from './views/Auth/Auth';
// import { connect } from 'react-redux';
class AppRouter extends Component {
constructor(props) {
super(props);
window.router = this;
}
state = {};
import proxy from './Redux/proxy';
export default class AppRouter extends Component {
render() {
let home = (
let home;
if (proxy.status()) {
home = (
<Route exact path={'/'}>
{proxy.status() ? <Home /> : <Auth />}
<Home />
</Route>
);
} else {
home = (
<Route exact path={'/'}>
<Auth />
</Route>
);
}
return (
<Provider store={store}>
<Router>
<Switch>{home}</Switch>
<Route exact path={`/chatroom/:id`}>
<ChatRoom />
</Route>
<Route exact path={'/auth'}>
<Auth />
</Route>
</Router>
</Provider>
);
}
}
export default AppRouter; //connect((state) => ({ isLogin: state.user.isLogin }), {})(AppRouter);

@ -1,3 +0,0 @@
// import { createBrowserHistory } from 'history';
// export default createBrowserHistory();

@ -8,11 +8,11 @@ import './Auth.scss';
export default class Auth extends Component {
constructor(props) {
super(props);
this.state = {
page: 'logo',
};
}
setPage = (val) => {
this.setState({
page: val,

@ -6,7 +6,8 @@ import { RecordState } from 'audio-react-recorder';
import ReactPlayer from 'react-player';
import ReactAudioPlayer from 'react-audio-player';
import { ToastContainer } from 'react-toastify';
import photo from '../../../assets/images/reza.png';
import photo1 from '../../../assets/images/user2.png';
import './Body.scss';
import { list, send, sendKeys } from '../../../Redux/actions/message';
import { info, bio } from '../../../Redux/actions/chat';
@ -342,15 +343,12 @@ class Body extends Component {
}
render() {
const { setPage, chatInfo, messageList, userId } = this.props;
const userIdx = {};
chatInfo.users.map((e) => (userIdx[e.id] = e));
console.log({ userId });
const { setPage } = this.props;
return (
<div className="chat-body d-flex flex-column">
<div className="chat-room__status d-flex flex-column" onClick={() => setPage('info')}>
<h1>{chatInfo.title}</h1>
<p>{chatInfo.subtitle}</p>
<h1>{this.props.info.title}</h1>
<p>{this.props.info.subtitle}</p>
</div>
<div
className="chat-body__content d-flex flex-column"
@ -361,18 +359,15 @@ class Body extends Component {
paddingBottom: this.state.footer === 'suggest' ? 110 : 70,
}}
>
{chatInfo.users &&
messageList.map((item, i) =>
this.state.image === null &&
this.state.music === null &&
this.state.video === null ? (
{this.props.message_list.map((item, i) =>
this.state.image === null && this.state.music === null && this.state.video === null ? (
<Message
isSelf={userId == item.userId}
isSelf={this.props.userId == item.userId}
key={i}
file={this.state.image}
document={this.state.document}
message={item}
user={userIdx[item.userId] || { id: 0, fileId: 0, name: 'null' }}
user={this.props.info.users[item.userId]}
/>
) : null
)}
@ -440,13 +435,10 @@ class Body extends Component {
}
}
export default connect(
(state) => {
console.log(state);
return {
chatInfo: state.chat.info,
userId: state.user.isLogin.id,
messageList: state.message.list || [],
};
},
(state) => ({
info: state.chat.info,
userId: state.user.id,
message_list: state.message.list || [],
}),
{ list, send, sendKeys, info, bio }
)(Body);

@ -14,7 +14,7 @@ export default class Message2D extends Component {
}}
>
<img
src={window.baseURL + '/file/download/' + user.fileId}
src={user.imageUri}
style={{ alignSelf: isSelf ? 'flex-end' : 'flex-start' }}
alt={message.id}
/>
@ -26,14 +26,11 @@ export default class Message2D extends Component {
) : null}
</div>
<div className="message-2d__options d-flex flex-column">
{message.options.map((option, i) => (
<div
key={message.id + '_' + option.id + '_' + i}
className="message-2d__options--row d-flex"
>
{message.options.map((option) => (
<div className="message-2d__options--row d-flex">
{option.map((item, i) => (
<div
key={message.id + '_' + item.id + '_' + i}
key={i}
className="d-flex"
style={{ width: `calc(100% / ${option.length} )` }}
draggable={true}

@ -18,7 +18,7 @@ export default class NormalMessage extends Component {
}}
>
<img
src={window.baseURL + '/file/download/' + user.fileId}
src={user.imageUri}
style={{ alignSelf: isSelf ? 'flex-end' : 'flex-start' }}
alt={message.id}
/>

@ -26,7 +26,7 @@ export default class RadioMessage extends Component {
}}
>
<img
src={window.baseURL + '/file/download/' + user.fileId}
src={user.imageUri}
style={{ alignSelf: isSelf ? 'flex-end' : 'flex-start' }}
alt={message.id}
/>

@ -42,7 +42,7 @@ export default class SliderMessage extends Component {
}}
>
<img
src={window.baseURL + '/file/download/' + user.fileId}
src={user.imageUri}
style={{ alignSelf: isSelf ? 'flex-end' : 'flex-start' }}
alt={message.id}
/>

@ -8,14 +8,11 @@ import './ChatRoom.scss';
export default class ChatRoom extends Component {
constructor(props) {
super(props);
window.nav = this.nav.bind(this);
this.state = {
page: 'chatroom',
};
}
nav = (url) => {
this.props.history.push(url);
};
setPage = (val) => {
this.setState({
page: val,

@ -50,7 +50,7 @@ class NavbarDrawer extends Component {
},
{
name: 'خروج',
link: '/',
link: '/auth',
icon: <ExitToAppIcon style={{ color: 'white', width: 35, height: 35, marginLeft: 10 }} />,
toast: '',
onClick: this.props.logout,

@ -1158,7 +1158,7 @@
dependencies:
regenerator-runtime "^0.13.4"
"@babel/runtime@^7.1.2", "@babel/runtime@^7.10.2", "@babel/runtime@^7.11.2", "@babel/runtime@^7.12.1", "@babel/runtime@^7.12.5", "@babel/runtime@^7.2.0", "@babel/runtime@^7.3.1", "@babel/runtime@^7.4.4", "@babel/runtime@^7.4.5", "@babel/runtime@^7.5.5", "@babel/runtime@^7.7.2", "@babel/runtime@^7.7.6", "@babel/runtime@^7.8.3", "@babel/runtime@^7.8.4", "@babel/runtime@^7.8.7", "@babel/runtime@^7.9.2":
"@babel/runtime@^7.1.2", "@babel/runtime@^7.10.2", "@babel/runtime@^7.11.2", "@babel/runtime@^7.12.1", "@babel/runtime@^7.12.5", "@babel/runtime@^7.2.0", "@babel/runtime@^7.3.1", "@babel/runtime@^7.4.4", "@babel/runtime@^7.4.5", "@babel/runtime@^7.5.5", "@babel/runtime@^7.7.2", "@babel/runtime@^7.8.3", "@babel/runtime@^7.8.4", "@babel/runtime@^7.8.7", "@babel/runtime@^7.9.2":
version "7.14.0"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.14.0.tgz#46794bc20b612c5f75e62dd071e24dfd95f1cbe6"
integrity sha512-JELkvo/DlpNdJ7dlyw/eY7E0suy5i5GQH+Vlxaq1nsNJ+H7f4Vtv3jMeCEgRhZZQFXTjldYfQgv2qmM6M1v5wA==
@ -6182,13 +6182,6 @@ history@^4.9.0:
tiny-warning "^1.0.0"
value-equal "^1.0.1"
history@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/history/-/history-5.0.0.tgz#0cabbb6c4bbf835addb874f8259f6d25101efd08"
integrity sha512-3NyRMKIiFSJmIPdq7FxkNMJkQ7ZEtVblOQ38VtKaA0zZMW1Eo6Q6W8oDKEflr1kNNTItSnk4JMCO1deeSgbLLg==
dependencies:
"@babel/runtime" "^7.7.6"
hmac-drbg@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/hmac-drbg/-/hmac-drbg-1.0.1.tgz#d2745701025a6c775a6c545793ed502fc0c649a1"

Loading…
Cancel
Save