);
diff --git a/js/page/file-list.js b/js/page/file-list.js
new file mode 100644
index 000000000..95304535c
--- /dev/null
+++ b/js/page/file-list.js
@@ -0,0 +1,201 @@
+import React from 'react';
+import lbry from '../lbry.js';
+import {Link} from '../component/link.js';
+import FormField from '../component/form.js';
+import {FileTileStream} from '../component/file-tile.js';
+import {BusyMessage, Thumbnail} from '../component/common.js';
+
+
+export let FileListDownloaded = React.createClass({
+ _isMounted: false,
+
+ getInitialState: function() {
+ return {
+ fileInfos: null,
+ };
+ },
+ componentDidMount: function() {
+ this._isMounted = true;
+ document.title = "Downloaded Files";
+
+ let publishedFilesSdHashes = [];
+ lbry.getMyClaims((claimInfos) => {
+
+ if (!this._isMounted) { return; }
+
+ for (let claimInfo of claimInfos) {
+ let metadata = JSON.parse(claimInfo.value);
+ publishedFilesSdHashes.push(metadata.sources.lbry_sd_hash);
+ }
+
+ lbry.getFilesInfo((fileInfos) => {
+ if (!this._isMounted) { return; }
+
+ this.setState({
+ fileInfos: fileInfos.filter(({sd_hash}) => {
+ return publishedFilesSdHashes.indexOf(sd_hash) == -1;
+ })
+ });
+ });
+ });
+ },
+ render: function() {
+ if (this.state.fileInfos === null) {
+ return (
+
+
+
+ );
+ } else if (!this.state.fileInfos.length) {
+ return (
+
+ You haven't downloaded anything from LBRY yet. Go !
+
+ );
+ } else {
+ return (
+
+
+
+ );
+ }
+ }
+});
+
+export let FileListPublished = React.createClass({
+ _isMounted: false,
+
+ getInitialState: function () {
+ return {
+ fileInfos: null,
+ };
+ },
+ componentDidMount: function () {
+ this._isMounted = true;
+ document.title = "Published Files";
+
+ lbry.getMyClaims((claimInfos) => {
+ /**
+ * Build newFileInfos as a sparse array and drop elements in at the same position they
+ * occur in claimInfos, so the order is preserved even if the API calls inside this loop
+ * return out of order.
+ */
+ let newFileInfos = Array(claimInfos.length),
+ claimInfoProcessedCount = 0;
+
+ for (let [i, claimInfo] of claimInfos.entries()) {
+ let metadata = JSON.parse(claimInfo.value);
+ lbry.getFileInfoBySdHash(metadata.sources.lbry_sd_hash, (fileInfo) => {
+ claimInfoProcessedCount++;
+ if (fileInfo !== false) {
+ newFileInfos[i] = fileInfo;
+ }
+ if (claimInfoProcessedCount >= claimInfos.length) {
+ /**
+ * newfileInfos may have gaps from claims that don't have associated files in
+ * lbrynet, so filter out any missing elements
+ */
+ this.setState({
+ fileInfos: newFileInfos.filter(function () {
+ return true
+ }),
+ });
+ }
+ });
+ }
+ });
+ },
+ render: function () {
+ if (this.state.fileInfos === null) {
+ return (
+
+
+
+ );
+ }
+ else if (!this.state.fileInfos.length) {
+ return (
+
+ You haven't published anything to LBRY yet. Try !
+
+ );
+ }
+ else {
+ return (
+
+
+
+ );
+ }
+ }
+});
+
+export let FileList = React.createClass({
+ _sortFunctions: {
+ date: function(fileInfos) {
+ return fileInfos.reverse();
+ },
+ title: function(fileInfos) {
+ return fileInfos.sort(function(a, b) {
+ return ((a.metadata ? a.metadata.title.toLowerCase() : a.name) >
+ (b.metadata ? b.metadata.title.toLowerCase() : b.name));
+ });
+ },
+ filename: function(fileInfos) {
+ return fileInfos.sort(function(a, b) {
+ return (a.file_name.toLowerCase() >
+ b.file_name.toLowerCase());
+ });
+ },
+ },
+ propTypes: {
+ fileInfos: React.PropTypes.array.isRequired,
+ hidePrices: React.PropTypes.bool,
+ },
+ getDefaultProps: function() {
+ return {
+ hidePrices: false,
+ };
+ },
+ getInitialState: function() {
+ return {
+ sortBy: 'date',
+ };
+ },
+ handleSortChanged: function(event) {
+ this.setState({
+ sortBy: event.target.value,
+ });
+ },
+ render: function() {
+ var content = [],
+ seenUris = {};
+
+ const fileInfosSorted = this._sortFunctions[this.state.sortBy](this.props.fileInfos);
+ for (let fileInfo of fileInfosSorted) {
+ let {lbry_uri, sd_hash, metadata} = fileInfo;
+
+ if (!metadata || seenUris[lbry_uri]) {
+ continue;
+ }
+
+ seenUris[lbry_uri] = true;
+ content.push();
+ }
+
+ return (
+
+
+ Sort by { ' ' }
+
+
+
+
+
+
+ {content}
+
+ );
+ }
+});
\ No newline at end of file
diff --git a/js/page/my_files.js b/js/page/my_files.js
deleted file mode 100644
index 2d6b28e66..000000000
--- a/js/page/my_files.js
+++ /dev/null
@@ -1,380 +0,0 @@
-import React from 'react';
-import lbry from '../lbry.js';
-import {Link, WatchLink} from '../component/link.js';
-import {Menu, MenuItem} from '../component/menu.js';
-import FormField from '../component/form.js';
-import Modal from '../component/modal.js';
-import {BusyMessage, Thumbnail} from '../component/common.js';
-
-var moreMenuStyle = {
- position: 'absolute',
- display: 'block',
- top: '26px',
- right: '13px',
-};
-var MyFilesRowMoreMenu = React.createClass({
- propTypes: {
- title: React.PropTypes.string.isRequired,
- path: React.PropTypes.string.isRequired,
- completed: React.PropTypes.bool.isRequired,
- lbryUri: React.PropTypes.string.isRequired,
- },
- handleRevealClicked: function() {
- lbry.revealFile(this.props.path);
- },
- handleRemoveClicked: function() {
- lbry.deleteFile(this.props.lbryUri, false);
- },
- handleDeleteClicked: function() {
- this.setState({
- modal: 'confirmDelete',
- });
- },
- handleDeleteConfirmed: function() {
- lbry.deleteFile(this.props.lbryUri);
- this.setState({
- modal: null,
- });
- },
- closeModal: function() {
- this.setState({
- modal: null,
- });
- },
- getInitialState: function() {
- return {
- modal: null,
- };
- },
- render: function() {
- return (
-
-
-
- Are you sure you'd like to delete {this.props.title}? This will {this.props.completed ? ' stop the download and ' : ''}
- permanently remove the file from your system.
-
-