update: prestage

This commit is contained in:
srgooglo 2020-04-25 16:09:23 +02:00
parent 3e403ff990
commit ebddfbcb6e
10 changed files with 291 additions and 8 deletions

View File

@ -19,6 +19,7 @@
"dva": "2.4.1",
"dva-model-extend": "^0.1.2",
"enquire-js": "^0.2.1",
"express": "^4.17.1",
"interact.js": "^1.2.8",
"interactjs": "^1.9.9",
"jquery": "^3.4.1",
@ -30,8 +31,10 @@
"node-sass": "^4.13.1",
"nprogress": "^0.2.0",
"path-to-regexp": "^6.1.0",
"peerjs": "^1.2.0",
"prop-types": "^15.7.2",
"radium": "^0.26.0",
"randomstring": "^1.1.5",
"react-animations": "^1.0.0",
"react-dazzle": "^1.4.0",
"react-google-recaptcha": "^2.0.1",

View File

@ -13,7 +13,8 @@ import {
__priSearch,
__trendings,
__pro,
__footer
__footer,
__chats
} from './renders.js'
export const SwapMode = {
@ -216,7 +217,7 @@ export default class Secondary extends React.PureComponent {
<div className={styles.secondary_main}>
{ycore.IsThisUser.pro() ? <__pro /> : <__pro />}
<__trendings data={trending_data} />
<__chats />
{__footer()}
</div>

View File

@ -21,6 +21,15 @@ const VerifiedBadge = () => (
</svg>
)
export class __chats extends React.PureComponent{
render(){
return(
<div className={styles.SecondaryBody}> <h2>Chats</h2> </div>
)
}
}
export class __priPost extends React.PureComponent {
renderContent(payload) {
const { id, postText, postFile_full, post_time, publisher } = payload

View File

@ -3,6 +3,10 @@
.SecondaryBody {
width: 100%;
height: 100%;
font-family: @__Global_general_font_family;
color: #ffffff;
font-size: 12px;
h1,h2,h3,h4,h5{color:#ffffff}
}
.UserContainer {

View File

@ -58,10 +58,10 @@ export default class Sider_Default extends React.PureComponent {
</antd.Menu.Item>
<antd.Menu.Item key="events">
<Icons.CarryOutTwoTone twoToneColor={"#ff4d4f"}/>
<antd.Menu.Item key="chats">
<Icons.MessageTwoTone twoToneColor={"#ff4d4f"}/>
<Trans>
<span>Events</span>
<span>Chats</span>
</Trans>
</antd.Menu.Item>

View File

@ -24,9 +24,14 @@ class Sider extends React.PureComponent {
this.setState({selectedKey: e})
ycore.router.go('main')
},
chats: (e) => {
this.setState({selectedKey: e})
ycore.router.go('chats')
}
}
handleClickMenu = e => {
e.key === 'chats' && this.onClickFunctions.chats(e.key)
e.key === 'SignOut' && ycore.app_session.logout()
e.key === 'general_settings' && ycore.router.go('settings')
e.key === 'profile' && ycore.router.goprofile()

9
src/pages/chats/index.js Normal file
View File

@ -0,0 +1,9 @@
import React from 'react'
export default class extends React.PureComponent{
render(){
return(
<div>Chats</div>
)
}
}

View File

@ -0,0 +1,150 @@
import React from 'react'
import * as ycore from 'ycore'
import Peer from 'peerjs'
var lastPeerId = null;
var peer = new Peer
var peerId = null;
var conn = null;
function addMessage(msg) {
var now = new Date();
var h = now.getHours();
var m = addZero(now.getMinutes());
var s = addZero(now.getSeconds());
if (h > 12)
h -= 12;
else if (h === 0)
h = 12;
function addZero(t) {
if (t < 10)
t = "0" + t;
return t;
};
message.innerHTML = "<br><span class=\"msg-time\">" + h + ":" + m + ":" + s + "</span> - " + msg + message.innerHTML;
}
function putStatus(key){
if(!key)return false
window.ChatClass.setState({ status: key })
}
function putID(key){
if(!key)return false
window.ChatClass.setState({ ssid: key })
}
export default class Chats extends React.PureComponent{
constructor(props){
super(props),
this.state = {
ssid: null,
loading: true,
status: "Init...",
_d: null
}
window.ChatClass = this
}
async __init (){
const userData = await ycore.userData()
this.setState({ _d: userData, loading: false })
console.log(this.state._d)
peer.on('open', function (id) {
// Workaround for peer.reconnect deleting previous id
if (peer.id === null) {
console.log('Received null id from peer open');
peer.id = lastPeerId;
} else {
lastPeerId = peer.id;
}
putID(peer.id)
putStatus("Awaiting connection...")
});
peer.on('connection', function (c) {
// Allow only a single connection
if (conn) {
c.on('open', function() {
c.send("Already connected to another client");
setTimeout(function() { c.close(); }, 500);
});
return;
}
conn = c;
console.log("Connected to: " + conn.peer);
putStatus("Connected...")
window.ChatClass.ready();
});
peer.on('disconnected', function () {
window.ChatClass.setState({ status: 'Connection lost. Please reconnect' })
console.log('Connection lost. Please reconnect');
// Workaround for peer.reconnect deleting previous id
peer.reconnect();
});
peer.on('close', function() {
conn = null;
putStatus("Connection Destroyed...")
console.log('Connection destroyed');
});
peer.on('error', function (err) {
console.log(err);
alert('' + err);
});
}
ready() {
conn.on('data', function (data) {
console.log("Data recieved");
var cueString = "<span class=\"cueMsg\">Cue: </span>";
switch (data) {
case 'Go':
go();
addMessage(cueString + data);
break;
case 'Fade':
fade();
addMessage(cueString + data);
break;
case 'Off':
off();
addMessage(cueString + data);
break;
case 'Reset':
reset();
addMessage(cueString + data);
break;
default:
addMessage("<span class=\"peerMsg\">Peer: </span>" + data);
break;
};
});
conn.on('close', function () {
putStatus("Connection reset...")
conn = null;
start(true);
});
}
componentDidMount(){
this.__init()
}
render(){
const { _d, loading } = this.state
if (loading) return null
return(
<div>
<h1> Proto IRC </h1>
<h3> Status: {this.state.status} | SSID: {this.state.ssid} </h3>
</div>
)
}
}

View File

@ -0,0 +1,72 @@
import React from 'react'
import randomstring from 'randomstring'
import Peer from 'peerjs'
export default class extends React.PureComponent{
constructor(props){
super(props),
this.state={
peer: new Peer(),
my_id: null,
peer_id: null,
initialized: false,
files: []
}
}
componentWillMount(){
this.state.peer.on('open', (id)=>{
console.log('My peer ID is: ' + id);
this.setState({
my_id: id,
initialized: true
})
})
this.state.peer.on('connection', (connection) => {
console.log('New Connected')
console.log(connection)
this.setState({
conn: connection
}, () => {
this.state.conn.on('open', this.on)
})
})
}
componentWillUnmount(){
}
connect(){
}
sendFile(){
}
onReceiveData(){
}
addFile(){
}
handleTextChange(){
}
render(){
return(
<div>__ RENDER</div>
)
}
renderNotConnected(){
}
renderConnected(){
}
renderListFiles(){
}
renderNoFiles(){
}
renderFile(){
}
}

View File

@ -0,0 +1,30 @@
import React from 'react'
import * as ycore from 'ycore'
export default class _temp01 extends React.PureComponent{
state = {
loading: true,
ua: 'asd',
nombre_de_usuario: ' Error ',
estado_2: 'Algo'
}
componentDidMount(){
const a = ycore.userData()
const b = JSON.stringify(a)
console.log(a)
this.setState({ ua: b, nombre_de_usuario: 'GVASHDJH', loading: false })
}
render(){
if(this.state.loading) return <h1>loading...</h1>
return(
<div>
<h1> Hola de nuevo, {this.state.nombre_de_usuario} </h1><br/>
Este es tu token:
{ this.state.ua }
</div>
)
}
}