From 02d45ac81ae808f93577afe42e898308ff88fa11 Mon Sep 17 00:00:00 2001 From: Alex Kern Date: Sun, 29 Mar 2015 18:01:49 -0700 Subject: [PATCH] Another massive refactor. --- README.md | 2 + client/actions/DownloadActions.js | 2 +- client/actions/PeerActions.js | 9 - client/alt.js | 2 +- client/components/App.js | 77 +- client/components/Arrow.js | 51 + client/components/DownloadPage.js | 64 + client/components/DropZone.js | 37 +- client/components/NotFoundPage.js | 9 + client/components/Tempalink.js | 12 +- client/components/UploadPage.js | 73 + client/components/Uploader.js | 37 + client/index.js | 17 +- client/peer.js | 16 + client/routes.js | 15 + client/socket.js | 14 +- client/stores/DownloadStore.js | 59 +- client/stores/PeerStore.js | 30 - client/stores/UploadStore.js | 59 +- package.json | 10 +- server/routes.js | 54 +- static/app.js | 3953 ++++++++++++++++++++++++++--- static/index.css | 150 +- 23 files changed, 4157 insertions(+), 595 deletions(-) delete mode 100644 client/actions/PeerActions.js create mode 100644 client/components/Arrow.js create mode 100644 client/components/DownloadPage.js create mode 100644 client/components/NotFoundPage.js create mode 100644 client/components/UploadPage.js create mode 100644 client/components/Uploader.js create mode 100644 client/peer.js create mode 100644 client/routes.js delete mode 100644 client/stores/PeerStore.js diff --git a/README.md b/README.md index e260cdb..364a74b 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # webdrop +![XKCD 949](http://imgs.xkcd.com/comics/file_transfer.png) + Peer-to-peer file transfers in your browser ## Usage diff --git a/client/actions/DownloadActions.js b/client/actions/DownloadActions.js index 29568a1..42551f8 100644 --- a/client/actions/DownloadActions.js +++ b/client/actions/DownloadActions.js @@ -4,7 +4,7 @@ export default alt.createActions(class DownloadActions { constructor() { this.generateActions( 'requestDownload', - 'setDownloadInfo' + 'beginDownload' ) } }) diff --git a/client/actions/PeerActions.js b/client/actions/PeerActions.js deleted file mode 100644 index c363f1f..0000000 --- a/client/actions/PeerActions.js +++ /dev/null @@ -1,9 +0,0 @@ -import alt from '../alt'; - -export default alt.createActions(class PeerActions { - constructor() { - this.generateActions( - 'peerConnected' - ) - } -}) diff --git a/client/alt.js b/client/alt.js index 487e70b..aa4173f 100644 --- a/client/alt.js +++ b/client/alt.js @@ -1,2 +1,2 @@ var Alt = require('alt'); -module.exports = new Alt(); +export default new Alt(); diff --git a/client/components/App.js b/client/components/App.js index 9a4c877..d08dfaa 100644 --- a/client/components/App.js +++ b/client/components/App.js @@ -1,70 +1,23 @@ -import DownloadActions from '../actions/DownloadActions'; -import DownloadStore from '../stores/DownloadStore'; -import DropZone from './DropZone'; -import FileDescription from './FileDescription'; -import PeerStore from '../stores/PeerStore'; +import FrozenHead from 'react-frozenhead'; import React from 'react'; -import Tempalink from './Tempalink'; -import UploadActions from '../actions/UploadActions'; -import UploadStore from '../stores/UploadStore'; - -function getState() { - return { - peerID: PeerStore.getPeerID(), - readyToUpload: UploadStore.getState().status.isUploading(), - uploadFile: UploadStore.getState().file, - uploadToken: UploadStore.getState().token, - downloadFile: DownloadStore.getState().file, - downloadToken: DownloadStore.getState().token, - readyToDownload: DownloadStore.getState().status.isReady() - }; -} +import { RouteHandler } from 'react-router'; export default class App extends React.Component { - constructor() { - - this.state = getState(); - this._onChange = function() { - this.setState(getState()); - }.bind(this); - - } - - componentDidMount() { - PeerStore.listen(this._onChange); - UploadStore.listen(this._onChange); - DownloadStore.listen(this._onChange); - } - - componentDidUnmount() { - PeerStore.unlisten(this._onChange); - UploadStore.unlisten(this._onChange); - DownloadStore.unlisten(this._onChange); - } - - uploadFile(file) { - UploadActions.uploadFile(file); - } - - downloadFile() { - DownloadActions.requestDownload(); - } - render() { - if (this.state.readyToUpload) { - return
- - -
; - } else if (this.state.readyToDownload) { - return
- - -
; - } else { - return ; - } + return + + + WebDrop - Send Files, Easily + + +