2019-04-03 19:12:51 +02:00
'use strict' ;
Object . defineProperty ( exports , '__esModule' , { value : true } ) ;
function _interopDefault ( ex ) { return ( ex && ( typeof ex === 'object' ) && 'default' in ex ) ? ex [ 'default' ] : ex ; }
require ( 'proxy-polyfill' ) ;
var reselect = require ( 'reselect' ) ;
var uuid = _interopDefault ( require ( 'uuid/v4' ) ) ;
2019-07-01 21:49:51 +02:00
const MINIMUM _PUBLISH _BID = 0.00000001 ;
const CHANNEL _ANONYMOUS = 'anonymous' ;
const CHANNEL _NEW = 'new' ;
const PAGE _SIZE = 20 ;
var claim = /*#__PURE__*/ Object . freeze ( {
MINIMUM _PUBLISH _BID : MINIMUM _PUBLISH _BID ,
CHANNEL _ANONYMOUS : CHANNEL _ANONYMOUS ,
CHANNEL _NEW : CHANNEL _NEW ,
PAGE _SIZE : PAGE _SIZE
} ) ;
2019-04-03 19:12:51 +02:00
const WINDOW _FOCUSED = 'WINDOW_FOCUSED' ;
const DAEMON _READY = 'DAEMON_READY' ;
const DAEMON _VERSION _MATCH = 'DAEMON_VERSION_MATCH' ;
const DAEMON _VERSION _MISMATCH = 'DAEMON_VERSION_MISMATCH' ;
const VOLUME _CHANGED = 'VOLUME_CHANGED' ;
// Navigation
const CHANGE _AFTER _AUTH _PATH = 'CHANGE_AFTER_AUTH_PATH' ;
const WINDOW _SCROLLED = 'WINDOW_SCROLLED' ;
const HISTORY _NAVIGATE = 'HISTORY_NAVIGATE' ;
// Upgrades
const UPGRADE _CANCELLED = 'UPGRADE_CANCELLED' ;
const DOWNLOAD _UPGRADE = 'DOWNLOAD_UPGRADE' ;
const UPGRADE _DOWNLOAD _STARTED = 'UPGRADE_DOWNLOAD_STARTED' ;
const UPGRADE _DOWNLOAD _COMPLETED = 'UPGRADE_DOWNLOAD_COMPLETED' ;
const UPGRADE _DOWNLOAD _PROGRESSED = 'UPGRADE_DOWNLOAD_PROGRESSED' ;
const CHECK _UPGRADE _AVAILABLE = 'CHECK_UPGRADE_AVAILABLE' ;
const CHECK _UPGRADE _START = 'CHECK_UPGRADE_START' ;
const CHECK _UPGRADE _SUCCESS = 'CHECK_UPGRADE_SUCCESS' ;
const CHECK _UPGRADE _FAIL = 'CHECK_UPGRADE_FAIL' ;
const CHECK _UPGRADE _SUBSCRIBE = 'CHECK_UPGRADE_SUBSCRIBE' ;
const UPDATE _VERSION = 'UPDATE_VERSION' ;
const UPDATE _REMOTE _VERSION = 'UPDATE_REMOTE_VERSION' ;
const SKIP _UPGRADE = 'SKIP_UPGRADE' ;
const START _UPGRADE = 'START_UPGRADE' ;
const AUTO _UPDATE _DECLINED = 'AUTO_UPDATE_DECLINED' ;
const AUTO _UPDATE _DOWNLOADED = 'AUTO_UPDATE_DOWNLOADED' ;
const CLEAR _UPGRADE _TIMER = 'CLEAR_UPGRADE_TIMER' ;
// Wallet
const GET _NEW _ADDRESS _STARTED = 'GET_NEW_ADDRESS_STARTED' ;
const GET _NEW _ADDRESS _COMPLETED = 'GET_NEW_ADDRESS_COMPLETED' ;
const FETCH _TRANSACTIONS _STARTED = 'FETCH_TRANSACTIONS_STARTED' ;
const FETCH _TRANSACTIONS _COMPLETED = 'FETCH_TRANSACTIONS_COMPLETED' ;
2019-05-10 07:02:03 +02:00
const FETCH _SUPPORTS _STARTED = 'FETCH_SUPPORTS_STARTED' ;
const FETCH _SUPPORTS _COMPLETED = 'FETCH_SUPPORTS_COMPLETED' ;
const ABANDON _SUPPORT _STARTED = 'ABANDON_SUPPORT_STARTED' ;
const ABANDON _SUPPORT _COMPLETED = 'ABANDON_SUPPORT_COMPLETED' ;
2019-04-03 19:12:51 +02:00
const UPDATE _BALANCE = 'UPDATE_BALANCE' ;
2019-04-18 09:56:16 +02:00
const UPDATE _TOTAL _BALANCE = 'UPDATE_TOTAL_BALANCE' ;
2019-04-03 19:12:51 +02:00
const CHECK _ADDRESS _IS _MINE _STARTED = 'CHECK_ADDRESS_IS_MINE_STARTED' ;
const CHECK _ADDRESS _IS _MINE _COMPLETED = 'CHECK_ADDRESS_IS_MINE_COMPLETED' ;
const SEND _TRANSACTION _STARTED = 'SEND_TRANSACTION_STARTED' ;
const SEND _TRANSACTION _COMPLETED = 'SEND_TRANSACTION_COMPLETED' ;
const SEND _TRANSACTION _FAILED = 'SEND_TRANSACTION_FAILED' ;
const SUPPORT _TRANSACTION _STARTED = 'SUPPORT_TRANSACTION_STARTED' ;
const SUPPORT _TRANSACTION _COMPLETED = 'SUPPORT_TRANSACTION_COMPLETED' ;
const SUPPORT _TRANSACTION _FAILED = 'SUPPORT_TRANSACTION_FAILED' ;
const WALLET _ENCRYPT _START = 'WALLET_ENCRYPT_START' ;
const WALLET _ENCRYPT _COMPLETED = 'WALLET_ENCRYPT_COMPLETED' ;
const WALLET _ENCRYPT _FAILED = 'WALLET_ENCRYPT_FAILED' ;
const WALLET _UNLOCK _START = 'WALLET_UNLOCK_START' ;
const WALLET _UNLOCK _COMPLETED = 'WALLET_UNLOCK_COMPLETED' ;
const WALLET _UNLOCK _FAILED = 'WALLET_UNLOCK_FAILED' ;
const WALLET _DECRYPT _START = 'WALLET_DECRYPT_START' ;
const WALLET _DECRYPT _COMPLETED = 'WALLET_DECRYPT_COMPLETED' ;
const WALLET _DECRYPT _FAILED = 'WALLET_DECRYPT_FAILED' ;
const WALLET _LOCK _START = 'WALLET_LOCK_START' ;
const WALLET _LOCK _COMPLETED = 'WALLET_LOCK_COMPLETED' ;
const WALLET _LOCK _FAILED = 'WALLET_LOCK_FAILED' ;
const WALLET _STATUS _START = 'WALLET_STATUS_START' ;
const WALLET _STATUS _COMPLETED = 'WALLET_STATUS_COMPLETED' ;
const SET _TRANSACTION _LIST _FILTER = 'SET_TRANSACTION_LIST_FILTER' ;
const UPDATE _CURRENT _HEIGHT = 'UPDATE_CURRENT_HEIGHT' ;
2019-04-18 09:56:16 +02:00
const SET _DRAFT _TRANSACTION _AMOUNT = 'SET_DRAFT_TRANSACTION_AMOUNT' ;
const SET _DRAFT _TRANSACTION _ADDRESS = 'SET_DRAFT_TRANSACTION_ADDRESS' ;
2019-04-03 19:12:51 +02:00
// Claims
const RESOLVE _URIS _STARTED = 'RESOLVE_URIS_STARTED' ;
const RESOLVE _URIS _COMPLETED = 'RESOLVE_URIS_COMPLETED' ;
const FETCH _CHANNEL _CLAIMS _STARTED = 'FETCH_CHANNEL_CLAIMS_STARTED' ;
const FETCH _CHANNEL _CLAIMS _COMPLETED = 'FETCH_CHANNEL_CLAIMS_COMPLETED' ;
const FETCH _CLAIM _LIST _MINE _STARTED = 'FETCH_CLAIM_LIST_MINE_STARTED' ;
const FETCH _CLAIM _LIST _MINE _COMPLETED = 'FETCH_CLAIM_LIST_MINE_COMPLETED' ;
const ABANDON _CLAIM _STARTED = 'ABANDON_CLAIM_STARTED' ;
const ABANDON _CLAIM _SUCCEEDED = 'ABANDON_CLAIM_SUCCEEDED' ;
const FETCH _CHANNEL _LIST _STARTED = 'FETCH_CHANNEL_LIST_STARTED' ;
const FETCH _CHANNEL _LIST _COMPLETED = 'FETCH_CHANNEL_LIST_COMPLETED' ;
const CREATE _CHANNEL _STARTED = 'CREATE_CHANNEL_STARTED' ;
const CREATE _CHANNEL _COMPLETED = 'CREATE_CHANNEL_COMPLETED' ;
2019-04-23 19:22:14 +02:00
const CREATE _CHANNEL _FAILED = 'CREATE_CHANNEL_FAILED' ;
2019-07-01 03:16:44 +02:00
const UPDATE _CHANNEL _STARTED = 'UPDATE_CHANNEL_STARTED' ;
const UPDATE _CHANNEL _COMPLETED = 'UPDATE_CHANNEL_COMPLETED' ;
const UPDATE _CHANNEL _FAILED = 'UPDATE_CHANNEL_FAILED' ;
2019-09-12 21:06:49 +02:00
const IMPORT _CHANNEL _STARTED = 'IMPORT_CHANNEL_STARTED' ;
const IMPORT _CHANNEL _COMPLETED = 'IMPORT_CHANNEL_COMPLETED' ;
const IMPORT _CHANNEL _FAILED = 'IMPORT_CHANNEL_FAILED' ;
2019-04-03 19:12:51 +02:00
const PUBLISH _STARTED = 'PUBLISH_STARTED' ;
const PUBLISH _COMPLETED = 'PUBLISH_COMPLETED' ;
const PUBLISH _FAILED = 'PUBLISH_FAILED' ;
const SET _PLAYING _URI = 'SET_PLAYING_URI' ;
const SET _CONTENT _POSITION = 'SET_CONTENT_POSITION' ;
const SET _CONTENT _LAST _VIEWED = 'SET_CONTENT_LAST_VIEWED' ;
const CLEAR _CONTENT _HISTORY _URI = 'CLEAR_CONTENT_HISTORY_URI' ;
const CLEAR _CONTENT _HISTORY _ALL = 'CLEAR_CONTENT_HISTORY_ALL' ;
2019-06-10 04:45:47 +02:00
const CLAIM _SEARCH _STARTED = 'CLAIM_SEARCH_STARTED' ;
const CLAIM _SEARCH _COMPLETED = 'CLAIM_SEARCH_COMPLETED' ;
const CLAIM _SEARCH _FAILED = 'CLAIM_SEARCH_FAILED' ;
2019-07-15 04:44:02 +02:00
const CLAIM _SEARCH _BY _TAGS _STARTED = 'CLAIM_SEARCH_BY_TAGS_STARTED' ;
const CLAIM _SEARCH _BY _TAGS _COMPLETED = 'CLAIM_SEARCH_BY_TAGS_COMPLETED' ;
const CLAIM _SEARCH _BY _TAGS _FAILED = 'CLAIM_SEARCH_BY_TAGS_FAILED' ;
2019-04-03 19:12:51 +02:00
2019-06-12 03:14:37 +02:00
// Comments
const COMMENT _LIST _STARTED = 'COMMENT_LIST_STARTED' ;
const COMMENT _LIST _COMPLETED = 'COMMENT_LIST_COMPLETED' ;
2019-06-27 01:13:29 +02:00
const COMMENT _LIST _FAILED = 'COMMENT_LIST_FAILED' ;
2019-06-12 03:14:37 +02:00
const COMMENT _CREATE _STARTED = 'COMMENT_CREATE_STARTED' ;
const COMMENT _CREATE _COMPLETED = 'COMMENT_CREATE_COMPLETED' ;
const COMMENT _CREATE _FAILED = 'COMMENT_CREATE_FAILED' ;
2019-04-03 19:12:51 +02:00
// Files
const FILE _LIST _STARTED = 'FILE_LIST_STARTED' ;
const FILE _LIST _SUCCEEDED = 'FILE_LIST_SUCCEEDED' ;
const FETCH _FILE _INFO _STARTED = 'FETCH_FILE_INFO_STARTED' ;
const FETCH _FILE _INFO _COMPLETED = 'FETCH_FILE_INFO_COMPLETED' ;
2019-08-13 19:33:32 +02:00
const FETCH _FILE _INFO _FAILED = 'FETCH_FILE_INFO_FAILED' ;
2019-04-03 19:12:51 +02:00
const LOADING _VIDEO _STARTED = 'LOADING_VIDEO_STARTED' ;
const LOADING _VIDEO _COMPLETED = 'LOADING_VIDEO_COMPLETED' ;
const LOADING _VIDEO _FAILED = 'LOADING_VIDEO_FAILED' ;
const DOWNLOADING _STARTED = 'DOWNLOADING_STARTED' ;
const DOWNLOADING _PROGRESSED = 'DOWNLOADING_PROGRESSED' ;
const DOWNLOADING _COMPLETED = 'DOWNLOADING_COMPLETED' ;
const DOWNLOADING _CANCELED = 'DOWNLOADING_CANCELED' ;
const PLAY _VIDEO _STARTED = 'PLAY_VIDEO_STARTED' ;
const FETCH _AVAILABILITY _STARTED = 'FETCH_AVAILABILITY_STARTED' ;
const FETCH _AVAILABILITY _COMPLETED = 'FETCH_AVAILABILITY_COMPLETED' ;
const FILE _DELETE = 'FILE_DELETE' ;
const SET _FILE _LIST _SORT = 'SET_FILE_LIST_SORT' ;
2019-05-21 21:18:07 +02:00
const PURCHASE _URI _STARTED = 'PURCHASE_URI_STARTED' ;
const PURCHASE _URI _COMPLETED = 'PURCHASE_URI_COMPLETED' ;
const PURCHASE _URI _FAILED = 'PURCHASE_URI_FAILED' ;
2019-05-27 15:59:21 +02:00
const DELETE _PURCHASED _URI = 'DELETE_PURCHASED_URI' ;
2019-04-03 19:12:51 +02:00
// Search
const SEARCH _START = 'SEARCH_START' ;
const SEARCH _SUCCESS = 'SEARCH_SUCCESS' ;
const SEARCH _FAIL = 'SEARCH_FAIL' ;
const UPDATE _SEARCH _QUERY = 'UPDATE_SEARCH_QUERY' ;
const UPDATE _SEARCH _OPTIONS = 'UPDATE_SEARCH_OPTIONS' ;
const UPDATE _SEARCH _SUGGESTIONS = 'UPDATE_SEARCH_SUGGESTIONS' ;
const SEARCH _FOCUS = 'SEARCH_FOCUS' ;
const SEARCH _BLUR = 'SEARCH_BLUR' ;
// Settings
const DAEMON _SETTINGS _RECEIVED = 'DAEMON_SETTINGS_RECEIVED' ;
const CLIENT _SETTING _CHANGED = 'CLIENT_SETTING_CHANGED' ;
const UPDATE _IS _NIGHT = 'UPDATE_IS_NIGHT' ;
// User
const AUTHENTICATION _STARTED = 'AUTHENTICATION_STARTED' ;
const AUTHENTICATION _SUCCESS = 'AUTHENTICATION_SUCCESS' ;
const AUTHENTICATION _FAILURE = 'AUTHENTICATION_FAILURE' ;
const USER _EMAIL _DECLINE = 'USER_EMAIL_DECLINE' ;
const USER _EMAIL _NEW _STARTED = 'USER_EMAIL_NEW_STARTED' ;
const USER _EMAIL _NEW _SUCCESS = 'USER_EMAIL_NEW_SUCCESS' ;
const USER _EMAIL _NEW _EXISTS = 'USER_EMAIL_NEW_EXISTS' ;
const USER _EMAIL _NEW _FAILURE = 'USER_EMAIL_NEW_FAILURE' ;
const USER _EMAIL _VERIFY _SET = 'USER_EMAIL_VERIFY_SET' ;
const USER _EMAIL _VERIFY _STARTED = 'USER_EMAIL_VERIFY_STARTED' ;
const USER _EMAIL _VERIFY _SUCCESS = 'USER_EMAIL_VERIFY_SUCCESS' ;
const USER _EMAIL _VERIFY _FAILURE = 'USER_EMAIL_VERIFY_FAILURE' ;
const USER _EMAIL _VERIFY _RETRY = 'USER_EMAIL_VERIFY_RETRY' ;
const USER _PHONE _RESET = 'USER_PHONE_RESET' ;
const USER _PHONE _NEW _STARTED = 'USER_PHONE_NEW_STARTED' ;
const USER _PHONE _NEW _SUCCESS = 'USER_PHONE_NEW_SUCCESS' ;
const USER _PHONE _NEW _FAILURE = 'USER_PHONE_NEW_FAILURE' ;
const USER _PHONE _VERIFY _STARTED = 'USER_PHONE_VERIFY_STARTED' ;
const USER _PHONE _VERIFY _SUCCESS = 'USER_PHONE_VERIFY_SUCCESS' ;
const USER _PHONE _VERIFY _FAILURE = 'USER_PHONE_VERIFY_FAILURE' ;
const USER _IDENTITY _VERIFY _STARTED = 'USER_IDENTITY_VERIFY_STARTED' ;
const USER _IDENTITY _VERIFY _SUCCESS = 'USER_IDENTITY_VERIFY_SUCCESS' ;
const USER _IDENTITY _VERIFY _FAILURE = 'USER_IDENTITY_VERIFY_FAILURE' ;
const USER _FETCH _STARTED = 'USER_FETCH_STARTED' ;
const USER _FETCH _SUCCESS = 'USER_FETCH_SUCCESS' ;
const USER _FETCH _FAILURE = 'USER_FETCH_FAILURE' ;
const USER _INVITE _STATUS _FETCH _STARTED = 'USER_INVITE_STATUS_FETCH_STARTED' ;
const USER _INVITE _STATUS _FETCH _SUCCESS = 'USER_INVITE_STATUS_FETCH_SUCCESS' ;
const USER _INVITE _STATUS _FETCH _FAILURE = 'USER_INVITE_STATUS_FETCH_FAILURE' ;
const USER _INVITE _NEW _STARTED = 'USER_INVITE_NEW_STARTED' ;
const USER _INVITE _NEW _SUCCESS = 'USER_INVITE_NEW_SUCCESS' ;
const USER _INVITE _NEW _FAILURE = 'USER_INVITE_NEW_FAILURE' ;
const FETCH _ACCESS _TOKEN _SUCCESS = 'FETCH_ACCESS_TOKEN_SUCCESS' ;
// Rewards
const FETCH _REWARDS _STARTED = 'FETCH_REWARDS_STARTED' ;
const FETCH _REWARDS _COMPLETED = 'FETCH_REWARDS_COMPLETED' ;
const CLAIM _REWARD _STARTED = 'CLAIM_REWARD_STARTED' ;
const CLAIM _REWARD _SUCCESS = 'CLAIM_REWARD_SUCCESS' ;
const CLAIM _REWARD _FAILURE = 'CLAIM_REWARD_FAILURE' ;
const CLAIM _REWARD _CLEAR _ERROR = 'CLAIM_REWARD_CLEAR_ERROR' ;
const FETCH _REWARD _CONTENT _COMPLETED = 'FETCH_REWARD_CONTENT_COMPLETED' ;
// Language
const DOWNLOAD _LANGUAGE _SUCCEEDED = 'DOWNLOAD_LANGUAGE_SUCCEEDED' ;
const DOWNLOAD _LANGUAGE _FAILED = 'DOWNLOAD_LANGUAGE_FAILED' ;
// Subscriptions
const CHANNEL _SUBSCRIBE = 'CHANNEL_SUBSCRIBE' ;
const CHANNEL _UNSUBSCRIBE = 'CHANNEL_UNSUBSCRIBE' ;
const HAS _FETCHED _SUBSCRIPTIONS = 'HAS_FETCHED_SUBSCRIPTIONS' ;
const SET _SUBSCRIPTION _LATEST = 'SET_SUBSCRIPTION_LATEST' ;
const SET _SUBSCRIPTION _NOTIFICATION = 'SET_SUBSCRIPTION_NOTIFICATION' ;
const SET _SUBSCRIPTION _NOTIFICATIONS = 'SET_SUBSCRIPTION_NOTIFICATIONS' ;
const CHECK _SUBSCRIPTION _STARTED = 'CHECK_SUBSCRIPTION_STARTED' ;
const CHECK _SUBSCRIPTION _COMPLETED = 'CHECK_SUBSCRIPTION_COMPLETED' ;
const CHECK _SUBSCRIPTIONS _SUBSCRIBE = 'CHECK_SUBSCRIPTIONS_SUBSCRIBE' ;
// Publishing
const CLEAR _PUBLISH = 'CLEAR_PUBLISH' ;
const UPDATE _PUBLISH _FORM = 'UPDATE_PUBLISH_FORM' ;
const PUBLISH _START = 'PUBLISH_START' ;
const PUBLISH _SUCCESS = 'PUBLISH_SUCCESS' ;
const PUBLISH _FAIL = 'PUBLISH_FAIL' ;
const CLEAR _PUBLISH _ERROR = 'CLEAR_PUBLISH_ERROR' ;
const REMOVE _PENDING _PUBLISH = 'REMOVE_PENDING_PUBLISH' ;
const DO _PREPARE _EDIT = 'DO_PREPARE_EDIT' ;
// Notifications
const CREATE _NOTIFICATION = 'CREATE_NOTIFICATION' ;
const EDIT _NOTIFICATION = 'EDIT_NOTIFICATION' ;
const DELETE _NOTIFICATION = 'DELETE_NOTIFICATION' ;
2019-04-18 09:56:16 +02:00
const DISMISS _NOTIFICATION = 'DISMISS_NOTIFICATION' ;
2019-04-03 19:12:51 +02:00
const CREATE _TOAST = 'CREATE_TOAST' ;
const DISMISS _TOAST = 'DISMISS_TOAST' ;
const CREATE _ERROR = 'CREATE_ERROR' ;
const DISMISS _ERROR = 'DISMISS_ERROR' ;
const FETCH _DATE = 'FETCH_DATE' ;
2019-05-21 21:18:07 +02:00
// Cost info
const FETCH _COST _INFO _STARTED = 'FETCH_COST_INFO_STARTED' ;
const FETCH _COST _INFO _COMPLETED = 'FETCH_COST_INFO_COMPLETED' ;
const FETCH _COST _INFO _FAILED = 'FETCH_COST_INFO_FAILED' ;
2019-09-10 20:14:40 +02:00
2019-06-10 04:45:47 +02:00
// Tags
const TOGGLE _TAG _FOLLOW = 'TOGGLE_TAG_FOLLOW' ;
const TAG _ADD = 'TAG_ADD' ;
const TAG _DELETE = 'TAG_DELETE' ;
2019-09-10 20:14:40 +02:00
2019-08-02 02:57:27 +02:00
// Blocked Channels
const TOGGLE _BLOCK _CHANNEL = 'TOGGLE_BLOCK_CHANNEL' ;
2019-05-21 21:18:07 +02:00
2019-09-10 20:14:40 +02:00
// Sync
2019-09-13 21:52:52 +02:00
const USER _STATE _POPULATE = 'USER_STATE_POPULATE' ;
2019-09-10 20:14:40 +02:00
2019-04-03 19:12:51 +02:00
var action _types = /*#__PURE__*/ Object . freeze ( {
2019-07-01 21:49:51 +02:00
WINDOW _FOCUSED : WINDOW _FOCUSED ,
DAEMON _READY : DAEMON _READY ,
DAEMON _VERSION _MATCH : DAEMON _VERSION _MATCH ,
DAEMON _VERSION _MISMATCH : DAEMON _VERSION _MISMATCH ,
VOLUME _CHANGED : VOLUME _CHANGED ,
CHANGE _AFTER _AUTH _PATH : CHANGE _AFTER _AUTH _PATH ,
WINDOW _SCROLLED : WINDOW _SCROLLED ,
HISTORY _NAVIGATE : HISTORY _NAVIGATE ,
UPGRADE _CANCELLED : UPGRADE _CANCELLED ,
DOWNLOAD _UPGRADE : DOWNLOAD _UPGRADE ,
UPGRADE _DOWNLOAD _STARTED : UPGRADE _DOWNLOAD _STARTED ,
UPGRADE _DOWNLOAD _COMPLETED : UPGRADE _DOWNLOAD _COMPLETED ,
UPGRADE _DOWNLOAD _PROGRESSED : UPGRADE _DOWNLOAD _PROGRESSED ,
CHECK _UPGRADE _AVAILABLE : CHECK _UPGRADE _AVAILABLE ,
CHECK _UPGRADE _START : CHECK _UPGRADE _START ,
CHECK _UPGRADE _SUCCESS : CHECK _UPGRADE _SUCCESS ,
CHECK _UPGRADE _FAIL : CHECK _UPGRADE _FAIL ,
CHECK _UPGRADE _SUBSCRIBE : CHECK _UPGRADE _SUBSCRIBE ,
UPDATE _VERSION : UPDATE _VERSION ,
UPDATE _REMOTE _VERSION : UPDATE _REMOTE _VERSION ,
SKIP _UPGRADE : SKIP _UPGRADE ,
START _UPGRADE : START _UPGRADE ,
AUTO _UPDATE _DECLINED : AUTO _UPDATE _DECLINED ,
AUTO _UPDATE _DOWNLOADED : AUTO _UPDATE _DOWNLOADED ,
CLEAR _UPGRADE _TIMER : CLEAR _UPGRADE _TIMER ,
GET _NEW _ADDRESS _STARTED : GET _NEW _ADDRESS _STARTED ,
GET _NEW _ADDRESS _COMPLETED : GET _NEW _ADDRESS _COMPLETED ,
FETCH _TRANSACTIONS _STARTED : FETCH _TRANSACTIONS _STARTED ,
FETCH _TRANSACTIONS _COMPLETED : FETCH _TRANSACTIONS _COMPLETED ,
FETCH _SUPPORTS _STARTED : FETCH _SUPPORTS _STARTED ,
FETCH _SUPPORTS _COMPLETED : FETCH _SUPPORTS _COMPLETED ,
ABANDON _SUPPORT _STARTED : ABANDON _SUPPORT _STARTED ,
ABANDON _SUPPORT _COMPLETED : ABANDON _SUPPORT _COMPLETED ,
UPDATE _BALANCE : UPDATE _BALANCE ,
UPDATE _TOTAL _BALANCE : UPDATE _TOTAL _BALANCE ,
CHECK _ADDRESS _IS _MINE _STARTED : CHECK _ADDRESS _IS _MINE _STARTED ,
CHECK _ADDRESS _IS _MINE _COMPLETED : CHECK _ADDRESS _IS _MINE _COMPLETED ,
SEND _TRANSACTION _STARTED : SEND _TRANSACTION _STARTED ,
SEND _TRANSACTION _COMPLETED : SEND _TRANSACTION _COMPLETED ,
SEND _TRANSACTION _FAILED : SEND _TRANSACTION _FAILED ,
SUPPORT _TRANSACTION _STARTED : SUPPORT _TRANSACTION _STARTED ,
SUPPORT _TRANSACTION _COMPLETED : SUPPORT _TRANSACTION _COMPLETED ,
SUPPORT _TRANSACTION _FAILED : SUPPORT _TRANSACTION _FAILED ,
WALLET _ENCRYPT _START : WALLET _ENCRYPT _START ,
WALLET _ENCRYPT _COMPLETED : WALLET _ENCRYPT _COMPLETED ,
WALLET _ENCRYPT _FAILED : WALLET _ENCRYPT _FAILED ,
WALLET _UNLOCK _START : WALLET _UNLOCK _START ,
WALLET _UNLOCK _COMPLETED : WALLET _UNLOCK _COMPLETED ,
WALLET _UNLOCK _FAILED : WALLET _UNLOCK _FAILED ,
WALLET _DECRYPT _START : WALLET _DECRYPT _START ,
WALLET _DECRYPT _COMPLETED : WALLET _DECRYPT _COMPLETED ,
WALLET _DECRYPT _FAILED : WALLET _DECRYPT _FAILED ,
WALLET _LOCK _START : WALLET _LOCK _START ,
WALLET _LOCK _COMPLETED : WALLET _LOCK _COMPLETED ,
WALLET _LOCK _FAILED : WALLET _LOCK _FAILED ,
WALLET _STATUS _START : WALLET _STATUS _START ,
WALLET _STATUS _COMPLETED : WALLET _STATUS _COMPLETED ,
SET _TRANSACTION _LIST _FILTER : SET _TRANSACTION _LIST _FILTER ,
UPDATE _CURRENT _HEIGHT : UPDATE _CURRENT _HEIGHT ,
SET _DRAFT _TRANSACTION _AMOUNT : SET _DRAFT _TRANSACTION _AMOUNT ,
SET _DRAFT _TRANSACTION _ADDRESS : SET _DRAFT _TRANSACTION _ADDRESS ,
RESOLVE _URIS _STARTED : RESOLVE _URIS _STARTED ,
RESOLVE _URIS _COMPLETED : RESOLVE _URIS _COMPLETED ,
FETCH _CHANNEL _CLAIMS _STARTED : FETCH _CHANNEL _CLAIMS _STARTED ,
FETCH _CHANNEL _CLAIMS _COMPLETED : FETCH _CHANNEL _CLAIMS _COMPLETED ,
FETCH _CLAIM _LIST _MINE _STARTED : FETCH _CLAIM _LIST _MINE _STARTED ,
FETCH _CLAIM _LIST _MINE _COMPLETED : FETCH _CLAIM _LIST _MINE _COMPLETED ,
ABANDON _CLAIM _STARTED : ABANDON _CLAIM _STARTED ,
ABANDON _CLAIM _SUCCEEDED : ABANDON _CLAIM _SUCCEEDED ,
FETCH _CHANNEL _LIST _STARTED : FETCH _CHANNEL _LIST _STARTED ,
FETCH _CHANNEL _LIST _COMPLETED : FETCH _CHANNEL _LIST _COMPLETED ,
CREATE _CHANNEL _STARTED : CREATE _CHANNEL _STARTED ,
CREATE _CHANNEL _COMPLETED : CREATE _CHANNEL _COMPLETED ,
CREATE _CHANNEL _FAILED : CREATE _CHANNEL _FAILED ,
2019-07-01 03:16:44 +02:00
UPDATE _CHANNEL _STARTED : UPDATE _CHANNEL _STARTED ,
UPDATE _CHANNEL _COMPLETED : UPDATE _CHANNEL _COMPLETED ,
UPDATE _CHANNEL _FAILED : UPDATE _CHANNEL _FAILED ,
2019-09-12 21:06:49 +02:00
IMPORT _CHANNEL _STARTED : IMPORT _CHANNEL _STARTED ,
IMPORT _CHANNEL _COMPLETED : IMPORT _CHANNEL _COMPLETED ,
IMPORT _CHANNEL _FAILED : IMPORT _CHANNEL _FAILED ,
2019-07-01 21:49:51 +02:00
PUBLISH _STARTED : PUBLISH _STARTED ,
PUBLISH _COMPLETED : PUBLISH _COMPLETED ,
PUBLISH _FAILED : PUBLISH _FAILED ,
SET _PLAYING _URI : SET _PLAYING _URI ,
SET _CONTENT _POSITION : SET _CONTENT _POSITION ,
SET _CONTENT _LAST _VIEWED : SET _CONTENT _LAST _VIEWED ,
CLEAR _CONTENT _HISTORY _URI : CLEAR _CONTENT _HISTORY _URI ,
CLEAR _CONTENT _HISTORY _ALL : CLEAR _CONTENT _HISTORY _ALL ,
CLAIM _SEARCH _STARTED : CLAIM _SEARCH _STARTED ,
CLAIM _SEARCH _COMPLETED : CLAIM _SEARCH _COMPLETED ,
CLAIM _SEARCH _FAILED : CLAIM _SEARCH _FAILED ,
2019-07-15 04:44:02 +02:00
CLAIM _SEARCH _BY _TAGS _STARTED : CLAIM _SEARCH _BY _TAGS _STARTED ,
CLAIM _SEARCH _BY _TAGS _COMPLETED : CLAIM _SEARCH _BY _TAGS _COMPLETED ,
CLAIM _SEARCH _BY _TAGS _FAILED : CLAIM _SEARCH _BY _TAGS _FAILED ,
2019-07-01 21:49:51 +02:00
COMMENT _LIST _STARTED : COMMENT _LIST _STARTED ,
COMMENT _LIST _COMPLETED : COMMENT _LIST _COMPLETED ,
COMMENT _LIST _FAILED : COMMENT _LIST _FAILED ,
COMMENT _CREATE _STARTED : COMMENT _CREATE _STARTED ,
COMMENT _CREATE _COMPLETED : COMMENT _CREATE _COMPLETED ,
COMMENT _CREATE _FAILED : COMMENT _CREATE _FAILED ,
FILE _LIST _STARTED : FILE _LIST _STARTED ,
FILE _LIST _SUCCEEDED : FILE _LIST _SUCCEEDED ,
FETCH _FILE _INFO _STARTED : FETCH _FILE _INFO _STARTED ,
FETCH _FILE _INFO _COMPLETED : FETCH _FILE _INFO _COMPLETED ,
2019-08-13 19:33:32 +02:00
FETCH _FILE _INFO _FAILED : FETCH _FILE _INFO _FAILED ,
2019-07-01 21:49:51 +02:00
LOADING _VIDEO _STARTED : LOADING _VIDEO _STARTED ,
LOADING _VIDEO _COMPLETED : LOADING _VIDEO _COMPLETED ,
LOADING _VIDEO _FAILED : LOADING _VIDEO _FAILED ,
DOWNLOADING _STARTED : DOWNLOADING _STARTED ,
DOWNLOADING _PROGRESSED : DOWNLOADING _PROGRESSED ,
DOWNLOADING _COMPLETED : DOWNLOADING _COMPLETED ,
DOWNLOADING _CANCELED : DOWNLOADING _CANCELED ,
PLAY _VIDEO _STARTED : PLAY _VIDEO _STARTED ,
FETCH _AVAILABILITY _STARTED : FETCH _AVAILABILITY _STARTED ,
FETCH _AVAILABILITY _COMPLETED : FETCH _AVAILABILITY _COMPLETED ,
FILE _DELETE : FILE _DELETE ,
SET _FILE _LIST _SORT : SET _FILE _LIST _SORT ,
PURCHASE _URI _STARTED : PURCHASE _URI _STARTED ,
PURCHASE _URI _COMPLETED : PURCHASE _URI _COMPLETED ,
PURCHASE _URI _FAILED : PURCHASE _URI _FAILED ,
DELETE _PURCHASED _URI : DELETE _PURCHASED _URI ,
SEARCH _START : SEARCH _START ,
SEARCH _SUCCESS : SEARCH _SUCCESS ,
SEARCH _FAIL : SEARCH _FAIL ,
UPDATE _SEARCH _QUERY : UPDATE _SEARCH _QUERY ,
UPDATE _SEARCH _OPTIONS : UPDATE _SEARCH _OPTIONS ,
UPDATE _SEARCH _SUGGESTIONS : UPDATE _SEARCH _SUGGESTIONS ,
SEARCH _FOCUS : SEARCH _FOCUS ,
SEARCH _BLUR : SEARCH _BLUR ,
DAEMON _SETTINGS _RECEIVED : DAEMON _SETTINGS _RECEIVED ,
CLIENT _SETTING _CHANGED : CLIENT _SETTING _CHANGED ,
UPDATE _IS _NIGHT : UPDATE _IS _NIGHT ,
AUTHENTICATION _STARTED : AUTHENTICATION _STARTED ,
AUTHENTICATION _SUCCESS : AUTHENTICATION _SUCCESS ,
AUTHENTICATION _FAILURE : AUTHENTICATION _FAILURE ,
USER _EMAIL _DECLINE : USER _EMAIL _DECLINE ,
USER _EMAIL _NEW _STARTED : USER _EMAIL _NEW _STARTED ,
USER _EMAIL _NEW _SUCCESS : USER _EMAIL _NEW _SUCCESS ,
USER _EMAIL _NEW _EXISTS : USER _EMAIL _NEW _EXISTS ,
USER _EMAIL _NEW _FAILURE : USER _EMAIL _NEW _FAILURE ,
USER _EMAIL _VERIFY _SET : USER _EMAIL _VERIFY _SET ,
USER _EMAIL _VERIFY _STARTED : USER _EMAIL _VERIFY _STARTED ,
USER _EMAIL _VERIFY _SUCCESS : USER _EMAIL _VERIFY _SUCCESS ,
USER _EMAIL _VERIFY _FAILURE : USER _EMAIL _VERIFY _FAILURE ,
USER _EMAIL _VERIFY _RETRY : USER _EMAIL _VERIFY _RETRY ,
USER _PHONE _RESET : USER _PHONE _RESET ,
USER _PHONE _NEW _STARTED : USER _PHONE _NEW _STARTED ,
USER _PHONE _NEW _SUCCESS : USER _PHONE _NEW _SUCCESS ,
USER _PHONE _NEW _FAILURE : USER _PHONE _NEW _FAILURE ,
USER _PHONE _VERIFY _STARTED : USER _PHONE _VERIFY _STARTED ,
USER _PHONE _VERIFY _SUCCESS : USER _PHONE _VERIFY _SUCCESS ,
USER _PHONE _VERIFY _FAILURE : USER _PHONE _VERIFY _FAILURE ,
USER _IDENTITY _VERIFY _STARTED : USER _IDENTITY _VERIFY _STARTED ,
USER _IDENTITY _VERIFY _SUCCESS : USER _IDENTITY _VERIFY _SUCCESS ,
USER _IDENTITY _VERIFY _FAILURE : USER _IDENTITY _VERIFY _FAILURE ,
USER _FETCH _STARTED : USER _FETCH _STARTED ,
USER _FETCH _SUCCESS : USER _FETCH _SUCCESS ,
USER _FETCH _FAILURE : USER _FETCH _FAILURE ,
USER _INVITE _STATUS _FETCH _STARTED : USER _INVITE _STATUS _FETCH _STARTED ,
USER _INVITE _STATUS _FETCH _SUCCESS : USER _INVITE _STATUS _FETCH _SUCCESS ,
USER _INVITE _STATUS _FETCH _FAILURE : USER _INVITE _STATUS _FETCH _FAILURE ,
USER _INVITE _NEW _STARTED : USER _INVITE _NEW _STARTED ,
USER _INVITE _NEW _SUCCESS : USER _INVITE _NEW _SUCCESS ,
USER _INVITE _NEW _FAILURE : USER _INVITE _NEW _FAILURE ,
FETCH _ACCESS _TOKEN _SUCCESS : FETCH _ACCESS _TOKEN _SUCCESS ,
FETCH _REWARDS _STARTED : FETCH _REWARDS _STARTED ,
FETCH _REWARDS _COMPLETED : FETCH _REWARDS _COMPLETED ,
CLAIM _REWARD _STARTED : CLAIM _REWARD _STARTED ,
CLAIM _REWARD _SUCCESS : CLAIM _REWARD _SUCCESS ,
CLAIM _REWARD _FAILURE : CLAIM _REWARD _FAILURE ,
CLAIM _REWARD _CLEAR _ERROR : CLAIM _REWARD _CLEAR _ERROR ,
FETCH _REWARD _CONTENT _COMPLETED : FETCH _REWARD _CONTENT _COMPLETED ,
DOWNLOAD _LANGUAGE _SUCCEEDED : DOWNLOAD _LANGUAGE _SUCCEEDED ,
DOWNLOAD _LANGUAGE _FAILED : DOWNLOAD _LANGUAGE _FAILED ,
CHANNEL _SUBSCRIBE : CHANNEL _SUBSCRIBE ,
CHANNEL _UNSUBSCRIBE : CHANNEL _UNSUBSCRIBE ,
HAS _FETCHED _SUBSCRIPTIONS : HAS _FETCHED _SUBSCRIPTIONS ,
SET _SUBSCRIPTION _LATEST : SET _SUBSCRIPTION _LATEST ,
SET _SUBSCRIPTION _NOTIFICATION : SET _SUBSCRIPTION _NOTIFICATION ,
SET _SUBSCRIPTION _NOTIFICATIONS : SET _SUBSCRIPTION _NOTIFICATIONS ,
CHECK _SUBSCRIPTION _STARTED : CHECK _SUBSCRIPTION _STARTED ,
CHECK _SUBSCRIPTION _COMPLETED : CHECK _SUBSCRIPTION _COMPLETED ,
CHECK _SUBSCRIPTIONS _SUBSCRIBE : CHECK _SUBSCRIPTIONS _SUBSCRIBE ,
CLEAR _PUBLISH : CLEAR _PUBLISH ,
UPDATE _PUBLISH _FORM : UPDATE _PUBLISH _FORM ,
PUBLISH _START : PUBLISH _START ,
PUBLISH _SUCCESS : PUBLISH _SUCCESS ,
PUBLISH _FAIL : PUBLISH _FAIL ,
CLEAR _PUBLISH _ERROR : CLEAR _PUBLISH _ERROR ,
REMOVE _PENDING _PUBLISH : REMOVE _PENDING _PUBLISH ,
DO _PREPARE _EDIT : DO _PREPARE _EDIT ,
CREATE _NOTIFICATION : CREATE _NOTIFICATION ,
EDIT _NOTIFICATION : EDIT _NOTIFICATION ,
DELETE _NOTIFICATION : DELETE _NOTIFICATION ,
DISMISS _NOTIFICATION : DISMISS _NOTIFICATION ,
CREATE _TOAST : CREATE _TOAST ,
DISMISS _TOAST : DISMISS _TOAST ,
CREATE _ERROR : CREATE _ERROR ,
DISMISS _ERROR : DISMISS _ERROR ,
FETCH _DATE : FETCH _DATE ,
FETCH _COST _INFO _STARTED : FETCH _COST _INFO _STARTED ,
FETCH _COST _INFO _COMPLETED : FETCH _COST _INFO _COMPLETED ,
FETCH _COST _INFO _FAILED : FETCH _COST _INFO _FAILED ,
TOGGLE _TAG _FOLLOW : TOGGLE _TAG _FOLLOW ,
TAG _ADD : TAG _ADD ,
2019-08-02 02:57:27 +02:00
TAG _DELETE : TAG _DELETE ,
2019-09-10 20:14:40 +02:00
TOGGLE _BLOCK _CHANNEL : TOGGLE _BLOCK _CHANNEL ,
2019-09-13 21:52:52 +02:00
USER _STATE _POPULATE : USER _STATE _POPULATE
2019-04-03 19:12:51 +02:00
} ) ;
2019-07-01 21:49:51 +02:00
const CC _LICENSES = [ {
value : 'Creative Commons Attribution 4.0 International' ,
url : 'https://creativecommons.org/licenses/by/4.0/legalcode'
} , {
value : 'Creative Commons Attribution-ShareAlike 4.0 International' ,
url : 'https://creativecommons.org/licenses/by-sa/4.0/legalcode'
} , {
value : 'Creative Commons Attribution-NoDerivatives 4.0 International' ,
url : 'https://creativecommons.org/licenses/by-nd/4.0/legalcode'
} , {
value : 'Creative Commons Attribution-NonCommercial 4.0 International' ,
url : 'https://creativecommons.org/licenses/by-nc/4.0/legalcode'
} , {
value : 'Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International' ,
url : 'https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode'
} , {
value : 'Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International' ,
url : 'https://creativecommons.org/licenses/by-nc-nd/4.0/legalcode'
} ] ;
const NONE = 'None' ;
const PUBLIC _DOMAIN = 'Public Domain' ;
const OTHER = 'other' ;
const COPYRIGHT = 'copyright' ;
var licenses = /*#__PURE__*/ Object . freeze ( {
CC _LICENSES : CC _LICENSES ,
NONE : NONE ,
PUBLIC _DOMAIN : PUBLIC _DOMAIN ,
OTHER : OTHER ,
COPYRIGHT : COPYRIGHT
} ) ;
2019-04-03 19:12:51 +02:00
2019-07-01 21:49:51 +02:00
const AUTH = 'auth' ;
const BACKUP = 'backup' ;
const CHANNEL = 'channel' ;
const DISCOVER = 'discover' ;
const FILE = 'file' ;
const DOWNLOADED = 'downloaded' ;
const PUBLISHED = 'published' ;
const GET _CREDITS = 'getcredits' ;
const HELP = 'help' ;
const INVITE = 'invite' ;
const PUBLISH = 'publish' ;
const REPORT = 'report' ;
const REWARDS = 'rewards' ;
const SEARCH = 'search' ;
const SEND _CREDITS = 'send' ;
const SETTINGS = 'settings' ;
const SHOW = 'show' ;
const SUBSCRIPTIONS = 'subscriptions' ;
const TRANSACTION _HISTORY = 'history' ;
const HISTORY = 'user_history' ;
const WALLET = 'wallet' ;
var pages = /*#__PURE__*/ Object . freeze ( {
AUTH : AUTH ,
BACKUP : BACKUP ,
CHANNEL : CHANNEL ,
DISCOVER : DISCOVER ,
FILE : FILE ,
DOWNLOADED : DOWNLOADED ,
PUBLISHED : PUBLISHED ,
GET _CREDITS : GET _CREDITS ,
HELP : HELP ,
INVITE : INVITE ,
PUBLISH : PUBLISH ,
REPORT : REPORT ,
REWARDS : REWARDS ,
SEARCH : SEARCH ,
SEND _CREDITS : SEND _CREDITS ,
SETTINGS : SETTINGS ,
SHOW : SHOW ,
SUBSCRIPTIONS : SUBSCRIPTIONS ,
TRANSACTION _HISTORY : TRANSACTION _HISTORY ,
HISTORY : HISTORY ,
WALLET : WALLET
2019-04-03 19:12:51 +02:00
} ) ;
/* hardcoded names still exist for these in reducers/settings.js - only discovered when debugging */
/ * M a n y S E T T I N G S a r e s t o r e d i n t h e l o c a l S t o r a g e b y t h e i r n a m e -
be careful about changing the value of a SETTINGS constant , as doing so can invalidate existing SETTINGS * /
const CREDIT _REQUIRED _ACKNOWLEDGED = 'credit_required_acknowledged' ;
const NEW _USER _ACKNOWLEDGED = 'welcome_acknowledged' ;
const EMAIL _COLLECTION _ACKNOWLEDGED = 'email_collection_acknowledged' ;
const LANGUAGE = 'language' ;
const SHOW _NSFW = 'showNsfw' ;
const SHOW _UNAVAILABLE = 'showUnavailable' ;
const INSTANT _PURCHASE _ENABLED = 'instantPurchaseEnabled' ;
const INSTANT _PURCHASE _MAX = 'instantPurchaseMax' ;
const THEME = 'theme' ;
const THEMES = 'themes' ;
const AUTOMATIC _DARK _MODE _ENABLED = 'automaticDarkModeEnabled' ;
// mobile settings
const BACKGROUND _PLAY _ENABLED = 'backgroundPlayEnabled' ;
const FOREGROUND _NOTIFICATION _ENABLED = 'foregroundNotificationEnabled' ;
const KEEP _DAEMON _RUNNING = 'keepDaemonRunning' ;
var settings = /*#__PURE__*/ Object . freeze ( {
2019-07-01 21:49:51 +02:00
CREDIT _REQUIRED _ACKNOWLEDGED : CREDIT _REQUIRED _ACKNOWLEDGED ,
NEW _USER _ACKNOWLEDGED : NEW _USER _ACKNOWLEDGED ,
EMAIL _COLLECTION _ACKNOWLEDGED : EMAIL _COLLECTION _ACKNOWLEDGED ,
LANGUAGE : LANGUAGE ,
SHOW _NSFW : SHOW _NSFW ,
SHOW _UNAVAILABLE : SHOW _UNAVAILABLE ,
INSTANT _PURCHASE _ENABLED : INSTANT _PURCHASE _ENABLED ,
INSTANT _PURCHASE _MAX : INSTANT _PURCHASE _MAX ,
THEME : THEME ,
THEMES : THEMES ,
AUTOMATIC _DARK _MODE _ENABLED : AUTOMATIC _DARK _MODE _ENABLED ,
BACKGROUND _PLAY _ENABLED : BACKGROUND _PLAY _ENABLED ,
FOREGROUND _NOTIFICATION _ENABLED : FOREGROUND _NOTIFICATION _ENABLED ,
KEEP _DAEMON _RUNNING : KEEP _DAEMON _RUNNING
2019-04-03 19:12:51 +02:00
} ) ;
const DATE _NEW = 'dateNew' ;
const DATE _OLD = 'dateOld' ;
const TITLE = 'title' ;
const FILENAME = 'filename' ;
var sort _options = /*#__PURE__*/ Object . freeze ( {
2019-07-01 21:49:51 +02:00
DATE _NEW : DATE _NEW ,
DATE _OLD : DATE _OLD ,
TITLE : TITLE ,
FILENAME : FILENAME
2019-04-03 19:12:51 +02:00
} ) ;
2019-07-01 21:49:51 +02:00
const API _DOWN = 'apiDown' ;
const READY = 'ready' ;
const IN _PROGRESS = 'inProgress' ;
const COMPLETE = 'complete' ;
const MANUAL = 'manual' ;
var thumbnail _upload _statuses = /*#__PURE__*/ Object . freeze ( {
API _DOWN : API _DOWN ,
READY : READY ,
IN _PROGRESS : IN _PROGRESS ,
COMPLETE : COMPLETE ,
MANUAL : MANUAL
} ) ;
// eslint-disable-next-line import/prefer-default-export
const ALL = 'all' ;
const SPEND = 'spend' ;
const RECEIVE = 'receive' ;
2019-04-03 19:12:51 +02:00
const PUBLISH$1 = 'publish' ;
2019-07-01 21:49:51 +02:00
const CHANNEL$1 = 'channel' ;
const TIP = 'tip' ;
const SUPPORT = 'support' ;
const UPDATE = 'update' ;
const ABANDON = 'abandon' ;
2019-04-03 19:12:51 +02:00
2019-07-01 21:49:51 +02:00
var transaction _types = /*#__PURE__*/ Object . freeze ( {
ALL : ALL ,
SPEND : SPEND ,
RECEIVE : RECEIVE ,
PUBLISH : PUBLISH$1 ,
CHANNEL : CHANNEL$1 ,
TIP : TIP ,
SUPPORT : SUPPORT ,
UPDATE : UPDATE ,
ABANDON : ABANDON
2019-04-03 19:12:51 +02:00
} ) ;
2019-09-25 18:30:26 +02:00
// PAGE SIZE
const PAGE _SIZE$1 = 50 ;
var transaction _list = /*#__PURE__*/ Object . freeze ( {
PAGE _SIZE : PAGE _SIZE$1
} ) ;
2019-04-03 19:12:51 +02:00
const SEARCH _TYPES = {
FILE : 'file' ,
CHANNEL : 'channel' ,
2019-07-10 18:48:50 +02:00
SEARCH : 'search' ,
TAG : 'tag'
2019-04-03 19:12:51 +02:00
} ;
const SEARCH _OPTIONS = {
RESULT _COUNT : 'size' ,
CLAIM _TYPE : 'claimType' ,
INCLUDE _FILES : 'file' ,
INCLUDE _CHANNELS : 'channel' ,
INCLUDE _FILES _AND _CHANNELS : 'file,channel' ,
MEDIA _AUDIO : 'audio' ,
MEDIA _VIDEO : 'video' ,
MEDIA _TEXT : 'text' ,
MEDIA _IMAGE : 'image' ,
MEDIA _APPLICATION : 'application'
} ;
2019-07-23 21:39:45 +02:00
const DEFAULT _FOLLOWED _TAGS = [ 'art' , 'automotive' , 'blockchain' , 'comedy' , 'economics' , 'education' , 'gaming' , 'music' , 'news' , 'science' , 'sports' , 'technology' ] ;
2019-07-02 22:33:57 +02:00
const MATURE _TAGS = [ 'porn' , 'nsfw' , 'mature' , 'xxx' ] ;
2019-07-23 21:42:48 +02:00
const DEFAULT _KNOWN _TAGS = [ 'gaming' , 'pop culture' , 'Entertainment' , 'technology' , 'music' , 'funny' , 'Education' , 'learning' , 'news' , 'gameplay' , 'nature' , 'beliefs' , 'comedy' , 'games' , 'sony interactive entertainment' , 'film & animation' , 'game' , 'weapons' , "let's play" , 'blockchain' , 'video game' , 'sports' , 'walkthrough' , 'ps4live' , 'art' , 'pc' , 'minecraft' , 'playthrough' , 'economics' , 'automotive' , 'play' , 'ps4share' , 'tutorial' , 'twitch' , 'how to' , 'ps4' , 'bitcoin' , 'fortnite' , 'commentary' , 'lets play' , 'fun' , 'politics' , 'xbox' , 'autos & vehicles' , 'Travel & Events' , 'food' , 'science' , 'xbox one' , 'liberal' , 'democrat' , 'progressive' , 'survival' , 'Nonprofits & Activism' , 'cryptocurrency' , 'playstation' , 'nintendo' , 'government' , 'steam' , 'podcast' , 'gamer' , 'horror' , 'conservative' , 'reaction' , 'trailer' , 'love' , 'cnn' , 'republican' , 'political' , 'hangoutsonair' , 'hoa' , 'msnbc' , 'cbs' , 'anime' , 'donald trump' , 'fiction' , 'fox news' , 'crypto' , 'ethereum' , 'call of duty' , 'android' , 'multiplayer' , 'epic' , 'rpg' , 'adventure' , 'secular talk' , 'btc' , 'atheist' , 'atheism' , 'video games' , 'ps3' , 'cod' , 'online' , 'agnostic' , 'movie' , 'fps' , 'lets' , 'mod' , 'world' , 'reviews' , 'sharefactory' , 'space' , 'pokemon' , 'stream' , 'hilarious' , 'lol' , 'sony' , 'god' , "let's" , 'dance' , 'pvp' , 'tech' , 'strategy' , 'zombies' , 'fail' , 'film' , 'xbox 360' , 'animation' , 'unboxing' , 'money' , 'how' , 'travel' , 'wwe' , 'mods' , 'indie' , 'pubg' , 'ios' , 'history' , 'rap' , 'sony computer entertainment' , 'mobile' , 'trump' , 'hack' , 'flat earth' , 'trap' , 'humor' , 'vlogging' , 'fox' , 'news radio' , 'facebook' , 'edm' , 'fitness' , 'vaping' , 'hip hop' , 'secular' , 'jesus' , 'song' , 'vape' , 'guitar' , 'remix' , 'mining' , 'daily' , 'diy' , 'pets & animals' , 'videogame' , 'death' , 'funny moments' , 'religion' , 'media' , 'viral' , 'war' , 'nbc' , 'freedom' , 'gold' , 'family' , 'meme' , 'zombie' , 'photography' , 'chill' , 'sniper' , 'computer' , 'iphone' , 'dragon' , 'bible' , 'pro' , 'overwatch' , 'litecoin' , 'gta' , 'house' , 'fire' , 'bass' , 'bitcoin news' , 'truth' , 'crash' , 'mario' , 'league of legends' , 'wii' , 'mmorpg' , 'grand theft auto v' , 'health' , 'marvel' , 'racing' , 'apple' , 'instrumental' , 'earth' , 'destiny' , 'satire' , 'race' , 'training' , 'electronic' , 'boss' , 'roblox' , 'family friendly' , 'california' , 'react' , 'christian' , 'mmo' , 'twitter' , 'help' , 'star' , 'cars' , 'random' , 'top 10' , 'ninja' , 'guns' , 'linux' , 'lessons' , 'vegan' , 'future' , 'dota 2' , 'studio' , 'star wars' , 'gta 5' , 'shooting' , 'nasa' , 'rock' , 'league' , 'subscribe' , 'water' , 'gta v' , 'car' , 'samsung' , 'music video' , 'skyrim' , 'dog' , 'comics' , 'shooter game' , 'bo3' , 'halloween' , 'liberty' , 'eth' , 'conspiracy' , 'knife' , 'fashion' , 'stories' , 'vapor' , 'nvidia' , 'cute' , 'beat' , 'nintendo switch' , 'fantasy' , 'christmas' , 'world of warcraft' , 'industry' , 'cartoon' , 'crypto news' , 'garden' , 'animals' , 'windows' , 'happy' , 'magic' , 'memes' , 'design' , 'tactical' , 'fallout 4' , 'puzzle' , 'parody' , 'rv' , 'beats' , 'fortnite battle royale' , 'building' , 'disney' , 'drone' , 'ps2' , 'beach' , 'metal' , 'christianity' , 'business' , 'mix' , 'bo2' , 'cover' , 'senate' , '4k' , 'united states' , 'final' , 'hero' , 'playing' , 'dlc' , 'ubisoft' , 'halo' , 'pc gaming' , 'raw' , 'investing' , 'online learning' , 'software' , 'ark' , 'mojang' , 'console' , 'battle royale' , 'canon' , 'microsoft' , 'camping' , 'cryptocurrency news' , 'ufo' , 'progressive talk' , 'switch' , 'fpv' , 'arcade' , 'school' , 'driving' , 'bodybuilding' , 'drama' , 'retro' , 'science fiction' , 'eggs' , 'australia' , 'modded' , 'rainbow' , 'gamers' , 'resident evil' , 'drawing' , 'brasil' , 'england' , 'hillary clinton' , 'singing' , 'final fantasy' , 'hiphop' , 'video blog' , 'mature' , 'quad' , 'noob' , 'simulation' , 'illuminati' , 'poetry' , 'dayz' , 'manga' , 'howto' , 'insane' , 'xbox360' , 'press' , 'special' , 'church' , 'ico' , 'weird' , 'libertarian' , 'crafting' , 'level' , 'comic' , 'sandbox' , 'daily vlog' , 'outdoor' , 'black ops' , 'sound' , 'christ' , 'duty' , 'Juvenile fiction' , 'pc game' , 'how-to' , 'ww2' , 'creepy' , 'artist' , 'galaxy' , 'destiny 2' , 'new music' , 'quest' , 'lee' , 'pacman' , 'super smash bros' , 'day' , 'survival horror' ,
2019-07-02 22:33:57 +02:00
2019-04-03 19:12:51 +02:00
//
const CHECK _DAEMON _STARTED _TRY _NUMBER = 200 ;
2019-04-23 19:22:14 +02:00
//
// Basic LBRY sdk connection config
// Offers a proxy to call LBRY sdk methods
2019-04-03 19:12:51 +02:00
2019-04-23 19:22:14 +02:00
//
2019-04-03 19:12:51 +02:00
const Lbry = {
isConnected : false ,
2019-04-23 19:22:14 +02:00
connectPromise : null ,
2019-04-03 19:12:51 +02:00
daemonConnectionString : 'http://localhost:5279' ,
2019-09-10 20:14:40 +02:00
apiRequestHeaders : { 'Content-Type' : 'application/json-rpc' } ,
2019-04-23 19:22:14 +02:00
// Allow overriding daemon connection string (e.g. to `/api/proxy` for lbryweb)
setDaemonConnectionString : value => {
Lbry . daemonConnectionString = value ;
} ,
2019-05-30 17:24:46 +02:00
setApiHeader : ( key , value ) => {
Lbry . apiRequestHeaders = Object . assign ( Lbry . apiRequestHeaders , { [ key ] : value } ) ;
} ,
unsetApiHeader : key => {
Object . keys ( Lbry . apiRequestHeaders ) . includes ( key ) && delete Lbry . apiRequestHeaders [ 'key' ] ;
} ,
2019-04-23 19:22:14 +02:00
// Allow overriding Lbry methods
overrides : { } ,
setOverride : ( methodName , newMethod ) => {
Lbry . overrides [ methodName ] = newMethod ;
} ,
// Returns a human readable media type based on the content type or extension of a file that is returned by the sdk
2019-08-02 08:21:28 +02:00
getMediaType : ( contentType , fileName ) => {
2019-08-16 07:16:04 +02:00
if ( fileName ) {
2019-09-04 17:57:48 +02:00
const formats = [ [ /\.(mp4|m4v|webm|flv|f4v|ogv)$/i , 'video' ] , [ /\.(mp3|m4a|aac|wav|flac|ogg|opus)$/i , 'audio' ] , [ /\.(jpeg|jpg|png|gif|svg)$/i , 'image' ] , [ /\.(h|go|ja|java|js|jsx|c|cpp|cs|css|rb|scss|sh|php|py)$/i , 'script' ] , [ /\.(json|csv|txt|log|md|markdown|docx|pdf|xml|yml|yaml)$/i , 'document' ] , [ /\.(pdf|odf|doc|docx|epub|org|rtf)$/i , 'e-book' ] , [ /\.(stl|obj|fbx|gcode)$/i , '3D-file' ] , [ /\.(cbr|cbt|cbz)$/i , 'comic-book' ] , [ /\.(lbry)$/i , 'application' ] ] ;
2019-08-02 08:21:28 +02:00
2019-04-23 19:22:14 +02:00
const res = formats . reduce ( ( ret , testpair ) => {
2019-08-16 07:16:04 +02:00
switch ( testpair [ 0 ] . test ( ret ) ) {
case true :
return testpair [ 1 ] ;
default :
return ret ;
}
} , fileName ) ;
return res === fileName ? 'unknown' : res ;
} else if ( contentType ) {
// $FlowFixMe
return ( /^[^/]+/ . exec ( contentType ) [ 0 ]
) ;
2019-04-23 19:22:14 +02:00
}
2019-08-02 08:21:28 +02:00
2019-04-23 19:22:14 +02:00
return 'unknown' ;
} ,
//
// Lbry SDK Methods
// https://lbry.tech/api/sdk
//
status : ( params = { } ) => daemonCallWithResult ( 'status' , params ) ,
stop : ( ) => daemonCallWithResult ( 'stop' , { } ) ,
version : ( ) => daemonCallWithResult ( 'version' , { } ) ,
// Claim fetching and manipulation
resolve : params => daemonCallWithResult ( 'resolve' , params ) ,
get : params => daemonCallWithResult ( 'get' , params ) ,
publish : params => daemonCallWithResult ( 'publish' , params ) ,
claim _search : params => daemonCallWithResult ( 'claim_search' , params ) ,
claim _list : params => daemonCallWithResult ( 'claim_list' , params ) ,
channel _create : params => daemonCallWithResult ( 'channel_create' , params ) ,
2019-07-01 03:16:44 +02:00
channel _update : params => daemonCallWithResult ( 'channel_update' , params ) ,
2019-09-12 21:06:49 +02:00
channel _import : params => daemonCallWithResult ( 'channel_import' , params ) ,
2019-04-23 19:22:14 +02:00
channel _list : params => daemonCallWithResult ( 'channel_list' , params ) ,
stream _abandon : params => daemonCallWithResult ( 'stream_abandon' , params ) ,
channel _abandon : params => daemonCallWithResult ( 'channel_abandon' , params ) ,
support _create : params => daemonCallWithResult ( 'support_create' , params ) ,
// File fetching and manipulation
file _list : ( params = { } ) => daemonCallWithResult ( 'file_list' , params ) ,
file _delete : ( params = { } ) => daemonCallWithResult ( 'file_delete' , params ) ,
file _set _status : ( params = { } ) => daemonCallWithResult ( 'file_set_status' , params ) ,
blob _delete : ( params = { } ) => daemonCallWithResult ( 'blob_delete' , params ) ,
blob _list : ( params = { } ) => daemonCallWithResult ( 'blob_list' , params ) ,
// Wallet utilities
2019-09-24 00:56:53 +02:00
account _balance : ( params = { } ) => daemonCallWithResult ( 'account_balance' , params ) ,
2019-04-23 19:22:14 +02:00
account _decrypt : ( ) => daemonCallWithResult ( 'account_decrypt' , { } ) ,
account _encrypt : ( params = { } ) => daemonCallWithResult ( 'account_encrypt' , params ) ,
account _unlock : ( params = { } ) => daemonCallWithResult ( 'account_unlock' , params ) ,
account _list : ( params = { } ) => daemonCallWithResult ( 'account_list' , params ) ,
account _send : ( params = { } ) => daemonCallWithResult ( 'account_send' , params ) ,
2019-05-15 11:58:36 +02:00
account _set : ( params = { } ) => daemonCallWithResult ( 'account_set' , params ) ,
2019-04-23 19:22:14 +02:00
address _is _mine : ( params = { } ) => daemonCallWithResult ( 'address_is_mine' , params ) ,
address _unused : ( params = { } ) => daemonCallWithResult ( 'address_unused' , params ) ,
2019-09-17 19:48:41 +02:00
address _list : ( params = { } ) => daemonCallWithResult ( 'address_list' , params ) ,
2019-04-23 19:22:14 +02:00
transaction _list : ( params = { } ) => daemonCallWithResult ( 'transaction_list' , params ) ,
utxo _release : ( params = { } ) => daemonCallWithResult ( 'utxo_release' , params ) ,
2019-05-10 07:02:03 +02:00
support _abandon : ( params = { } ) => daemonCallWithResult ( 'support_abandon' , params ) ,
2019-04-23 19:22:14 +02:00
sync _hash : ( params = { } ) => daemonCallWithResult ( 'sync_hash' , params ) ,
sync _apply : ( params = { } ) => daemonCallWithResult ( 'sync_apply' , params ) ,
2019-06-12 03:14:37 +02:00
// Comments
comment _list : ( params = { } ) => daemonCallWithResult ( 'comment_list' , params ) ,
comment _create : ( params = { } ) => daemonCallWithResult ( 'comment_create' , params ) ,
2019-04-23 19:22:14 +02:00
// Connect to the sdk
connect : ( ) => {
if ( Lbry . connectPromise === null ) {
Lbry . connectPromise = new Promise ( ( resolve , reject ) => {
let tryNum = 0 ;
// Check every half second to see if the daemon is accepting connections
function checkDaemonStarted ( ) {
tryNum += 1 ;
Lbry . status ( ) . then ( resolve ) . catch ( ( ) => {
if ( tryNum <= CHECK _DAEMON _STARTED _TRY _NUMBER ) {
setTimeout ( checkDaemonStarted , tryNum < 50 ? 400 : 1000 ) ;
} else {
reject ( new Error ( 'Unable to connect to LBRY' ) ) ;
}
} ) ;
}
checkDaemonStarted ( ) ;
} ) ;
}
// Flow thinks this could be empty, but it will always reuturn a promise
// $FlowFixMe
return Lbry . connectPromise ;
}
2019-04-03 19:12:51 +02:00
} ;
function checkAndParse ( response ) {
if ( response . status >= 200 && response . status < 300 ) {
return response . json ( ) ;
}
return response . json ( ) . then ( json => {
let error ;
if ( json . error ) {
const errorMessage = typeof json . error === 'object' ? json . error . message : json . error ;
error = new Error ( errorMessage ) ;
} else {
error = new Error ( 'Protocol error with unknown response signature' ) ;
}
return Promise . reject ( error ) ;
} ) ;
}
function apiCall ( method , params , resolve , reject ) {
const counter = new Date ( ) . getTime ( ) ;
const options = {
method : 'POST' ,
2019-05-30 17:24:46 +02:00
headers : Lbry . apiRequestHeaders ,
2019-04-03 19:12:51 +02:00
body : JSON . stringify ( {
jsonrpc : '2.0' ,
method ,
params ,
id : counter
} )
} ;
return fetch ( Lbry . daemonConnectionString , options ) . then ( checkAndParse ) . then ( response => {
const error = response . error || response . result && response . result . error ;
if ( error ) {
return reject ( error ) ;
}
return resolve ( response . result ) ;
} ) . catch ( reject ) ;
}
2019-04-23 19:22:14 +02:00
function daemonCallWithResult ( name , params = { } ) {
return new Promise ( ( resolve , reject ) => {
apiCall ( name , params , result => {
resolve ( result ) ;
} , reject ) ;
} ) ;
}
2019-04-03 19:12:51 +02:00
2019-04-23 19:22:14 +02:00
// This is only for a fallback
// If there is a Lbry method that is being called by an app, it should be added to /flow-typed/Lbry.js
2019-04-03 19:12:51 +02:00
const lbryProxy = new Proxy ( Lbry , {
get ( target , name ) {
if ( name in target ) {
return target [ name ] ;
}
return ( params = { } ) => new Promise ( ( resolve , reject ) => {
apiCall ( name , params , resolve , reject ) ;
} ) ;
}
} ) ;
//
const DEFAULT _SEARCH _RESULT _FROM = 0 ;
const DEFAULT _SEARCH _SIZE = 20 ;
function parseQueryParams ( queryString ) {
if ( queryString === '' ) return { } ;
const parts = queryString . split ( '?' ) . pop ( ) . split ( '&' ) . map ( p => p . split ( '=' ) ) ;
const params = { } ;
parts . forEach ( array => {
const [ first , second ] = array ;
params [ first ] = second ;
} ) ;
return params ;
}
function toQueryString ( params ) {
if ( ! params ) return '' ;
const parts = [ ] ;
Object . keys ( params ) . forEach ( key => {
if ( Object . prototype . hasOwnProperty . call ( params , key ) && params [ key ] ) {
parts . push ( ` ${ key } = ${ params [ key ] } ` ) ;
}
} ) ;
return parts . join ( '&' ) ;
}
const getSearchQueryString = ( query , options = { } , includeUserOptions = false ) => {
const encodedQuery = encodeURIComponent ( query ) ;
const queryParams = [ ` s= ${ encodedQuery } ` , ` size= ${ options . size || DEFAULT _SEARCH _SIZE } ` , ` from= ${ options . from || DEFAULT _SEARCH _RESULT _FROM } ` ] ;
if ( includeUserOptions ) {
2019-05-07 06:18:22 +02:00
const claimType = options [ SEARCH _OPTIONS . CLAIM _TYPE ] ;
queryParams . push ( ` claimType= ${ claimType } ` ) ;
2019-04-03 19:12:51 +02:00
// If they are only searching for channels, strip out the media info
2019-05-07 06:18:22 +02:00
if ( ! claimType . includes ( SEARCH _OPTIONS . INCLUDE _CHANNELS ) ) {
2019-04-03 19:12:51 +02:00
queryParams . push ( ` mediaType= ${ [ SEARCH _OPTIONS . MEDIA _FILE , SEARCH _OPTIONS . MEDIA _AUDIO , SEARCH _OPTIONS . MEDIA _VIDEO , SEARCH _OPTIONS . MEDIA _TEXT , SEARCH _OPTIONS . MEDIA _IMAGE , SEARCH _OPTIONS . MEDIA _APPLICATION ] . reduce ( ( acc , currentOption ) => options [ currentOption ] ? ` ${ acc } ${ currentOption } , ` : acc , '' ) } ` ) ;
}
}
return queryParams . join ( '&' ) ;
} ;
var _extends = Object . assign || function ( target ) { for ( var i = 1 ; i < arguments . length ; i ++ ) { var source = arguments [ i ] ; for ( var key in source ) { if ( Object . prototype . hasOwnProperty . call ( source , key ) ) { target [ key ] = source [ key ] ; } } } return target ; } ;
2019-08-20 22:00:26 +02:00
function _objectWithoutProperties ( obj , keys ) { var target = { } ; for ( var i in obj ) { if ( keys . indexOf ( i ) >= 0 ) continue ; if ( ! Object . prototype . hasOwnProperty . call ( obj , i ) ) continue ; target [ i ] = obj [ i ] ; } return target ; }
2019-08-29 18:38:00 +02:00
const channelNameMinLength = 1 ;
2019-04-03 19:12:51 +02:00
const claimIdMaxLength = 40 ;
2019-06-03 04:55:52 +02:00
// see https://spec.lbry.com/#urls
2019-07-30 18:15:29 +02:00
const regexInvalidURI = /[ =&#:$@%?;/\\"<>%{}|^~[\]`\u{0000}-\u{0008}\u{000b}-\u{000c}\u{000e}-\u{001F}\u{D800}-\u{DFFF}\u{FFFE}-\u{FFFF}]/u ;
2019-04-03 19:12:51 +02:00
const regexAddress = /^(b|r)(?=[^0OIl]{32,33})[0-9A-Za-z]{32,33}$/ ;
2019-08-20 22:00:26 +02:00
const regexPartProtocol = '^((?:lbry://)?)' ;
const regexPartStreamOrChannelName = '([^:$#/]*)' ;
const regexPartModifierSeparator = '([:$#]?)([^/]*)' ;
2019-08-24 04:43:49 +02:00
const queryStringBreaker = '^([\\S]+)([?][\\S]*)' ;
const separateQuerystring = new RegExp ( queryStringBreaker ) ;
2019-04-03 19:12:51 +02:00
/ * *
* Parses a LBRY name into its component parts . Throws errors with user - friendly
* messages for invalid names .
*
* Returns a dictionary with keys :
2019-08-20 22:00:26 +02:00
* - path ( string )
2019-04-03 19:12:51 +02:00
* - isChannel ( boolean )
2019-08-20 22:00:26 +02:00
* - streamName ( string , if present )
* - streamClaimId ( string , if present )
* - channelName ( string , if present )
* - channelClaimId ( string , if present )
* - primaryClaimSequence ( int , if present )
* - secondaryClaimSequence ( int , if present )
* - primaryBidPosition ( int , if present )
* - secondaryBidPosition ( int , if present )
2019-04-03 19:12:51 +02:00
* /
2019-08-20 22:00:26 +02:00
function parseURI ( URL , requireProto = false ) {
2019-04-03 19:12:51 +02:00
// Break into components. Empty sub-matches are converted to null
2019-08-24 04:43:49 +02:00
2019-08-20 22:00:26 +02:00
const componentsRegex = new RegExp ( regexPartProtocol + // protocol
regexPartStreamOrChannelName + // stream or channel name (stops at the first separator or end)
regexPartModifierSeparator + // modifier separator, modifier (stops at the first path separator or end)
'(/?)' + // path separator, there should only be one (optional) slash to separate the stream and channel parts
regexPartStreamOrChannelName + regexPartModifierSeparator ) ;
2019-08-24 04:43:49 +02:00
// chop off the querystring first
let QSStrippedURL , qs ;
const qsRegexResult = separateQuerystring . exec ( URL ) ;
if ( qsRegexResult ) {
[ QSStrippedURL , qs ] = qsRegexResult . slice ( 1 ) . map ( match => match || null ) ;
}
2019-04-03 19:12:51 +02:00
2019-08-24 04:43:49 +02:00
const cleanURL = QSStrippedURL || URL ;
const regexMatch = componentsRegex . exec ( cleanURL ) || [ ] ;
2019-08-20 22:00:26 +02:00
const [ proto , ... rest ] = regexMatch . slice ( 1 ) . map ( match => match || null ) ;
const path = rest . join ( '' ) ;
const [ streamNameOrChannelName , primaryModSeparator , primaryModValue , pathSep , possibleStreamName , secondaryModSeparator , secondaryModValue ] = rest ;
2019-04-03 19:12:51 +02:00
// Validate protocol
if ( requireProto && ! proto ) {
2019-07-02 05:04:27 +02:00
throw new Error ( _ _ ( 'LBRY URIs must include a protocol prefix (lbry://).' ) ) ;
2019-04-03 19:12:51 +02:00
}
// Validate and process name
2019-08-20 22:00:26 +02:00
if ( ! streamNameOrChannelName ) {
2019-07-02 05:04:27 +02:00
throw new Error ( _ _ ( 'URI does not include name.' ) ) ;
2019-04-03 19:12:51 +02:00
}
2019-08-20 22:00:26 +02:00
const includesChannel = streamNameOrChannelName . startsWith ( '@' ) ;
const isChannel = streamNameOrChannelName . startsWith ( '@' ) && ! possibleStreamName ;
2019-08-29 18:38:00 +02:00
const channelName = includesChannel && streamNameOrChannelName . slice ( 1 ) ;
2019-04-03 19:12:51 +02:00
2019-08-20 22:00:26 +02:00
if ( includesChannel ) {
2019-04-03 19:12:51 +02:00
if ( ! channelName ) {
2019-07-02 05:04:27 +02:00
throw new Error ( _ _ ( 'No channel name after @.' ) ) ;
2019-04-03 19:12:51 +02:00
}
if ( channelName . length < channelNameMinLength ) {
2019-07-02 05:04:27 +02:00
throw new Error ( _ _ ( ` Channel names must be at least %s characters. ` , channelNameMinLength ) ) ;
2019-04-03 19:12:51 +02:00
}
}
2019-08-20 22:00:26 +02:00
// Validate and process modifier
const [ primaryClaimId , primaryClaimSequence , primaryBidPosition ] = parseURIModifier ( primaryModSeparator , primaryModValue ) ;
const [ secondaryClaimId , secondaryClaimSequence , secondaryBidPosition ] = parseURIModifier ( secondaryModSeparator , secondaryModValue ) ;
const streamName = includesChannel ? possibleStreamName : streamNameOrChannelName ;
const streamClaimId = includesChannel ? secondaryClaimId : primaryClaimId ;
const channelClaimId = includesChannel && primaryClaimId ;
2019-04-03 19:12:51 +02:00
2019-08-20 22:00:26 +02:00
return _extends ( {
isChannel ,
path
} , streamName ? { streamName } : { } , streamClaimId ? { streamClaimId } : { } , channelName ? { channelName } : { } , channelClaimId ? { channelClaimId } : { } , primaryClaimSequence ? { primaryClaimSequence : parseInt ( primaryClaimSequence , 10 ) } : { } , secondaryClaimSequence ? { secondaryClaimSequence : parseInt ( secondaryClaimSequence , 10 ) } : { } , primaryBidPosition ? { primaryBidPosition : parseInt ( primaryBidPosition , 10 ) } : { } , secondaryBidPosition ? { secondaryBidPosition : parseInt ( secondaryBidPosition , 10 ) } : { } , {
// The values below should not be used for new uses of parseURI
// They will not work properly with canonical_urls
claimName : streamNameOrChannelName ,
claimId : primaryClaimId
2019-08-28 19:19:12 +02:00
} , streamName ? { contentName : streamName } : { } , qs ? { queryString : qs } : { } ) ;
2019-08-20 22:00:26 +02:00
}
2019-04-03 19:12:51 +02:00
2019-08-20 22:00:26 +02:00
function parseURIModifier ( modSeperator , modValue ) {
2019-04-03 19:12:51 +02:00
let claimId ;
let claimSequence ;
let bidPosition ;
2019-08-24 04:43:49 +02:00
2019-08-20 22:00:26 +02:00
if ( modSeperator ) {
if ( ! modValue ) {
throw new Error ( _ _ ( ` No modifier provided after separator %s. ` , modSeperator ) ) ;
2019-04-03 19:12:51 +02:00
}
2019-08-20 22:00:26 +02:00
if ( modSeperator === '#' ) {
claimId = modValue ;
} else if ( modSeperator === ':' ) {
claimSequence = modValue ;
} else if ( modSeperator === '$' ) {
bidPosition = modValue ;
2019-04-03 19:12:51 +02:00
}
}
if ( claimId && ( claimId . length > claimIdMaxLength || ! claimId . match ( /^[0-9a-f]+$/ ) ) ) {
2019-07-02 05:04:27 +02:00
throw new Error ( _ _ ( ` Invalid claim ID %s. ` , claimId ) ) ;
2019-04-03 19:12:51 +02:00
}
if ( claimSequence && ! claimSequence . match ( /^-?[1-9][0-9]*$/ ) ) {
2019-07-02 05:04:27 +02:00
throw new Error ( _ _ ( 'Claim sequence must be a number.' ) ) ;
2019-04-03 19:12:51 +02:00
}
if ( bidPosition && ! bidPosition . match ( /^-?[1-9][0-9]*$/ ) ) {
2019-07-02 05:04:27 +02:00
throw new Error ( _ _ ( 'Bid position must be a number.' ) ) ;
2019-04-03 19:12:51 +02:00
}
2019-08-20 22:00:26 +02:00
return [ claimId , claimSequence , bidPosition ] ;
2019-04-03 19:12:51 +02:00
}
/ * *
* Takes an object in the same format returned by parse ( ) and builds a URI .
*
* The channelName key will accept names with or without the @ prefix .
* /
2019-08-20 22:00:26 +02:00
function buildURI ( UrlObj , includeProto = true , protoDefault = 'lbry://' ) {
const {
streamName ,
streamClaimId ,
channelName ,
channelClaimId ,
primaryClaimSequence ,
primaryBidPosition ,
secondaryClaimSequence ,
secondaryBidPosition
} = UrlObj ,
deprecatedParts = _objectWithoutProperties ( UrlObj , [ 'streamName' , 'streamClaimId' , 'channelName' , 'channelClaimId' , 'primaryClaimSequence' , 'primaryBidPosition' , 'secondaryClaimSequence' , 'secondaryBidPosition' ] ) ;
const { claimId , claimName , contentName } = deprecatedParts ;
if ( ! claimName && ! channelName && ! streamName ) {
2019-08-30 18:28:36 +02:00
console . error ( _ _ ( "'claimName', 'channelName', and 'streamName' are all empty. One must be present to build a url." ) ) ;
2019-04-03 19:12:51 +02:00
}
2019-08-20 22:00:26 +02:00
const formattedChannelName = channelName && ( channelName . startsWith ( '@' ) ? channelName : ` @ ${ channelName } ` ) ;
2019-08-22 17:03:13 +02:00
const primaryClaimName = claimName || contentName || formattedChannelName || streamName ;
2019-08-20 22:00:26 +02:00
const primaryClaimId = claimId || ( formattedChannelName ? channelClaimId : streamClaimId ) ;
2019-08-22 17:03:13 +02:00
const secondaryClaimName = ! claimName && contentName || ( formattedChannelName ? streamName : null ) ;
2019-08-20 22:00:26 +02:00
const secondaryClaimId = secondaryClaimName && streamClaimId ;
2019-04-03 19:12:51 +02:00
2019-08-20 22:00:26 +02:00
return ( includeProto ? protoDefault : '' ) +
// primaryClaimName will always exist here because we throw above if there is no "name" value passed in
// $FlowFixMe
primaryClaimName + ( primaryClaimId ? ` # ${ primaryClaimId } ` : '' ) + ( primaryClaimSequence ? ` : ${ primaryClaimSequence } ` : '' ) + ( primaryBidPosition ? ` ${ primaryBidPosition } ` : '' ) + ( secondaryClaimName ? ` / ${ secondaryClaimName } ` : '' ) + ( secondaryClaimId ? ` # ${ secondaryClaimId } ` : '' ) + ( secondaryClaimSequence ? ` : ${ secondaryClaimSequence } ` : '' ) + ( secondaryBidPosition ? ` ${ secondaryBidPosition } ` : '' ) ;
2019-04-03 19:12:51 +02:00
}
2019-08-20 22:00:26 +02:00
/* Takes a parseable LBRY URL and converts it to standard, canonical format */
function normalizeURI ( URL ) {
const {
streamName ,
streamClaimId ,
channelName ,
channelClaimId ,
primaryClaimSequence ,
primaryBidPosition ,
secondaryClaimSequence ,
secondaryBidPosition
} = parseURI ( URL ) ;
return buildURI ( {
streamName ,
streamClaimId ,
channelName ,
channelClaimId ,
primaryClaimSequence ,
primaryBidPosition ,
secondaryClaimSequence ,
secondaryBidPosition
} ) ;
2019-04-03 19:12:51 +02:00
}
2019-08-20 22:00:26 +02:00
function isURIValid ( URL ) {
2019-04-03 19:12:51 +02:00
try {
2019-08-20 22:00:26 +02:00
parseURI ( normalizeURI ( URL ) ) ;
2019-04-03 19:12:51 +02:00
} catch ( error ) {
return false ;
}
2019-08-20 22:00:26 +02:00
return true ;
2019-04-03 19:12:51 +02:00
}
2019-06-03 04:55:52 +02:00
function isNameValid ( claimName ) {
return ! regexInvalidURI . test ( claimName ) ;
2019-04-03 19:12:51 +02:00
}
2019-08-20 22:00:26 +02:00
function isURIClaimable ( URL ) {
2019-04-03 19:12:51 +02:00
let parts ;
try {
2019-08-20 22:00:26 +02:00
parts = parseURI ( normalizeURI ( URL ) ) ;
2019-04-03 19:12:51 +02:00
} catch ( error ) {
return false ;
}
2019-08-20 22:00:26 +02:00
return parts && parts . streamName && ! parts . streamClaimId && ! parts . isChannel ;
2019-04-03 19:12:51 +02:00
}
2019-08-20 22:00:26 +02:00
function convertToShareLink ( URL ) {
const {
streamName ,
streamClaimId ,
channelName ,
channelClaimId ,
primaryBidPosition ,
primaryClaimSequence ,
secondaryBidPosition ,
secondaryClaimSequence
} = parseURI ( URL ) ;
return buildURI ( {
streamName ,
streamClaimId ,
channelName ,
channelClaimId ,
primaryBidPosition ,
primaryClaimSequence ,
secondaryBidPosition ,
secondaryClaimSequence
} , true , 'https://open.lbry.com/' ) ;
2019-04-03 19:12:51 +02:00
}
var _extends$1 = Object . assign || function ( target ) { for ( var i = 1 ; i < arguments . length ; i ++ ) { var source = arguments [ i ] ; for ( var key in source ) { if ( Object . prototype . hasOwnProperty . call ( source , key ) ) { target [ key ] = source [ key ] ; } } } return target ; } ;
const selectState = state => state . search ;
const selectSearchValue = reselect . createSelector ( selectState , state => state . searchQuery ) ;
const selectSearchOptions = reselect . createSelector ( selectState , state => state . options ) ;
const selectSuggestions = reselect . createSelector ( selectState , state => state . suggestions ) ;
const selectIsSearching = reselect . createSelector ( selectState , state => state . searching ) ;
const selectSearchUrisByQuery = reselect . createSelector ( selectState , state => state . urisByQuery ) ;
const makeSelectSearchUris = query =>
// replace statement below is kind of ugly, and repeated in doSearch action
reselect . createSelector ( selectSearchUrisByQuery , byQuery => byQuery [ query ? query . replace ( /^lbry:\/\//i , '' ) . replace ( /\// , ' ' ) : query ] ) ;
const selectSearchBarFocused = reselect . createSelector ( selectState , state => state . focused ) ;
const selectSearchSuggestions = reselect . createSelector ( selectSearchValue , selectSuggestions , ( query , suggestions ) => {
if ( ! query ) {
return [ ] ;
}
2019-06-18 18:59:04 +02:00
const queryIsPrefix = query === 'lbry:' || query === 'lbry:/' || query === 'lbry://' || query === 'lbry://@' ;
2019-04-03 19:12:51 +02:00
2019-06-18 18:59:04 +02:00
if ( queryIsPrefix ) {
// If it is a prefix, wait until something else comes to figure out what to do
return [ ] ;
} else if ( query . startsWith ( 'lbry://' ) ) {
2019-04-03 19:12:51 +02:00
// If it starts with a prefix, don't show any autocomplete results
// They are probably typing/pasting in a lbry uri
return [ {
value : query ,
2019-06-18 18:59:04 +02:00
type : query [ 7 ] === '@' ? SEARCH _TYPES . CHANNEL : SEARCH _TYPES . FILE
2019-04-03 19:12:51 +02:00
} ] ;
}
let searchSuggestions = [ ] ;
try {
const uri = normalizeURI ( query ) ;
2019-08-20 22:00:26 +02:00
const { channelName , streamName , isChannel } = parseURI ( uri ) ;
2019-04-03 19:12:51 +02:00
searchSuggestions . push ( {
2019-08-28 01:14:19 +02:00
value : query ,
2019-04-03 19:12:51 +02:00
type : SEARCH _TYPES . SEARCH
} , {
value : uri ,
2019-08-20 22:00:26 +02:00
shorthand : isChannel ? channelName : streamName ,
2019-04-03 19:12:51 +02:00
type : isChannel ? SEARCH _TYPES . CHANNEL : SEARCH _TYPES . FILE
} ) ;
} catch ( e ) {
searchSuggestions . push ( {
value : query ,
type : SEARCH _TYPES . SEARCH
} ) ;
}
2019-07-10 18:48:50 +02:00
searchSuggestions . push ( {
value : query ,
type : SEARCH _TYPES . TAG
} ) ;
2019-04-03 19:12:51 +02:00
const apiSuggestions = suggestions [ query ] || [ ] ;
if ( apiSuggestions . length ) {
searchSuggestions = searchSuggestions . concat ( apiSuggestions . filter ( suggestion => suggestion !== query ) . map ( suggestion => {
// determine if it's a channel
try {
const uri = normalizeURI ( suggestion ) ;
2019-08-20 22:00:26 +02:00
const { channelName , streamName , isChannel } = parseURI ( uri ) ;
2019-04-03 19:12:51 +02:00
return {
value : uri ,
2019-08-20 22:00:26 +02:00
shorthand : isChannel ? channelName : streamName ,
2019-04-03 19:12:51 +02:00
type : isChannel ? SEARCH _TYPES . CHANNEL : SEARCH _TYPES . FILE
} ;
} catch ( e ) {
// search result includes some character that isn't valid in claim names
return {
value : suggestion ,
type : SEARCH _TYPES . SEARCH
} ;
}
} ) ) ;
}
return searchSuggestions ;
} ) ;
// Creates a query string based on the state in the search reducer
// Can be overrided by passing in custom sizes/from values for other areas pagination
const makeSelectQueryWithOptions = ( customQuery , customSize , customFrom , isBackgroundSearch = false // If it's a background search, don't use the users settings
) => reselect . createSelector ( selectSearchValue , selectSearchOptions , ( query , options ) => {
const size = customSize || options [ SEARCH _OPTIONS . RESULT _COUNT ] ;
const queryString = getSearchQueryString ( customQuery || query , _extends$1 ( { } , options , { size , from : customFrom } ) , ! isBackgroundSearch ) ;
return queryString ;
} ) ;
//
function doToast ( params ) {
if ( ! params ) {
throw Error ( "'params' object is required to create a toast notification" ) ;
}
return {
type : CREATE _TOAST ,
data : {
id : uuid ( ) ,
params
}
} ;
}
function doDismissToast ( ) {
return {
type : DISMISS _TOAST
} ;
}
function doError ( error ) {
return {
type : CREATE _ERROR ,
data : {
error
}
} ;
}
function doDismissError ( ) {
return {
type : DISMISS _ERROR
} ;
}
2019-09-23 04:25:12 +02:00
//
2019-08-15 08:13:50 +02:00
const selectState$1 = state => state . wallet || { } ;
const selectWalletState = selectState$1 ;
const selectWalletIsEncrypted = reselect . createSelector ( selectState$1 , state => state . walletIsEncrypted ) ;
const selectWalletEncryptPending = reselect . createSelector ( selectState$1 , state => state . walletEncryptPending ) ;
const selectWalletEncryptSucceeded = reselect . createSelector ( selectState$1 , state => state . walletEncryptSucceded ) ;
const selectWalletEncryptResult = reselect . createSelector ( selectState$1 , state => state . walletEncryptResult ) ;
const selectWalletDecryptPending = reselect . createSelector ( selectState$1 , state => state . walletDecryptPending ) ;
const selectWalletDecryptSucceeded = reselect . createSelector ( selectState$1 , state => state . walletDecryptSucceded ) ;
const selectWalletDecryptResult = reselect . createSelector ( selectState$1 , state => state . walletDecryptResult ) ;
const selectWalletUnlockPending = reselect . createSelector ( selectState$1 , state => state . walletUnlockPending ) ;
const selectWalletUnlockSucceeded = reselect . createSelector ( selectState$1 , state => state . walletUnlockSucceded ) ;
const selectWalletUnlockResult = reselect . createSelector ( selectState$1 , state => state . walletUnlockResult ) ;
const selectWalletLockPending = reselect . createSelector ( selectState$1 , state => state . walletLockPending ) ;
const selectWalletLockSucceeded = reselect . createSelector ( selectState$1 , state => state . walletLockSucceded ) ;
const selectWalletLockResult = reselect . createSelector ( selectState$1 , state => state . walletLockResult ) ;
const selectBalance = reselect . createSelector ( selectState$1 , state => state . balance ) ;
const selectTotalBalance = reselect . createSelector ( selectState$1 , state => state . totalBalance ) ;
2019-09-24 00:56:53 +02:00
const selectReservedBalance = reselect . createSelector ( selectState$1 , state => state . reservedBalance ) ;
const selectClaimsBalance = reselect . createSelector ( selectState$1 , state => state . claimsBalance ) ;
const selectSupportsBalance = reselect . createSelector ( selectState$1 , state => state . supportsBalance ) ;
const selectTipsBalance = reselect . createSelector ( selectState$1 , state => state . tipsBalance ) ;
2019-08-15 08:13:50 +02:00
const selectTransactionsById = reselect . createSelector ( selectState$1 , state => state . transactions || { } ) ;
const selectSupportsByOutpoint = reselect . createSelector ( selectState$1 , state => state . supports || { } ) ;
const selectTotalSupports = reselect . createSelector ( selectSupportsByOutpoint , byOutpoint => {
let total = parseFloat ( "0.0" ) ;
Object . values ( byOutpoint ) . forEach ( support => {
const { amount } = support ;
total = amount ? total + parseFloat ( amount ) : total ;
} ) ;
return total ;
} ) ;
const selectTransactionItems = reselect . createSelector ( selectTransactionsById , byId => {
const items = [ ] ;
Object . keys ( byId ) . forEach ( txid => {
const tx = byId [ txid ] ;
// ignore dust/fees
// it is fee only txn if all infos are also empty
if ( Math . abs ( tx . value ) === Math . abs ( tx . fee ) && tx . claim _info . length === 0 && tx . support _info . length === 0 && tx . update _info . length === 0 && tx . abandon _info . length === 0 ) {
return ;
}
const append = [ ] ;
append . push ( ... tx . claim _info . map ( item => Object . assign ( { } , tx , item , {
type : item . claim _name [ 0 ] === '@' ? CHANNEL$1 : PUBLISH$1
} ) ) ) ;
append . push ( ... tx . support _info . map ( item => Object . assign ( { } , tx , item , {
type : ! item . is _tip ? SUPPORT : TIP
} ) ) ) ;
append . push ( ... tx . update _info . map ( item => Object . assign ( { } , tx , item , { type : UPDATE } ) ) ) ;
append . push ( ... tx . abandon _info . map ( item => Object . assign ( { } , tx , item , { type : ABANDON } ) ) ) ;
if ( ! append . length ) {
append . push ( Object . assign ( { } , tx , {
type : tx . value < 0 ? SPEND : RECEIVE
} ) ) ;
}
items . push ( ... append . map ( item => {
// value on transaction, amount on outpoint
// amount is always positive, but should match sign of value
const balanceDelta = parseFloat ( item . balance _delta ) ;
const value = parseFloat ( item . value ) ;
const amount = balanceDelta || value ;
const fee = parseFloat ( tx . fee ) ;
return {
txid ,
timestamp : tx . timestamp ,
date : tx . timestamp ? new Date ( Number ( tx . timestamp ) * 1000 ) : null ,
amount ,
fee ,
claim _id : item . claim _id ,
claim _name : item . claim _name ,
type : item . type || SPEND ,
nout : item . nout ,
confirmations : tx . confirmations
} ;
} ) ) ;
} ) ;
return items . sort ( ( tx1 , tx2 ) => {
if ( ! tx1 . timestamp && ! tx2 . timestamp ) {
return 0 ;
} else if ( ! tx1 . timestamp && tx2 . timestamp ) {
return - 1 ;
} else if ( tx1 . timestamp && ! tx2 . timestamp ) {
return 1 ;
}
return tx2 . timestamp - tx1 . timestamp ;
} ) ;
} ) ;
const selectRecentTransactions = reselect . createSelector ( selectTransactionItems , transactions => {
const threshold = new Date ( ) ;
threshold . setDate ( threshold . getDate ( ) - 7 ) ;
return transactions . filter ( transaction => {
if ( ! transaction . date ) {
return true ; // pending transaction
}
return transaction . date > threshold ;
} ) ;
} ) ;
const selectHasTransactions = reselect . createSelector ( selectTransactionItems , transactions => transactions && transactions . length > 0 ) ;
const selectIsFetchingTransactions = reselect . createSelector ( selectState$1 , state => state . fetchingTransactions ) ;
const selectIsSendingSupport = reselect . createSelector ( selectState$1 , state => state . sendingSupport ) ;
const selectReceiveAddress = reselect . createSelector ( selectState$1 , state => state . receiveAddress ) ;
const selectGettingNewAddress = reselect . createSelector ( selectState$1 , state => state . gettingNewAddress ) ;
const selectDraftTransaction = reselect . createSelector ( selectState$1 , state => state . draftTransaction || { } ) ;
const selectDraftTransactionAmount = reselect . createSelector ( selectDraftTransaction , draft => draft . amount ) ;
const selectDraftTransactionAddress = reselect . createSelector ( selectDraftTransaction , draft => draft . address ) ;
const selectDraftTransactionError = reselect . createSelector ( selectDraftTransaction , draft => draft . error ) ;
const selectBlocks = reselect . createSelector ( selectState$1 , state => state . blocks ) ;
const selectCurrentHeight = reselect . createSelector ( selectState$1 , state => state . latestBlock ) ;
const selectTransactionListFilter = reselect . createSelector ( selectState$1 , state => state . transactionListFilter || '' ) ;
2019-09-23 04:25:12 +02:00
const selectFilteredTransactions = reselect . createSelector ( selectTransactionItems , selectTransactionListFilter , ( transactions , filter ) => {
return transactions . filter ( transaction => {
return filter === ALL || filter === transaction . type ;
} ) ;
} ) ;
const makeSelectFilteredTransactionsForPage = ( page = 1 ) => reselect . createSelector ( selectFilteredTransactions , filteredTransactions => {
2019-09-25 18:30:26 +02:00
const start = ( Number ( page ) - 1 ) * Number ( PAGE _SIZE$1 ) ;
const end = Number ( page ) * Number ( PAGE _SIZE$1 ) ;
2019-09-23 04:25:12 +02:00
return filteredTransactions && filteredTransactions . length ? filteredTransactions . slice ( start , end ) : [ ] ;
} ) ;
const selectFilteredTransactionCount = reselect . createSelector ( selectFilteredTransactions , filteredTransactions => filteredTransactions . length ) ;
2019-04-23 19:22:14 +02:00
var _extends$2 = Object . assign || function ( target ) { for ( var i = 1 ; i < arguments . length ; i ++ ) { var source = arguments [ i ] ; for ( var key in source ) { if ( Object . prototype . hasOwnProperty . call ( source , key ) ) { target [ key ] = source [ key ] ; } } } return target ; } ;
2019-08-20 22:00:26 +02:00
function _objectWithoutProperties$1 ( obj , keys ) { var target = { } ; for ( var i in obj ) { if ( keys . indexOf ( i ) >= 0 ) continue ; if ( ! Object . prototype . hasOwnProperty . call ( obj , i ) ) continue ; target [ i ] = obj [ i ] ; } return target ; }
2019-07-30 17:48:45 +02:00
2019-07-02 22:33:57 +02:00
const matureTagMap = MATURE _TAGS . reduce ( ( acc , tag ) => _extends$2 ( { } , acc , { [ tag ] : true } ) , { } ) ;
2019-04-23 19:22:14 +02:00
const isClaimNsfw = claim => {
if ( ! claim ) {
throw new Error ( 'No claim passed to isClaimNsfw()' ) ;
}
if ( ! claim . value ) {
return false ;
}
const tags = claim . value . tags || [ ] ;
for ( let i = 0 ; i < tags . length ; i += 1 ) {
2019-04-23 21:02:32 +02:00
const tag = tags [ i ] . toLowerCase ( ) ;
2019-07-02 22:33:57 +02:00
if ( matureTagMap [ tag ] ) {
2019-04-23 19:22:14 +02:00
return true ;
}
}
return false ;
} ;
2019-07-30 17:48:45 +02:00
function createNormalizedClaimSearchKey ( options ) {
// Ignore page because we don't care what the last page searched was, we want everything
// Ignore release_time because that will change depending on when you call claim_search ex: release_time: ">12344567"
2019-08-20 22:00:26 +02:00
const rest = _objectWithoutProperties$1 ( options , [ 'page' , 'release_time' ] ) ;
2019-07-30 17:48:45 +02:00
const query = JSON . stringify ( rest ) ;
return query ;
}
2019-07-26 08:27:09 +02:00
2019-09-24 21:57:51 +02:00
function concatClaims ( claimList = [ ] , concatClaimList = [ ] ) {
if ( ! claimList || claimList . length === 0 ) {
if ( ! concatClaimList ) {
return [ ] ;
}
return concatClaimList . slice ( ) ;
}
const claims = claimList . slice ( ) ;
concatClaimList . forEach ( claim => {
if ( ! claims . some ( item => item . claim _id === claim . claim _id ) ) {
claims . push ( claim ) ;
}
} ) ;
return claims ;
}
2019-04-23 19:22:14 +02:00
//
2019-08-15 08:13:50 +02:00
const selectState$2 = state => state . claims || { } ;
2019-04-03 19:12:51 +02:00
2019-08-15 08:13:50 +02:00
const selectClaimsById = reselect . createSelector ( selectState$2 , state => state . byId || { } ) ;
2019-04-03 19:12:51 +02:00
2019-08-15 08:13:50 +02:00
const selectCurrentChannelPage = reselect . createSelector ( selectState$2 , state => state . currentChannelPage || 1 ) ;
2019-04-03 19:12:51 +02:00
2019-08-27 06:42:52 +02:00
const selectCreatingChannel = reselect . createSelector ( selectState$2 , state => state . creatingChannel ) ;
2019-09-13 21:52:52 +02:00
const selectCreateChannelError = reselect . createSelector ( selectState$2 , state => state . createChannelError ) ;
2019-09-10 20:14:40 +02:00
2019-08-15 08:13:50 +02:00
const selectClaimsByUri = reselect . createSelector ( selectState$2 , selectClaimsById , ( state , byId ) => {
2019-04-03 19:12:51 +02:00
const byUri = state . claimsByUri || { } ;
const claims = { } ;
Object . keys ( byUri ) . forEach ( uri => {
const claimId = byUri [ uri ] ;
// NOTE returning a null claim allows us to differentiate between an
// undefined (never fetched claim) and one which just doesn't exist. Not
// the cleanest solution but couldn't think of anything better right now
if ( claimId === null ) {
claims [ uri ] = null ;
} else {
claims [ uri ] = byId [ claimId ] ;
}
} ) ;
return claims ;
} ) ;
2019-08-15 08:13:50 +02:00
const selectAllClaimsByChannel = reselect . createSelector ( selectState$2 , state => state . claimsByChannel || { } ) ;
2019-04-03 19:12:51 +02:00
2019-08-15 08:13:50 +02:00
const selectPendingById = reselect . createSelector ( selectState$2 , state => state . pendingById || { } ) ;
2019-04-03 19:12:51 +02:00
2019-08-15 08:13:50 +02:00
const selectPendingClaims = reselect . createSelector ( selectState$2 , state => Object . values ( state . pendingById || [ ] ) ) ;
2019-04-03 19:12:51 +02:00
const makeSelectClaimIsPending = uri => reselect . createSelector ( selectPendingById , pendingById => {
2019-07-11 21:00:45 +02:00
let claimId ;
2019-08-20 22:00:26 +02:00
2019-07-11 21:00:45 +02:00
try {
2019-08-20 22:00:26 +02:00
const { isChannel , channelClaimId , streamClaimId } = parseURI ( uri ) ;
claimId = isChannel ? channelClaimId : streamClaimId ;
2019-07-11 21:00:45 +02:00
} catch ( e ) { }
if ( claimId ) {
return Boolean ( pendingById [ claimId ] ) ;
}
2019-04-03 19:12:51 +02:00
} ) ;
const makeSelectPendingByUri = uri => reselect . createSelector ( selectPendingById , pendingById => {
2019-08-20 22:00:26 +02:00
const { isChannel , channelClaimId , streamClaimId } = parseURI ( uri ) ;
const claimId = isChannel ? channelClaimId : streamClaimId ;
2019-04-03 19:12:51 +02:00
return pendingById [ claimId ] ;
} ) ;
const makeSelectClaimForUri = uri => reselect . createSelector ( selectClaimsByUri , selectPendingById , ( byUri , pendingById ) => {
// Check if a claim is pending first
// It won't be in claimsByUri because resolving it will return nothing
2019-07-17 22:50:58 +02:00
let valid ;
2019-08-20 22:00:26 +02:00
let channelClaimId ;
let streamClaimId ;
let isChannel ;
2019-07-11 21:00:45 +02:00
try {
2019-08-20 22:00:26 +02:00
( { isChannel , channelClaimId , streamClaimId } = parseURI ( uri ) ) ;
2019-07-17 22:50:58 +02:00
valid = true ;
2019-07-11 21:00:45 +02:00
} catch ( e ) { }
2019-07-17 22:50:58 +02:00
if ( valid ) {
2019-08-20 22:00:26 +02:00
const claimId = isChannel ? channelClaimId : streamClaimId ;
2019-07-11 21:00:45 +02:00
const pendingClaim = pendingById [ claimId ] ;
if ( pendingClaim ) {
return pendingClaim ;
}
return byUri && byUri [ normalizeURI ( uri ) ] ;
}
2019-04-03 19:12:51 +02:00
} ) ;
2019-08-15 08:13:50 +02:00
const selectMyClaimsRaw = reselect . createSelector ( selectState$2 , state => state . myClaims ) ;
2019-04-03 19:12:51 +02:00
2019-08-15 08:13:50 +02:00
const selectAbandoningIds = reselect . createSelector ( selectState$2 , state => Object . keys ( state . abandoningById || { } ) ) ;
2019-04-03 19:12:51 +02:00
const selectMyActiveClaims = reselect . createSelector ( selectMyClaimsRaw , selectAbandoningIds , ( claims , abandoningIds ) => new Set ( claims && claims . map ( claim => claim . claim _id ) . filter ( claimId => Object . keys ( abandoningIds ) . indexOf ( claimId ) === - 1 ) ) ) ;
const makeSelectClaimIsMine = rawUri => {
2019-07-11 21:00:45 +02:00
let uri ;
try {
uri = normalizeURI ( rawUri ) ;
} catch ( e ) { }
return reselect . createSelector ( selectClaimsByUri , selectMyActiveClaims , ( claims , myClaims ) => {
try {
parseURI ( uri ) ;
} catch ( e ) {
return false ;
}
2019-07-11 22:33:22 +02:00
return claims && claims [ uri ] && claims [ uri ] . claim _id && myClaims . has ( claims [ uri ] . claim _id ) ;
2019-07-11 21:00:45 +02:00
} ) ;
2019-04-03 19:12:51 +02:00
} ;
2019-08-15 08:13:50 +02:00
const selectAllFetchingChannelClaims = reselect . createSelector ( selectState$2 , state => state . fetchingChannelClaims || { } ) ;
2019-04-03 19:12:51 +02:00
const makeSelectFetchingChannelClaims = uri => reselect . createSelector ( selectAllFetchingChannelClaims , fetching => fetching && fetching [ uri ] ) ;
const makeSelectClaimsInChannelForPage = ( uri , page ) => reselect . createSelector ( selectClaimsById , selectAllClaimsByChannel , ( byId , allClaims ) => {
const byChannel = allClaims [ uri ] || { } ;
const claimIds = byChannel [ page || 1 ] ;
if ( ! claimIds ) return claimIds ;
return claimIds . map ( claimId => byId [ claimId ] ) ;
} ) ;
const makeSelectClaimsInChannelForCurrentPageState = uri => reselect . createSelector ( selectClaimsById , selectAllClaimsByChannel , selectCurrentChannelPage , ( byId , allClaims , page ) => {
const byChannel = allClaims [ uri ] || { } ;
const claimIds = byChannel [ page || 1 ] ;
if ( ! claimIds ) return claimIds ;
return claimIds . map ( claimId => byId [ claimId ] ) ;
} ) ;
const makeSelectMetadataForUri = uri => reselect . createSelector ( makeSelectClaimForUri ( uri ) , claim => {
2019-04-23 19:22:14 +02:00
const metadata = claim && claim . value ;
2019-04-03 19:12:51 +02:00
return metadata || ( claim === undefined ? undefined : null ) ;
} ) ;
2019-05-06 19:57:07 +02:00
const makeSelectMetadataItemForUri = ( uri , key ) => reselect . createSelector ( makeSelectMetadataForUri ( uri ) , metadata => {
return metadata ? metadata [ key ] : undefined ;
} ) ;
2019-04-03 19:12:51 +02:00
const makeSelectTitleForUri = uri => reselect . createSelector ( makeSelectMetadataForUri ( uri ) , metadata => metadata && metadata . title ) ;
2019-05-06 04:00:45 +02:00
const makeSelectDateForUri = uri => reselect . createSelector ( makeSelectClaimForUri ( uri ) , claim => {
2019-08-13 17:27:32 +02:00
const timestamp = claim && claim . value && ( claim . value . release _time ? claim . value . release _time * 1000 : claim . meta && claim . meta . creation _timestamp ? claim . meta . creation _timestamp * 1000 : null ) ;
2019-05-06 04:00:45 +02:00
if ( ! timestamp ) {
return undefined ;
}
const dateObj = new Date ( timestamp ) ;
return dateObj ;
} ) ;
2019-07-01 03:16:44 +02:00
const makeSelectAmountForUri = uri => reselect . createSelector ( makeSelectClaimForUri ( uri ) , claim => {
return claim && claim . amount ;
} ) ;
2019-04-03 19:12:51 +02:00
const makeSelectContentTypeForUri = uri => reselect . createSelector ( makeSelectClaimForUri ( uri ) , claim => {
2019-04-23 19:22:14 +02:00
const source = claim && claim . value && claim . value . source ;
return source ? source . media _type : undefined ;
} ) ;
const makeSelectThumbnailForUri = uri => reselect . createSelector ( makeSelectClaimForUri ( uri ) , claim => {
const thumbnail = claim && claim . value && claim . value . thumbnail ;
2019-10-02 01:00:59 +02:00
return thumbnail && thumbnail . url ? thumbnail . url . trim ( ) : undefined ;
2019-04-03 19:12:51 +02:00
} ) ;
2019-05-01 16:21:51 +02:00
const makeSelectCoverForUri = uri => reselect . createSelector ( makeSelectClaimForUri ( uri ) , claim => {
const cover = claim && claim . value && claim . value . cover ;
2019-10-02 01:00:59 +02:00
return cover && cover . url ? cover . url . trim ( ) : undefined ;
2019-05-01 16:21:51 +02:00
} ) ;
2019-08-15 08:13:50 +02:00
const selectIsFetchingClaimListMine = reselect . createSelector ( selectState$2 , state => state . isFetchingClaimListMine ) ;
2019-04-03 19:12:51 +02:00
const selectMyClaims = reselect . createSelector ( selectMyActiveClaims , selectClaimsById , selectAbandoningIds , selectPendingClaims , ( myClaimIds , byId , abandoningIds , pendingClaims ) => {
const claims = [ ] ;
myClaimIds . forEach ( id => {
const claim = byId [ id ] ;
if ( claim && abandoningIds . indexOf ( id ) === - 1 ) claims . push ( claim ) ;
} ) ;
return [ ... claims , ... pendingClaims ] ;
} ) ;
2019-06-27 00:01:49 +02:00
const selectMyClaimsWithoutChannels = reselect . createSelector ( selectMyClaims , myClaims => myClaims . filter ( claim => ! claim . name . match ( /^@/ ) ) . sort ( ( a , b ) => a . timestamp - b . timestamp ) ) ;
2019-04-03 19:12:51 +02:00
2019-07-09 07:58:31 +02:00
const selectMyClaimUrisWithoutChannels = reselect . createSelector ( selectMyClaimsWithoutChannels , myClaims => myClaims . sort ( ( a , b ) => {
if ( ! a . timestamp ) {
return - 1 ;
} else if ( ! b . timestamp ) {
return 1 ;
} else {
return b . timestamp - a . timestamp ;
}
} ) . map ( claim => ` lbry:// ${ claim . name } # ${ claim . claim _id } ` ) ) ;
2019-06-11 20:36:01 +02:00
2019-04-03 19:12:51 +02:00
const selectAllMyClaimsByOutpoint = reselect . createSelector ( selectMyClaimsRaw , claims => new Set ( claims && claims . length ? claims . map ( claim => ` ${ claim . txid } : ${ claim . nout } ` ) : null ) ) ;
const selectMyClaimsOutpoints = reselect . createSelector ( selectMyClaims , myClaims => {
const outpoints = [ ] ;
myClaims . forEach ( claim => outpoints . push ( ` ${ claim . txid } : ${ claim . nout } ` ) ) ;
return outpoints ;
} ) ;
2019-08-15 08:13:50 +02:00
const selectFetchingMyChannels = reselect . createSelector ( selectState$2 , state => state . fetchingMyChannels ) ;
2019-04-03 19:12:51 +02:00
2019-08-15 08:13:50 +02:00
const selectMyChannelClaims = reselect . createSelector ( selectState$2 , selectClaimsById , ( state , byId ) => {
2019-09-13 21:52:52 +02:00
const ids = state . myChannelClaims ;
if ( ! ids ) {
return ids ;
}
2019-04-03 19:12:51 +02:00
2019-09-13 21:52:52 +02:00
const claims = [ ] ;
2019-04-03 19:12:51 +02:00
ids . forEach ( id => {
if ( byId [ id ] ) {
// I'm not sure why this check is necessary, but it ought to be a quick fix for https://github.com/lbryio/lbry-desktop/issues/544
claims . push ( byId [ id ] ) ;
}
} ) ;
return claims ;
} ) ;
2019-08-15 08:13:50 +02:00
const selectResolvingUris = reselect . createSelector ( selectState$2 , state => state . resolvingUris || [ ] ) ;
2019-04-03 19:12:51 +02:00
2019-09-12 21:06:49 +02:00
const selectChannelImportPending = reselect . createSelector ( selectState$2 , state => state . pendingChannelImport ) ;
2019-04-03 19:12:51 +02:00
const makeSelectIsUriResolving = uri => reselect . createSelector ( selectResolvingUris , resolvingUris => resolvingUris && resolvingUris . indexOf ( uri ) !== - 1 ) ;
2019-08-15 08:13:50 +02:00
const selectPlayingUri = reselect . createSelector ( selectState$2 , state => state . playingUri ) ;
2019-04-03 19:12:51 +02:00
2019-08-15 08:13:50 +02:00
const selectChannelClaimCounts = reselect . createSelector ( selectState$2 , state => state . channelClaimCounts || { } ) ;
2019-04-03 19:12:51 +02:00
const makeSelectTotalItemsForChannel = uri => reselect . createSelector ( selectChannelClaimCounts , byUri => byUri && byUri [ uri ] ) ;
const makeSelectTotalPagesForChannel = ( uri , pageSize = 10 ) => reselect . createSelector ( selectChannelClaimCounts , byUri => byUri && byUri [ uri ] && Math . ceil ( byUri [ uri ] / pageSize ) ) ;
const makeSelectNsfwCountFromUris = uris => reselect . createSelector ( selectClaimsByUri , claims => uris . reduce ( ( acc , uri ) => {
const claim = claims [ uri ] ;
2019-04-23 19:22:14 +02:00
if ( claim && isClaimNsfw ( claim ) ) {
2019-04-03 19:12:51 +02:00
return acc + 1 ;
}
return acc ;
} , 0 ) ) ;
const makeSelectNsfwCountForChannel = uri => reselect . createSelector ( selectClaimsById , selectAllClaimsByChannel , selectCurrentChannelPage , ( byId , allClaims , page ) => {
const byChannel = allClaims [ uri ] || { } ;
const claimIds = byChannel [ page || 1 ] ;
if ( ! claimIds ) return 0 ;
return claimIds . reduce ( ( acc , claimId ) => {
const claim = byId [ claimId ] ;
if ( isClaimNsfw ( claim ) ) {
return acc + 1 ;
}
return acc ;
} , 0 ) ;
} ) ;
2019-04-23 21:02:32 +02:00
const makeSelectClaimIsNsfw = uri => reselect . createSelector ( makeSelectClaimForUri ( uri ) ,
// Eventually these will come from some list of tags that are considered adult
// Or possibly come from users settings of what tags they want to hide
// For now, there is just a hard coded list of tags inside `isClaimNsfw`
// selectNaughtyTags(),
claim => {
if ( ! claim ) {
return false ;
}
return isClaimNsfw ( claim ) ;
} ) ;
2019-04-03 19:12:51 +02:00
const makeSelectRecommendedContentForUri = uri => reselect . createSelector ( makeSelectClaimForUri ( uri ) , selectSearchUrisByQuery , ( claim , searchUrisByQuery ) => {
const atVanityURI = ! uri . includes ( '#' ) ;
let recommendedContent ;
if ( claim ) {
2019-08-30 18:28:36 +02:00
// always grab full URL - this can change once search returns canonical
const currentUri = buildURI ( { streamClaimId : claim . claim _id , streamName : claim . name } ) ;
2019-04-03 19:12:51 +02:00
2019-04-23 19:22:14 +02:00
const { title } = claim . value ;
2019-04-03 19:12:51 +02:00
2019-08-05 23:27:14 +02:00
const searchQuery = getSearchQueryString ( title ? title . replace ( /\// , ' ' ) : '' ) ;
2019-04-03 19:12:51 +02:00
let searchUris = searchUrisByQuery [ searchQuery ] ;
if ( searchUris ) {
searchUris = searchUris . filter ( searchUri => searchUri !== currentUri ) ;
recommendedContent = searchUris ;
}
}
return recommendedContent ;
} ) ;
const makeSelectFirstRecommendedFileForUri = uri => reselect . createSelector ( makeSelectRecommendedContentForUri ( uri ) , recommendedContent => recommendedContent ? recommendedContent [ 0 ] : null ) ;
// Returns the associated channel uri for a given claim uri
2019-04-23 19:22:14 +02:00
// accepts a regular claim uri lbry://something
// returns the channel uri that created this claim lbry://@channel
2019-04-03 19:12:51 +02:00
const makeSelectChannelForClaimUri = ( uri , includePrefix = false ) => reselect . createSelector ( makeSelectClaimForUri ( uri ) , claim => {
2019-09-04 18:56:24 +02:00
if ( ! claim || ! claim . signing _channel || ! claim . signing _channel . canonical _url ) {
2019-04-03 19:12:51 +02:00
return null ;
}
2019-09-04 17:57:48 +02:00
const { canonical _url : canonicalUrl } = claim . signing _channel ;
return includePrefix ? canonicalUrl : canonicalUrl . slice ( 'lbry://' . length ) ;
2019-04-03 19:12:51 +02:00
} ) ;
2019-06-10 04:45:47 +02:00
const makeSelectTagsForUri = uri => reselect . createSelector ( makeSelectMetadataForUri ( uri ) , metadata => {
return metadata && metadata . tags || [ ] ;
} ) ;
2019-08-15 08:13:50 +02:00
const selectFetchingClaimSearchByQuery = reselect . createSelector ( selectState$2 , state => state . fetchingClaimSearchByQuery || { } ) ;
2019-06-11 20:11:18 +02:00
2019-07-31 21:14:51 +02:00
const selectFetchingClaimSearch = reselect . createSelector ( selectFetchingClaimSearchByQuery , fetchingClaimSearchByQuery => Boolean ( Object . keys ( fetchingClaimSearchByQuery ) . length ) ) ;
2019-06-11 20:11:18 +02:00
2019-08-15 08:13:50 +02:00
const selectClaimSearchByQuery = reselect . createSelector ( selectState$2 , state => state . claimSearchByQuery || { } ) ;
2019-07-08 20:28:14 +02:00
2019-08-16 16:54:38 +02:00
const selectClaimSearchByQueryLastPageReached = reselect . createSelector ( selectState$2 , state => state . claimSearchByQueryLastPageReached || { } ) ;
2019-08-13 17:27:32 +02:00
2019-07-30 17:48:45 +02:00
const makeSelectShortUrlForUri = uri => reselect . createSelector ( makeSelectClaimForUri ( uri ) , claim => claim && claim . short _url ) ;
2019-07-15 04:44:02 +02:00
2019-08-20 22:00:26 +02:00
const makeSelectCanonicalUrlForUri = uri => reselect . createSelector ( makeSelectClaimForUri ( uri ) , claim => claim && claim . canonical _url ) ;
2019-09-04 17:57:48 +02:00
const makeSelectPermanentUrlForUri = uri => reselect . createSelector ( makeSelectClaimForUri ( uri ) , claim => claim && claim . permanent _url ) ;
2019-08-15 08:13:50 +02:00
const makeSelectSupportsForUri = uri => reselect . createSelector ( selectSupportsByOutpoint , makeSelectClaimForUri ( uri ) , ( byOutpoint , claim ) => {
if ( ! claim || ! claim . is _mine ) {
return null ;
}
2019-04-03 19:12:51 +02:00
2019-08-15 08:13:50 +02:00
const { claim _id : claimId } = claim ;
2019-08-20 22:00:26 +02:00
let total = 0 ;
2019-04-03 19:12:51 +02:00
2019-08-15 08:13:50 +02:00
Object . values ( byOutpoint ) . forEach ( support => {
2019-08-20 22:00:26 +02:00
// $FlowFixMe
2019-08-15 08:13:50 +02:00
const { claim _id , amount } = support ;
total = claim _id === claimId && amount ? total + parseFloat ( amount ) : total ;
2019-04-03 19:12:51 +02:00
} ) ;
2019-08-15 08:13:50 +02:00
return total ;
2019-04-03 19:12:51 +02:00
} ) ;
2019-09-15 13:00:14 +02:00
const selectUpdatingChannel = reselect . createSelector ( selectState$2 , state => state . updatingChannel ) ;
const selectUpdateChannelError = reselect . createSelector ( selectState$2 , state => state . updateChannelError ) ;
2019-09-25 23:37:21 +02:00
const makeSelectMyStreamUrlsForPage = ( page = 1 ) => reselect . createSelector ( selectMyClaimUrisWithoutChannels , urls => {
2019-09-25 23:16:27 +02:00
const start = ( Number ( page ) - 1 ) * Number ( PAGE _SIZE ) ;
const end = Number ( page ) * Number ( PAGE _SIZE ) ;
2019-09-25 23:37:21 +02:00
return urls && urls . length ? urls . slice ( start , end ) : [ ] ;
2019-09-23 19:00:12 +02:00
} ) ;
2019-09-25 23:37:21 +02:00
const selectMyStreamUrlsCount = reselect . createSelector ( selectMyClaimUrisWithoutChannels , channels => channels . length ) ;
2019-09-23 19:00:12 +02:00
2019-08-16 16:54:38 +02:00
function formatCredits ( amount , precision , shortFormat = false ) {
let actualAmount = parseFloat ( amount ) ,
suffix = '' ;
if ( Number . isNaN ( actualAmount ) ) return '0' ;
if ( shortFormat ) {
if ( actualAmount >= 1000000 ) {
actualAmount = actualAmount / 1000000 ;
suffix = 'M' ;
} else if ( actualAmount >= 1000 ) {
actualAmount = actualAmount / 1000 ;
suffix = 'K' ;
}
}
return actualAmount . toFixed ( precision || 1 ) . replace ( /\.?0+$/ , '' ) + suffix ;
2019-07-29 20:48:44 +02:00
}
function formatFullPrice ( amount , precision = 1 ) {
let formated = '' ;
const quantity = amount . toString ( ) . split ( '.' ) ;
const fraction = quantity [ 1 ] ;
if ( fraction ) {
const decimals = fraction . split ( '' ) ;
const first = decimals . filter ( number => number !== '0' ) [ 0 ] ;
const index = decimals . indexOf ( first ) ;
// Set format fraction
formated = ` . ${ fraction . substring ( 0 , index + precision ) } ` ;
}
return parseFloat ( quantity [ 0 ] + formated ) ;
}
function creditsToString ( amount ) {
const creditString = parseFloat ( amount ) . toFixed ( 8 ) ;
return creditString ;
}
2019-04-03 19:12:51 +02:00
function doUpdateBalance ( ) {
return ( dispatch , getState ) => {
const {
2019-09-25 07:37:02 +02:00
wallet : { totalBalance : totalInStore }
2019-04-03 19:12:51 +02:00
} = getState ( ) ;
2019-09-24 00:56:53 +02:00
lbryProxy . account _balance ( { reserved _subtotals : true } ) . then ( response => {
const { available , reserved , reserved _subtotals , total } = response ;
const { claims , supports , tips } = reserved _subtotals ;
const totalFloat = parseFloat ( total ) ;
if ( totalInStore !== totalFloat ) {
2019-04-03 19:12:51 +02:00
dispatch ( {
type : UPDATE _BALANCE ,
data : {
2019-09-24 00:56:53 +02:00
totalBalance : totalFloat ,
balance : parseFloat ( available ) ,
reservedBalance : parseFloat ( reserved ) ,
claimsBalance : parseFloat ( claims ) ,
supportsBalance : parseFloat ( supports ) ,
tipsBalance : parseFloat ( tips )
2019-04-18 09:56:16 +02:00
}
} ) ;
}
} ) ;
} ;
}
2019-04-03 19:12:51 +02:00
function doBalanceSubscribe ( ) {
return dispatch => {
dispatch ( doUpdateBalance ( ) ) ;
setInterval ( ( ) => dispatch ( doUpdateBalance ( ) ) , 5000 ) ;
} ;
}
function doFetchTransactions ( ) {
return dispatch => {
2019-05-10 07:02:03 +02:00
dispatch ( doFetchSupports ( ) ) ;
2019-04-03 19:12:51 +02:00
dispatch ( {
type : FETCH _TRANSACTIONS _STARTED
} ) ;
lbryProxy . utxo _release ( ) . then ( ( ) => lbryProxy . transaction _list ( ) ) . then ( results => {
dispatch ( {
type : FETCH _TRANSACTIONS _COMPLETED ,
data : {
transactions : results
}
} ) ;
} ) ;
} ;
}
2019-05-10 07:02:03 +02:00
function doFetchSupports ( ) {
return dispatch => {
dispatch ( {
type : FETCH _SUPPORTS _STARTED
} ) ;
lbryProxy . support _list ( ) . then ( results => {
dispatch ( {
type : FETCH _SUPPORTS _COMPLETED ,
data : {
supports : results
}
} ) ;
} ) ;
} ;
}
2019-04-03 19:12:51 +02:00
function doGetNewAddress ( ) {
return dispatch => {
dispatch ( {
type : GET _NEW _ADDRESS _STARTED
} ) ;
lbryProxy . address _unused ( ) . then ( address => {
dispatch ( {
type : GET _NEW _ADDRESS _COMPLETED ,
data : { address }
} ) ;
} ) ;
} ;
}
function doCheckAddressIsMine ( address ) {
return dispatch => {
dispatch ( {
type : CHECK _ADDRESS _IS _MINE _STARTED
} ) ;
lbryProxy . address _is _mine ( { address } ) . then ( isMine => {
if ( ! isMine ) dispatch ( doGetNewAddress ( ) ) ;
dispatch ( {
type : CHECK _ADDRESS _IS _MINE _COMPLETED
} ) ;
} ) ;
} ;
}
function doSendDraftTransaction ( address , amount ) {
return ( dispatch , getState ) => {
const state = getState ( ) ;
const balance = selectBalance ( state ) ;
if ( balance - amount <= 0 ) {
dispatch ( doToast ( {
title : 'Insufficient credits' ,
message : 'Insufficient credits'
} ) ) ;
return ;
}
dispatch ( {
type : SEND _TRANSACTION _STARTED
} ) ;
const successCallback = response => {
if ( response . txid ) {
dispatch ( {
type : SEND _TRANSACTION _COMPLETED
} ) ;
dispatch ( doToast ( {
message : ` You sent ${ amount } LBC ` ,
linkText : 'History' ,
linkTarget : '/wallet'
} ) ) ;
} else {
dispatch ( {
type : SEND _TRANSACTION _FAILED ,
data : { error : response }
} ) ;
dispatch ( doToast ( {
message : 'Transaction failed' ,
isError : true
} ) ) ;
}
} ;
const errorCallback = error => {
dispatch ( {
type : SEND _TRANSACTION _FAILED ,
data : { error : error . message }
} ) ;
dispatch ( doToast ( {
message : 'Transaction failed' ,
isError : true
} ) ) ;
} ;
2019-04-23 19:22:14 +02:00
lbryProxy . account _send ( {
addresses : [ address ] ,
2019-07-29 20:48:44 +02:00
amount : creditsToString ( amount )
2019-04-03 19:12:51 +02:00
} ) . then ( successCallback , errorCallback ) ;
} ;
}
function doSetDraftTransactionAmount ( amount ) {
return {
type : SET _DRAFT _TRANSACTION _AMOUNT ,
data : { amount }
} ;
}
function doSetDraftTransactionAddress ( address ) {
return {
type : SET _DRAFT _TRANSACTION _ADDRESS ,
data : { address }
} ;
}
2019-08-14 05:52:17 +02:00
function doSendTip ( amount , claimId , isSupport , successCallback , errorCallback ) {
2019-04-03 19:12:51 +02:00
return ( dispatch , getState ) => {
const state = getState ( ) ;
const balance = selectBalance ( state ) ;
2019-07-19 21:20:24 +02:00
const myClaims = selectMyClaimsRaw ( state ) ;
2019-08-23 10:10:07 +02:00
const shouldSupport = isSupport || ( myClaims ? myClaims . find ( claim => claim . claim _id === claimId ) : false ) ;
2019-04-03 19:12:51 +02:00
if ( balance - amount <= 0 ) {
dispatch ( doToast ( {
message : 'Insufficient credits' ,
isError : true
} ) ) ;
return ;
}
const success = ( ) => {
dispatch ( doToast ( {
2019-08-14 05:52:17 +02:00
message : shouldSupport ? _ _ ( ` You deposited ${ amount } LBC as a support! ` ) : _ _ ( ` You sent ${ amount } LBC as a tip, Mahalo! ` ) ,
2019-04-03 19:12:51 +02:00
linkText : _ _ ( 'History' ) ,
linkTarget : _ _ ( '/wallet' )
} ) ) ;
dispatch ( {
type : SUPPORT _TRANSACTION _COMPLETED
} ) ;
if ( successCallback ) {
successCallback ( ) ;
}
} ;
const error = err => {
dispatch ( doToast ( {
message : _ _ ( ` There was an error sending support funds. ` ) ,
isError : true
} ) ) ;
dispatch ( {
type : SUPPORT _TRANSACTION _FAILED ,
data : {
error : err
}
} ) ;
if ( errorCallback ) {
errorCallback ( ) ;
}
} ;
dispatch ( {
type : SUPPORT _TRANSACTION _STARTED
} ) ;
2019-04-23 19:22:14 +02:00
lbryProxy . support _create ( {
2019-04-03 19:12:51 +02:00
claim _id : claimId ,
2019-07-29 20:48:44 +02:00
amount : creditsToString ( amount ) ,
2019-10-02 01:00:59 +02:00
tip : ! shouldSupport ,
blocking : true
2019-04-03 19:12:51 +02:00
} ) . then ( success , error ) ;
} ;
}
function doWalletEncrypt ( newPassword ) {
return dispatch => {
dispatch ( {
type : WALLET _ENCRYPT _START
} ) ;
lbryProxy . account _encrypt ( { new _password : newPassword } ) . then ( result => {
if ( result === true ) {
dispatch ( {
type : WALLET _ENCRYPT _COMPLETED ,
result
} ) ;
} else {
dispatch ( {
type : WALLET _ENCRYPT _FAILED ,
result
} ) ;
}
} ) ;
} ;
}
function doWalletUnlock ( password ) {
return dispatch => {
dispatch ( {
type : WALLET _UNLOCK _START
} ) ;
lbryProxy . account _unlock ( { password } ) . then ( result => {
if ( result === true ) {
dispatch ( {
type : WALLET _UNLOCK _COMPLETED ,
result
} ) ;
} else {
dispatch ( {
type : WALLET _UNLOCK _FAILED ,
result
} ) ;
}
} ) ;
} ;
}
function doWalletDecrypt ( ) {
return dispatch => {
dispatch ( {
type : WALLET _DECRYPT _START
} ) ;
lbryProxy . account _decrypt ( ) . then ( result => {
if ( result === true ) {
dispatch ( {
type : WALLET _DECRYPT _COMPLETED ,
result
} ) ;
} else {
dispatch ( {
type : WALLET _DECRYPT _FAILED ,
result
} ) ;
}
} ) ;
} ;
}
function doWalletStatus ( ) {
return dispatch => {
dispatch ( {
type : WALLET _STATUS _START
} ) ;
lbryProxy . status ( ) . then ( status => {
if ( status && status . wallet ) {
dispatch ( {
type : WALLET _STATUS _COMPLETED ,
result : status . wallet . is _encrypted
} ) ;
}
} ) ;
} ;
}
function doSetTransactionListFilter ( filterOption ) {
return {
type : SET _TRANSACTION _LIST _FILTER ,
data : filterOption
} ;
}
function doUpdateBlockHeight ( ) {
return dispatch => lbryProxy . status ( ) . then ( status => {
if ( status . wallet ) {
dispatch ( {
type : UPDATE _CURRENT _HEIGHT ,
data : status . wallet . blocks
} ) ;
}
} ) ;
}
2019-07-29 20:48:44 +02:00
// https://github.com/reactjs/redux/issues/911
function batchActions ( ... actions ) {
return {
type : 'BATCH_ACTIONS' ,
actions
} ;
}
2019-04-23 19:22:14 +02:00
var _extends$3 = Object . assign || function ( target ) { for ( var i = 1 ; i < arguments . length ; i ++ ) { var source = arguments [ i ] ; for ( var key in source ) { if ( Object . prototype . hasOwnProperty . call ( source , key ) ) { target [ key ] = source [ key ] ; } } } return target ; } ;
2019-04-03 19:12:51 +02:00
function doResolveUris ( uris , returnCachedClaims = false ) {
return ( dispatch , getState ) => {
const normalizedUris = uris . map ( normalizeURI ) ;
const state = getState ( ) ;
const resolvingUris = selectResolvingUris ( state ) ;
const claimsByUri = selectClaimsByUri ( state ) ;
const urisToResolve = normalizedUris . filter ( uri => {
if ( resolvingUris . includes ( uri ) ) {
return false ;
}
return returnCachedClaims ? ! claimsByUri [ uri ] : true ;
} ) ;
if ( urisToResolve . length === 0 ) {
return ;
}
dispatch ( {
type : RESOLVE _URIS _STARTED ,
data : { uris : normalizedUris }
} ) ;
const resolveInfo = { } ;
2019-04-23 19:22:14 +02:00
2019-04-03 19:12:51 +02:00
lbryProxy . resolve ( { urls : urisToResolve } ) . then ( result => {
Object . entries ( result ) . forEach ( ( [ uri , uriResolveInfo ] ) => {
const fallbackResolveInfo = {
2019-06-06 23:37:36 +02:00
stream : null ,
2019-04-03 19:12:51 +02:00
claimsInChannel : null ,
2019-06-06 23:37:36 +02:00
channel : null
2019-04-03 19:12:51 +02:00
} ;
2019-04-23 19:22:14 +02:00
// Flow has terrible Object.entries support
// https://github.com/facebook/flow/issues/2221
2019-06-04 18:06:19 +02:00
if ( uriResolveInfo ) {
if ( uriResolveInfo . error ) {
resolveInfo [ uri ] = _extends$3 ( { } , fallbackResolveInfo ) ;
} else {
let result = { } ;
if ( uriResolveInfo . value _type === 'channel' ) {
2019-06-06 23:37:36 +02:00
result . channel = uriResolveInfo ;
2019-06-04 18:06:19 +02:00
// $FlowFixMe
result . claimsInChannel = uriResolveInfo . meta . claims _in _channel ;
} else {
2019-06-06 23:37:36 +02:00
result . stream = uriResolveInfo ;
if ( uriResolveInfo . signing _channel ) {
result . channel = uriResolveInfo . signing _channel ;
2019-06-11 18:22:44 +02:00
result . claimsInChannel = uriResolveInfo . signing _channel . meta && uriResolveInfo . signing _channel . meta . claims _in _channel || 0 ;
2019-06-06 23:37:36 +02:00
}
2019-06-04 18:06:19 +02:00
}
// $FlowFixMe
resolveInfo [ uri ] = result ;
}
2019-04-23 19:22:14 +02:00
}
2019-04-03 19:12:51 +02:00
} ) ;
dispatch ( {
type : RESOLVE _URIS _COMPLETED ,
data : { resolveInfo }
} ) ;
} ) ;
} ;
}
function doResolveUri ( uri ) {
return doResolveUris ( [ uri ] ) ;
}
function doFetchClaimListMine ( ) {
return dispatch => {
dispatch ( {
type : FETCH _CLAIM _LIST _MINE _STARTED
} ) ;
2019-04-23 19:22:14 +02:00
lbryProxy . claim _list ( ) . then ( claims => {
2019-04-03 19:12:51 +02:00
dispatch ( {
type : FETCH _CLAIM _LIST _MINE _COMPLETED ,
data : {
claims
}
} ) ;
} ) ;
} ;
}
function doAbandonClaim ( txid , nout ) {
2019-05-14 06:50:21 +02:00
const outpoint = ` ${ txid } : ${ nout } ` ;
2019-04-03 19:12:51 +02:00
return ( dispatch , getState ) => {
const state = getState ( ) ;
const myClaims = selectMyClaimsRaw ( state ) ;
2019-05-14 06:50:21 +02:00
const mySupports = selectSupportsByOutpoint ( state ) ;
2019-05-10 07:02:03 +02:00
// A user could be trying to abandon a support or one of their claims
2019-04-23 19:22:14 +02:00
const claimToAbandon = myClaims . find ( claim => claim . txid === txid && claim . nout === nout ) ;
2019-05-14 06:50:21 +02:00
const supportToAbandon = mySupports [ outpoint ] ;
2019-04-23 19:22:14 +02:00
2019-05-10 07:02:03 +02:00
if ( ! claimToAbandon && ! supportToAbandon ) {
console . error ( 'No associated support or claim with txid: ' , txid ) ;
2019-04-23 19:22:14 +02:00
return ;
}
2019-05-14 06:50:21 +02:00
const data = claimToAbandon ? { claimId : claimToAbandon . claim _id } : { outpoint : ` ${ supportToAbandon . txid } : ${ supportToAbandon . nout } ` } ;
2019-05-10 07:02:03 +02:00
const isClaim = ! ! claimToAbandon ;
const startedActionType = isClaim ? ABANDON _CLAIM _STARTED : ABANDON _SUPPORT _STARTED ;
const completedActionType = isClaim ? ABANDON _CLAIM _STARTED : ABANDON _SUPPORT _COMPLETED ;
2019-04-03 19:12:51 +02:00
dispatch ( {
2019-05-10 07:02:03 +02:00
type : startedActionType ,
data
2019-04-03 19:12:51 +02:00
} ) ;
const errorCallback = ( ) => {
dispatch ( doToast ( {
2019-07-19 21:20:24 +02:00
message : isClaim ? 'Error abandoning your claim/support' : 'Error unlocking your tip' ,
2019-04-03 19:12:51 +02:00
isError : true
} ) ) ;
} ;
2019-04-23 19:22:14 +02:00
const successCallback = ( ) => {
dispatch ( {
2019-05-10 07:02:03 +02:00
type : completedActionType ,
data
2019-04-23 19:22:14 +02:00
} ) ;
2019-04-03 19:12:51 +02:00
2019-07-19 21:20:24 +02:00
let abandonMessage ;
if ( isClaim ) {
abandonMessage = 'Successfully abandoned your claim.' ;
} else if ( supportToAbandon ) {
abandonMessage = 'Successfully abandoned your support.' ;
} else {
abandonMessage = 'Successfully unlocked your tip!' ;
}
2019-04-23 19:22:14 +02:00
dispatch ( doToast ( {
2019-07-19 21:20:24 +02:00
message : abandonMessage
2019-04-23 19:22:14 +02:00
} ) ) ;
// After abandoning, call claim_list to show the claim as abandoned
// Also fetch transactions to show the new abandon transaction
2019-07-19 21:20:24 +02:00
if ( isClaim ) dispatch ( doFetchClaimListMine ( ) ) ;
2019-04-23 19:22:14 +02:00
dispatch ( doFetchTransactions ( ) ) ;
2019-04-03 19:12:51 +02:00
} ;
2019-04-23 19:22:14 +02:00
const abandonParams = {
2019-04-03 19:12:51 +02:00
txid ,
2019-04-23 19:22:14 +02:00
nout ,
blocking : true
} ;
2019-05-10 07:02:03 +02:00
let method ;
if ( supportToAbandon ) {
method = 'support_abandon' ;
} else if ( claimToAbandon ) {
const { name : claimName } = claimToAbandon ;
method = claimName . startsWith ( '@' ) ? 'channel_abandon' : 'stream_abandon' ;
}
if ( ! method ) {
console . error ( 'No "method" chosen for claim or support abandon' ) ;
return ;
}
2019-04-23 19:22:14 +02:00
lbryProxy [ method ] ( abandonParams ) . then ( successCallback , errorCallback ) ;
2019-04-03 19:12:51 +02:00
} ;
}
2019-04-23 19:22:14 +02:00
function doFetchClaimsByChannel ( uri , page = 1 ) {
2019-04-03 19:12:51 +02:00
return dispatch => {
dispatch ( {
type : FETCH _CHANNEL _CLAIMS _STARTED ,
data : { uri , page }
} ) ;
2019-06-11 18:22:44 +02:00
lbryProxy . claim _search ( {
channel : uri ,
2019-06-25 08:37:31 +02:00
valid _channel _signature : true ,
2019-06-11 18:22:44 +02:00
page : page || 1 ,
order _by : [ 'release_time' ]
} ) . then ( result => {
2019-04-29 16:29:24 +02:00
const { items : claimsInChannel , page : returnedPage } = result ;
2019-04-03 19:12:51 +02:00
dispatch ( {
type : FETCH _CHANNEL _CLAIMS _COMPLETED ,
data : {
uri ,
claims : claimsInChannel || [ ] ,
page : returnedPage || undefined
}
} ) ;
} ) ;
} ;
}
2019-09-15 13:00:14 +02:00
function doCreateChannel ( name , amount , optionalParams ) {
2019-04-03 19:12:51 +02:00
return dispatch => {
dispatch ( {
2019-04-23 19:22:14 +02:00
type : CREATE _CHANNEL _STARTED
2019-04-03 19:12:51 +02:00
} ) ;
2019-09-15 13:00:14 +02:00
const createParams = {
2019-04-23 19:22:14 +02:00
name ,
2019-10-02 01:00:59 +02:00
bid : creditsToString ( amount ) ,
blocking : true
2019-09-15 13:00:14 +02:00
} ;
if ( optionalParams ) {
if ( optionalParams . title ) {
createParams . title = optionalParams . title ;
}
if ( optionalParams . coverUrl ) {
createParams . cover _url = optionalParams . coverUrl ;
}
if ( optionalParams . thumbnailUrl ) {
createParams . thumbnail _url = optionalParams . thumbnailUrl ;
}
if ( optionalParams . description ) {
createParams . description = optionalParams . description ;
}
if ( optionalParams . website ) {
createParams . website _url = optionalParams . website ;
}
if ( optionalParams . email ) {
createParams . email = optionalParams . email ;
}
if ( optionalParams . tags ) {
createParams . tags = optionalParams . tags . map ( tag => tag . name ) ;
}
}
return lbryProxy . channel _create ( createParams )
2019-04-23 19:22:14 +02:00
// outputs[0] is the certificate
// outputs[1] is the change from the tx, not in the app currently
. then ( result => {
const channelClaim = result . outputs [ 0 ] ;
2019-04-03 19:12:51 +02:00
dispatch ( {
2019-04-23 19:22:14 +02:00
type : CREATE _CHANNEL _COMPLETED ,
data : { channelClaim }
} ) ;
} ) . catch ( error => {
dispatch ( {
type : CREATE _CHANNEL _FAILED ,
2019-09-13 21:52:52 +02:00
data : error . message
2019-04-03 19:12:51 +02:00
} ) ;
} ) ;
} ;
}
2019-07-01 03:16:44 +02:00
function doUpdateChannel ( params ) {
2019-10-02 01:00:59 +02:00
return ( dispatch , getState ) => {
2019-07-01 03:16:44 +02:00
dispatch ( {
type : UPDATE _CHANNEL _STARTED
} ) ;
2019-10-02 01:00:59 +02:00
const state = getState ( ) ;
const myChannels = selectMyChannelClaims ( state ) ;
const channelClaim = myChannels . find ( myChannel => myChannel . claim _id === params . claim _id ) ;
2019-07-01 03:16:44 +02:00
const updateParams = {
claim _id : params . claim _id ,
2019-07-29 20:48:44 +02:00
bid : creditsToString ( params . amount ) ,
2019-07-01 03:16:44 +02:00
title : params . title ,
2019-09-15 13:00:14 +02:00
cover _url : params . coverUrl ,
thumbnail _url : params . thumbnailUrl ,
2019-07-01 03:16:44 +02:00
description : params . description ,
website _url : params . website ,
email : params . email ,
2019-10-02 01:00:59 +02:00
tags : [ ] ,
2019-07-18 16:27:35 +02:00
replace : true ,
2019-10-02 01:00:59 +02:00
languages : [ ] ,
locations : [ ] ,
blocking : true
2019-07-01 03:16:44 +02:00
} ;
2019-07-18 16:27:35 +02:00
if ( params . tags ) {
updateParams . tags = params . tags . map ( tag => tag . name ) ;
}
2019-10-02 01:00:59 +02:00
//we'll need to remove these once we add locations/channels to channel page edit/create options
if ( channelClaim && channelClaim . value && channelClaim . value . locations ) {
updateParams . locations = channelClaim . value . locations ;
}
if ( channelClaim && channelClaim . value && channelClaim . value . languages ) {
updateParams . languages = channelClaim . value . languages ;
}
2019-07-18 16:27:35 +02:00
2019-07-01 03:16:44 +02:00
return lbryProxy . channel _update ( updateParams ) . then ( result => {
const channelClaim = result . outputs [ 0 ] ;
dispatch ( {
type : UPDATE _CHANNEL _COMPLETED ,
data : { channelClaim }
} ) ;
} ) . catch ( error => {
dispatch ( {
type : UPDATE _CHANNEL _FAILED ,
data : error
} ) ;
} ) ;
} ;
}
2019-09-23 17:06:02 +02:00
function doImportChannel ( certificate ) {
2019-09-12 21:06:49 +02:00
return dispatch => {
dispatch ( {
2019-09-23 17:06:02 +02:00
type : IMPORT _CHANNEL _STARTED
2019-09-12 21:06:49 +02:00
} ) ;
return lbryProxy . channel _import ( { channel _data : certificate } ) . then ( result => {
dispatch ( {
2019-09-23 17:06:02 +02:00
type : IMPORT _CHANNEL _COMPLETED
2019-09-12 21:06:49 +02:00
} ) ;
} ) . catch ( error => {
dispatch ( {
type : IMPORT _CHANNEL _FAILED ,
data : error
} ) ;
} ) ;
} ;
}
2019-04-23 19:22:14 +02:00
function doFetchChannelListMine ( ) {
return dispatch => {
dispatch ( {
type : FETCH _CHANNEL _LIST _STARTED
} ) ;
const callback = channels => {
dispatch ( {
type : FETCH _CHANNEL _LIST _COMPLETED ,
data : { claims : channels }
} ) ;
} ;
lbryProxy . channel _list ( ) . then ( callback ) ;
} ;
}
2019-07-30 17:48:45 +02:00
function doClaimSearch ( options = {
page _size : 10
} ) {
const query = createNormalizedClaimSearchKey ( options ) ;
2019-06-10 04:45:47 +02:00
return dispatch => {
dispatch ( {
2019-07-30 17:48:45 +02:00
type : CLAIM _SEARCH _STARTED ,
data : { query : query }
2019-06-10 04:45:47 +02:00
} ) ;
const success = data => {
const resolveInfo = { } ;
2019-08-20 22:00:26 +02:00
const urls = [ ] ;
2019-06-10 04:45:47 +02:00
data . items . forEach ( stream => {
2019-08-20 22:00:26 +02:00
resolveInfo [ stream . canonical _url ] = { stream } ;
urls . push ( stream . canonical _url ) ;
2019-06-10 04:45:47 +02:00
} ) ;
dispatch ( {
type : CLAIM _SEARCH _COMPLETED ,
2019-08-13 17:27:32 +02:00
data : {
query ,
resolveInfo ,
2019-08-20 22:00:26 +02:00
urls ,
2019-08-13 17:27:32 +02:00
append : options . page && options . page !== 1 ,
pageSize : options . page _size
}
2019-06-10 04:45:47 +02:00
} ) ;
} ;
const failure = err => {
dispatch ( {
type : CLAIM _SEARCH _FAILED ,
2019-07-30 17:48:45 +02:00
data : { query } ,
2019-06-10 04:45:47 +02:00
error : err
} ) ;
} ;
2019-07-30 17:48:45 +02:00
lbryProxy . claim _search ( options ) . then ( success , failure ) ;
2019-07-15 04:44:02 +02:00
} ;
}
2019-04-03 19:12:51 +02:00
const selectState$3 = state => state . fileInfo || { } ;
const selectFileInfosByOutpoint = reselect . createSelector ( selectState$3 , state => state . byOutpoint || { } ) ;
const selectIsFetchingFileList = reselect . createSelector ( selectState$3 , state => state . isFetchingFileList ) ;
const selectIsFetchingFileListDownloadedOrPublished = reselect . createSelector ( selectIsFetchingFileList , selectIsFetchingClaimListMine , ( isFetchingFileList , isFetchingClaimListMine ) => isFetchingFileList || isFetchingClaimListMine ) ;
const makeSelectFileInfoForUri = uri => reselect . createSelector ( selectClaimsByUri , selectFileInfosByOutpoint , ( claims , byOutpoint ) => {
const claim = claims [ uri ] ;
const outpoint = claim ? ` ${ claim . txid } : ${ claim . nout } ` : undefined ;
return outpoint ? byOutpoint [ outpoint ] : undefined ;
} ) ;
const selectDownloadingByOutpoint = reselect . createSelector ( selectState$3 , state => state . downloadingByOutpoint || { } ) ;
const makeSelectDownloadingForUri = uri => reselect . createSelector ( selectDownloadingByOutpoint , makeSelectFileInfoForUri ( uri ) , ( byOutpoint , fileInfo ) => {
if ( ! fileInfo ) return false ;
return byOutpoint [ fileInfo . outpoint ] ;
} ) ;
2019-08-14 19:08:38 +02:00
const selectUrisLoading = reselect . createSelector ( selectState$3 , state => state . fetching || { } ) ;
2019-04-03 19:12:51 +02:00
2019-08-14 19:08:38 +02:00
const makeSelectLoadingForUri = uri => reselect . createSelector ( selectUrisLoading , makeSelectClaimForUri ( uri ) , ( fetchingByOutpoint , claim ) => {
if ( ! claim ) {
return false ;
}
const { txid , nout } = claim ;
const outpoint = ` ${ txid } : ${ nout } ` ;
const isFetching = fetchingByOutpoint [ outpoint ] ;
return isFetching ;
} ) ;
2019-04-03 19:12:51 +02:00
const selectFileInfosDownloaded = reselect . createSelector ( selectFileInfosByOutpoint , selectMyClaims , ( byOutpoint , myClaims ) => Object . values ( byOutpoint ) . filter ( fileInfo => {
const myClaimIds = myClaims . map ( claim => claim . claim _id ) ;
2019-08-02 08:21:28 +02:00
return fileInfo && myClaimIds . indexOf ( fileInfo . claim _id ) === - 1 && ( fileInfo . completed || fileInfo . written _bytes > 0 || fileInfo . blobs _completed > 0 ) ;
2019-04-03 19:12:51 +02:00
} ) ) ;
// export const selectFileInfoForUri = (state, props) => {
// const claims = selectClaimsByUri(state),
// claim = claims[props.uri],
// fileInfos = selectAllFileInfos(state),
// outpoint = claim ? `${claim.txid}:${claim.nout}` : undefined;
// return outpoint && fileInfos ? fileInfos[outpoint] : undefined;
// };
const selectDownloadingFileInfos = reselect . createSelector ( selectDownloadingByOutpoint , selectFileInfosByOutpoint , ( downloadingByOutpoint , fileInfosByOutpoint ) => {
const outpoints = Object . keys ( downloadingByOutpoint ) ;
const fileInfos = [ ] ;
outpoints . forEach ( outpoint => {
const fileInfo = fileInfosByOutpoint [ outpoint ] ;
if ( fileInfo ) fileInfos . push ( fileInfo ) ;
} ) ;
return fileInfos ;
} ) ;
const selectTotalDownloadProgress = reselect . createSelector ( selectDownloadingFileInfos , fileInfos => {
const progress = [ ] ;
fileInfos . forEach ( fileInfo => {
progress . push ( fileInfo . written _bytes / fileInfo . total _bytes * 100 ) ;
} ) ;
const totalProgress = progress . reduce ( ( a , b ) => a + b , 0 ) ;
if ( fileInfos . length > 0 ) return totalProgress / fileInfos . length / 100.0 ;
return - 1 ;
} ) ;
const selectFileListPublishedSort = reselect . createSelector ( selectState$3 , state => state . fileListPublishedSort ) ;
const selectFileListDownloadedSort = reselect . createSelector ( selectState$3 , state => state . fileListDownloadedSort ) ;
2019-06-10 04:45:47 +02:00
const selectDownloadedUris = reselect . createSelector ( selectFileInfosDownloaded ,
// We should use permament_url but it doesn't exist in file_list
2019-07-05 19:35:17 +02:00
info => info . slice ( ) . reverse ( ) . map ( claim => ` lbry:// ${ claim . claim _name } # ${ claim . claim _id } ` ) ) ;
2019-06-10 04:45:47 +02:00
2019-08-02 08:21:28 +02:00
const makeSelectMediaTypeForUri = uri => reselect . createSelector ( makeSelectFileInfoForUri ( uri ) , makeSelectContentTypeForUri ( uri ) , ( fileInfo , contentType ) => {
if ( ! fileInfo && ! contentType ) {
return undefined ;
}
const fileName = fileInfo && fileInfo . file _name ;
return lbryProxy . getMediaType ( contentType , fileName ) ;
} ) ;
const makeSelectUriIsStreamable = uri => reselect . createSelector ( makeSelectMediaTypeForUri ( uri ) , mediaType => {
const isStreamable = [ 'audio' , 'video' , 'image' ] . indexOf ( mediaType ) !== - 1 ;
return isStreamable ;
} ) ;
const makeSelectDownloadPathForUri = uri => reselect . createSelector ( makeSelectFileInfoForUri ( uri ) , fileInfo => {
return fileInfo && fileInfo . download _path ;
} ) ;
2019-08-14 18:52:24 +02:00
2019-08-14 19:51:30 +02:00
const makeSelectFilePartlyDownloaded = uri => reselect . createSelector ( makeSelectFileInfoForUri ( uri ) , fileInfo => {
if ( ! fileInfo ) {
2019-08-14 18:52:24 +02:00
return false ;
}
2019-08-14 19:51:30 +02:00
return fileInfo . written _bytes > 0 || fileInfo . blobs _completed > 0 ;
2019-08-14 18:52:24 +02:00
} ) ;
2019-08-02 08:21:28 +02:00
const makeSelectFileNameForUri = uri => reselect . createSelector ( makeSelectFileInfoForUri ( uri ) , fileInfo => {
return fileInfo && fileInfo . file _name ;
} ) ;
2019-09-25 23:37:21 +02:00
const makeSelectDownloadUrlsForPage = ( page = 1 ) => reselect . createSelector ( selectDownloadedUris , urls => {
2019-09-25 23:16:27 +02:00
const start = ( Number ( page ) - 1 ) * Number ( PAGE _SIZE ) ;
const end = Number ( page ) * Number ( PAGE _SIZE ) ;
2019-09-25 23:37:21 +02:00
return urls && urls . length ? urls . slice ( start , end ) : [ ] ;
2019-09-23 19:00:12 +02:00
} ) ;
2019-09-25 23:37:21 +02:00
const selectDownloadUrlsCount = reselect . createSelector ( selectDownloadedUris , uris => uris . length ) ;
2019-09-23 19:00:12 +02:00
2019-05-21 21:18:07 +02:00
//
const selectState$4 = state => state . file || { } ;
2019-05-27 15:59:21 +02:00
const selectPurchaseUriErrorMessage = reselect . createSelector ( selectState$4 , state => state . purchaseUriErrorMessage ) ;
2019-05-21 21:18:07 +02:00
const selectFailedPurchaseUris = reselect . createSelector ( selectState$4 , state => state . failedPurchaseUris ) ;
const selectPurchasedUris = reselect . createSelector ( selectState$4 , state => state . purchasedUris ) ;
const selectLastPurchasedUri = reselect . createSelector ( selectState$4 , state => state . purchasedUris . length > 0 ? state . purchasedUris [ state . purchasedUris . length - 1 ] : null ) ;
2019-08-02 08:21:28 +02:00
const makeSelectStreamingUrlForUri = uri => reselect . createSelector ( makeSelectFileInfoForUri ( uri ) , fileInfo => {
return fileInfo && fileInfo . streaming _url ;
} ) ;
2019-05-21 21:18:07 +02:00
//
2019-08-02 08:21:28 +02:00
function doFileGet ( uri , saveFile = true , onSuccess ) {
2019-08-13 19:33:32 +02:00
return ( dispatch , getState ) => {
const state = getState ( ) ;
const { nout , txid } = makeSelectClaimForUri ( uri ) ( state ) ;
const outpoint = ` ${ txid } : ${ nout } ` ;
2019-05-21 21:18:07 +02:00
dispatch ( {
2019-08-13 19:33:32 +02:00
type : FETCH _FILE _INFO _STARTED ,
2019-05-21 21:18:07 +02:00
data : {
2019-08-13 19:33:32 +02:00
outpoint
2019-05-21 21:18:07 +02:00
}
} ) ;
// set save_file argument to True to save the file (old behaviour)
lbryProxy . get ( { uri , save _file : saveFile } ) . then ( streamInfo => {
2019-08-02 08:21:28 +02:00
const timeout = streamInfo === null || typeof streamInfo !== 'object' || streamInfo . error === 'Timeout' ;
2019-05-21 21:18:07 +02:00
if ( timeout ) {
dispatch ( {
2019-08-13 19:33:32 +02:00
type : FETCH _FILE _INFO _FAILED ,
data : { outpoint }
2019-05-21 21:18:07 +02:00
} ) ;
dispatch ( doToast ( { message : ` File timeout for uri ${ uri } ` , isError : true } ) ) ;
} else {
// purchase was completed successfully
dispatch ( {
type : PURCHASE _URI _COMPLETED ,
2019-08-06 04:52:46 +02:00
data : { uri }
2019-05-21 21:18:07 +02:00
} ) ;
2019-08-02 08:21:28 +02:00
dispatch ( {
type : FETCH _FILE _INFO _COMPLETED ,
data : {
fileInfo : streamInfo ,
outpoint : streamInfo . outpoint
}
2019-05-21 21:18:07 +02:00
} ) ;
2019-08-02 08:21:28 +02:00
if ( onSuccess ) {
onSuccess ( streamInfo ) ;
}
2019-05-21 21:18:07 +02:00
}
} ) . catch ( ( ) => {
dispatch ( {
type : PURCHASE _URI _FAILED ,
data : { uri }
} ) ;
dispatch ( {
2019-08-13 19:33:32 +02:00
type : FETCH _FILE _INFO _FAILED ,
data : { outpoint }
2019-05-21 21:18:07 +02:00
} ) ;
dispatch ( doToast ( {
2019-08-02 08:21:28 +02:00
message : ` Failed to view ${ uri } , please try again. If this problem persists, visit https://lbry.com/faq/support for support. ` ,
2019-05-21 21:18:07 +02:00
isError : true
} ) ) ;
} ) ;
} ;
}
2019-08-02 08:21:28 +02:00
function doPurchaseUri ( uri , costInfo , saveFile = true , onSuccess ) {
2019-05-21 21:18:07 +02:00
return ( dispatch , getState ) => {
dispatch ( {
type : PURCHASE _URI _STARTED ,
data : { uri }
} ) ;
const state = getState ( ) ;
const balance = selectBalance ( state ) ;
const fileInfo = makeSelectFileInfoForUri ( uri ) ( state ) ;
const downloadingByOutpoint = selectDownloadingByOutpoint ( state ) ;
const alreadyDownloading = fileInfo && ! ! downloadingByOutpoint [ fileInfo . outpoint ] ;
const alreadyStreaming = makeSelectStreamingUrlForUri ( uri ) ( state ) ;
2019-08-15 00:22:50 +02:00
if ( ! saveFile && ( alreadyDownloading || alreadyStreaming ) ) {
2019-05-21 21:18:07 +02:00
dispatch ( {
type : PURCHASE _URI _FAILED ,
data : { uri , error : ` Already fetching uri: ${ uri } ` }
} ) ;
return ;
}
const { cost } = costInfo ;
2019-05-27 15:59:21 +02:00
if ( parseFloat ( cost ) > balance ) {
2019-05-21 21:18:07 +02:00
dispatch ( {
type : PURCHASE _URI _FAILED ,
data : { uri , error : 'Insufficient credits' }
} ) ;
return ;
}
2019-08-02 08:21:28 +02:00
dispatch ( doFileGet ( uri , saveFile , onSuccess ) ) ;
2019-05-21 21:18:07 +02:00
} ;
}
2019-05-27 15:59:21 +02:00
function doDeletePurchasedUri ( uri ) {
return {
type : DELETE _PURCHASED _URI ,
data : { uri }
} ;
}
2019-04-03 19:12:51 +02:00
function doFetchFileInfo ( uri ) {
return ( dispatch , getState ) => {
const state = getState ( ) ;
const claim = selectClaimsByUri ( state ) [ uri ] ;
const outpoint = claim ? ` ${ claim . txid } : ${ claim . nout } ` : null ;
const alreadyFetching = ! ! selectUrisLoading ( state ) [ uri ] ;
if ( ! alreadyFetching ) {
dispatch ( {
type : FETCH _FILE _INFO _STARTED ,
data : {
outpoint
}
} ) ;
lbryProxy . file _list ( { outpoint , full _status : true } ) . then ( fileInfos => {
dispatch ( {
type : FETCH _FILE _INFO _COMPLETED ,
data : {
outpoint ,
fileInfo : fileInfos && fileInfos . length ? fileInfos [ 0 ] : null
}
} ) ;
} ) ;
}
} ;
}
function doFileList ( ) {
return ( dispatch , getState ) => {
const state = getState ( ) ;
const isFetching = selectIsFetchingFileList ( state ) ;
if ( ! isFetching ) {
dispatch ( {
type : FILE _LIST _STARTED
} ) ;
lbryProxy . file _list ( ) . then ( fileInfos => {
dispatch ( {
type : FILE _LIST _SUCCEEDED ,
data : {
fileInfos
}
} ) ;
} ) ;
}
} ;
}
function doFetchFileInfosAndPublishedClaims ( ) {
return ( dispatch , getState ) => {
const state = getState ( ) ;
const isFetchingClaimListMine = selectIsFetchingClaimListMine ( state ) ;
const isFetchingFileInfo = selectIsFetchingFileList ( state ) ;
if ( ! isFetchingClaimListMine ) dispatch ( doFetchClaimListMine ( ) ) ;
if ( ! isFetchingFileInfo ) dispatch ( doFileList ( ) ) ;
} ;
}
function doSetFileListSort ( page , value ) {
return {
type : SET _FILE _LIST _SORT ,
data : { page , value }
} ;
}
2019-08-20 22:00:26 +02:00
function _objectWithoutProperties$2 ( obj , keys ) { var target = { } ; for ( var i in obj ) { if ( keys . indexOf ( i ) >= 0 ) continue ; if ( ! Object . prototype . hasOwnProperty . call ( obj , i ) ) continue ; target [ i ] = obj [ i ] ; } return target ; }
2019-07-01 21:49:51 +02:00
2019-07-05 04:20:56 +02:00
const selectState$5 = state => state . publish || { } ;
const selectPublishFormValues = reselect . createSelector ( selectState$5 , state => {
2019-08-20 22:00:26 +02:00
const formValues = _objectWithoutProperties$2 ( state , [ 'pendingPublish' ] ) ;
2019-07-05 04:20:56 +02:00
return formValues ;
} ) ;
const makeSelectPublishFormValue = item => reselect . createSelector ( selectState$5 , state => state [ item ] ) ;
// Is the current uri the same as the uri they clicked "edit" on
const selectIsStillEditing = reselect . createSelector ( selectPublishFormValues , publishState => {
const { editingURI , uri } = publishState ;
if ( ! editingURI || ! uri ) {
return false ;
2019-07-01 21:49:51 +02:00
}
2019-08-20 22:00:26 +02:00
const {
isChannel : currentIsChannel ,
2019-08-29 09:28:04 +02:00
streamName : currentClaimName ,
channelName : currentContentName
2019-08-20 22:00:26 +02:00
} = parseURI ( uri ) ;
const {
isChannel : editIsChannel ,
2019-08-29 09:28:04 +02:00
streamName : editClaimName ,
channelName : editContentName
2019-08-20 22:00:26 +02:00
} = parseURI ( editingURI ) ;
2019-07-05 04:20:56 +02:00
// Depending on the previous/current use of a channel, we need to compare different things
// ex: going from a channel to anonymous, the new uri won't return contentName, so we need to use claimName
const currentName = currentIsChannel ? currentContentName : currentClaimName ;
const editName = editIsChannel ? editContentName : editClaimName ;
return currentName === editName ;
} ) ;
const selectMyClaimForUri = reselect . createSelector ( selectPublishFormValues , selectIsStillEditing , selectClaimsById , selectMyClaimsWithoutChannels , ( { editingURI , uri } , isStillEditing , claimsById , myClaims ) => {
2019-08-29 09:28:04 +02:00
const { channelName : contentName , streamName : claimName } = parseURI ( uri ) ;
const { streamClaimId : editClaimId } = parseURI ( editingURI ) ;
2019-07-05 04:20:56 +02:00
// If isStillEditing
// They clicked "edit" from the file page
// They haven't changed the channel/name after clicking edit
// Get the claim so they can edit without re-uploading a new file
return isStillEditing ? claimsById [ editClaimId ] : myClaims . find ( claim => ! contentName ? claim . name === claimName : claim . name === contentName || claim . name === claimName ) ;
} ) ;
const selectIsResolvingPublishUris = reselect . createSelector ( selectState$5 , selectResolvingUris , ( { uri , name } , resolvingUris ) => {
if ( uri ) {
const isResolvingUri = resolvingUris . includes ( uri ) ;
const { isChannel } = parseURI ( uri ) ;
let isResolvingShortUri ;
2019-08-30 18:28:36 +02:00
if ( isChannel && name ) {
2019-08-20 22:00:26 +02:00
const shortUri = buildURI ( { streamName : name } ) ;
2019-07-05 04:20:56 +02:00
isResolvingShortUri = resolvingUris . includes ( shortUri ) ;
}
return isResolvingUri || isResolvingShortUri ;
}
return false ;
} ) ;
const selectTakeOverAmount = reselect . createSelector ( selectState$5 , selectMyClaimForUri , selectClaimsByUri , ( { name } , myClaimForUri , claimsByUri ) => {
2019-08-28 01:59:04 +02:00
if ( ! name ) {
return null ;
}
2019-07-05 04:20:56 +02:00
// We only care about the winning claim for the short uri
2019-08-28 01:59:04 +02:00
const shortUri = buildURI ( { streamName : name } ) ;
2019-07-05 04:20:56 +02:00
const claimForShortUri = claimsByUri [ shortUri ] ;
if ( ! myClaimForUri && claimForShortUri ) {
2019-08-29 09:28:04 +02:00
return claimForShortUri . meta . effective _amount ;
2019-07-05 04:20:56 +02:00
} else if ( myClaimForUri && claimForShortUri ) {
// https://github.com/lbryio/lbry/issues/1476
// We should check the current effective_amount on my claim to see how much additional lbc
// is needed to win the claim. Currently this is not possible during a takeover.
// With this, we could say something like, "You have x lbc in support, if you bid y additional LBC you will control the claim"
// For now just ignore supports. We will just show the winning claim's bid amount
2019-08-29 09:28:04 +02:00
return claimForShortUri . meta . effective _amount || claimForShortUri . amount ;
2019-07-05 04:20:56 +02:00
}
return null ;
} ) ;
2019-07-01 21:49:51 +02:00
var _extends$4 = Object . assign || function ( target ) { for ( var i = 1 ; i < arguments . length ; i ++ ) { var source = arguments [ i ] ; for ( var key in source ) { if ( Object . prototype . hasOwnProperty . call ( source , key ) ) { target [ key ] = source [ key ] ; } } } return target ; } ;
const doResetThumbnailStatus = ( ) => dispatch => {
dispatch ( {
type : UPDATE _PUBLISH _FORM ,
data : {
thumbnailPath : ''
}
} ) ;
return fetch ( 'https://spee.ch/api/config/site/publishing' ) . then ( res => res . json ( ) ) . then ( status => {
if ( status . disabled ) {
throw Error ( ) ;
}
return dispatch ( {
type : UPDATE _PUBLISH _FORM ,
data : {
uploadThumbnailStatus : READY ,
thumbnail : ''
}
} ) ;
} ) . catch ( ( ) => dispatch ( {
type : UPDATE _PUBLISH _FORM ,
data : {
uploadThumbnailStatus : API _DOWN ,
thumbnail : ''
}
} ) ) ;
} ;
const doClearPublish = ( ) => dispatch => {
dispatch ( { type : CLEAR _PUBLISH } ) ;
return dispatch ( doResetThumbnailStatus ( ) ) ;
} ;
const doUpdatePublishForm = publishFormValue => dispatch => dispatch ( {
type : UPDATE _PUBLISH _FORM ,
data : _extends$4 ( { } , publishFormValue )
} ) ;
2019-08-13 17:27:32 +02:00
const doUploadThumbnail = ( filePath , thumbnailBuffer , fsAdapter , fs , path ) => dispatch => {
2019-07-01 21:49:51 +02:00
let thumbnail , fileExt , fileName , fileType ;
const makeid = ( ) => {
let text = '' ;
const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789' ;
for ( let i = 0 ; i < 24 ; i += 1 ) text += possible . charAt ( Math . floor ( Math . random ( ) * 62 ) ) ;
return text ;
} ;
const uploadError = ( error = '' ) => {
dispatch ( batchActions ( {
type : UPDATE _PUBLISH _FORM ,
data : {
uploadThumbnailStatus : READY ,
thumbnail : '' ,
nsfw : false
}
} , doError ( error ) ) ) ;
} ;
dispatch ( {
type : UPDATE _PUBLISH _FORM ,
data : { uploadThumbnailStatus : IN _PROGRESS }
} ) ;
if ( fsAdapter && fsAdapter . readFile && filePath ) {
fsAdapter . readFile ( filePath , 'base64' ) . then ( base64Image => {
fileExt = 'png' ;
fileName = 'thumbnail.png' ;
fileType = 'image/png' ;
const data = new FormData ( ) ;
const name = makeid ( ) ;
data . append ( 'name' , name ) ;
2019-07-05 04:20:56 +02:00
// $FlowFixMe
2019-07-01 21:49:51 +02:00
data . append ( 'file' , { uri : 'file://' + filePath , type : fileType , name : fileName } ) ;
return fetch ( 'https://spee.ch/api/claim/publish' , {
method : 'POST' ,
body : data
} ) . then ( response => response . json ( ) ) . then ( json => json . success ? dispatch ( {
type : UPDATE _PUBLISH _FORM ,
data : {
uploadThumbnailStatus : COMPLETE ,
2019-08-13 17:27:32 +02:00
thumbnail : ` ${ json . data . url } . ${ fileExt } `
2019-07-01 21:49:51 +02:00
}
} ) : uploadError ( json . message ) ) . catch ( err => uploadError ( err . message ) ) ;
} ) ;
} else {
if ( filePath ) {
thumbnail = fs . readFileSync ( filePath ) ;
fileExt = path . extname ( filePath ) ;
fileName = path . basename ( filePath ) ;
fileType = ` image/ ${ fileExt . slice ( 1 ) } ` ;
} else if ( thumbnailBuffer ) {
thumbnail = thumbnailBuffer ;
fileExt = '.png' ;
fileName = 'thumbnail.png' ;
fileType = 'image/png' ;
} else {
return null ;
}
const data = new FormData ( ) ;
const name = makeid ( ) ;
const file = new File ( [ thumbnail ] , fileName , { type : fileType } ) ;
data . append ( 'name' , name ) ;
data . append ( 'file' , file ) ;
return fetch ( 'https://spee.ch/api/claim/publish' , {
method : 'POST' ,
body : data
} ) . then ( response => response . json ( ) ) . then ( json => json . success ? dispatch ( {
type : UPDATE _PUBLISH _FORM ,
data : {
uploadThumbnailStatus : COMPLETE ,
thumbnail : ` ${ json . data . url } ${ fileExt } `
}
} ) : uploadError ( json . message ) ) . catch ( err => uploadError ( err . message ) ) ;
}
} ;
2019-08-13 17:27:32 +02:00
const doPrepareEdit = ( claim , uri , fileInfo , fs ) => dispatch => {
2019-08-14 03:05:30 +02:00
const { name , amount , value = { } } = claim ;
2019-09-04 17:57:48 +02:00
const channelName = claim && claim . signing _channel && claim . signing _channel . name || null ;
2019-07-01 21:49:51 +02:00
const {
author ,
description ,
// use same values as default state
// fee will be undefined for free content
fee = {
2019-07-05 04:20:56 +02:00
amount : '0' ,
2019-07-01 21:49:51 +02:00
currency : 'LBC'
} ,
languages ,
license ,
license _url : licenseUrl ,
thumbnail ,
2019-08-14 20:47:57 +02:00
title ,
tags
2019-07-01 21:49:51 +02:00
} = value ;
const publishData = {
name ,
bid : amount ,
2019-07-29 20:42:28 +02:00
contentIsFree : fee . amount === '0' ,
2019-07-01 21:49:51 +02:00
author ,
description ,
2019-07-29 20:42:28 +02:00
fee ,
2019-07-01 21:49:51 +02:00
languages ,
thumbnail : thumbnail ? thumbnail . url : null ,
title ,
uri ,
uploadThumbnailStatus : thumbnail ? MANUAL : undefined ,
licenseUrl ,
2019-08-14 20:47:57 +02:00
nsfw : isClaimNsfw ( claim ) ,
tags : tags ? tags . map ( tag => ( { name : tag } ) ) : [ ]
2019-07-01 21:49:51 +02:00
} ;
2019-07-13 05:01:16 +02:00
// Make sure custom licenses are mapped properly
2019-07-01 21:49:51 +02:00
// If the license isn't one of the standard licenses, map the custom license and description/url
if ( ! CC _LICENSES . some ( ( { value } ) => value === license ) ) {
if ( ! license || license === NONE || license === PUBLIC _DOMAIN ) {
publishData . licenseType = license ;
} else if ( license && ! licenseUrl && license !== NONE ) {
publishData . licenseType = COPYRIGHT ;
} else {
publishData . licenseType = OTHER ;
}
publishData . otherLicenseDescription = license ;
} else {
publishData . licenseType = license ;
}
2019-07-05 04:20:56 +02:00
if ( channelName ) {
publishData [ 'channel' ] = channelName ;
}
2019-07-01 21:49:51 +02:00
dispatch ( { type : DO _PREPARE _EDIT , data : publishData } ) ;
} ;
2019-07-05 04:20:56 +02:00
const doPublish = ( success , fail ) => ( dispatch , getState ) => {
2019-07-01 21:49:51 +02:00
dispatch ( { type : PUBLISH _START } ) ;
const state = getState ( ) ;
2019-07-05 04:20:56 +02:00
const myClaimForUri = selectMyClaimForUri ( state ) ;
2019-07-01 21:49:51 +02:00
const myChannels = selectMyChannelClaims ( state ) ;
const myClaims = selectMyClaimsWithoutChannels ( state ) ;
2019-07-05 04:20:56 +02:00
// get redux publish form
const publishData = selectPublishFormValues ( state ) ;
2019-07-01 21:49:51 +02:00
2019-07-05 04:20:56 +02:00
// destructure the data values
2019-07-01 21:49:51 +02:00
const {
name ,
bid ,
filePath ,
description ,
language ,
license ,
licenseUrl ,
2019-07-05 04:20:56 +02:00
licenseType ,
otherLicenseDescription ,
2019-07-01 21:49:51 +02:00
thumbnail ,
channel ,
title ,
contentIsFree ,
fee ,
uri ,
2019-07-05 04:20:56 +02:00
tags ,
locations
} = publishData ;
let publishingLicense ;
switch ( licenseType ) {
case COPYRIGHT :
case OTHER :
publishingLicense = otherLicenseDescription ;
break ;
default :
publishingLicense = licenseType ;
}
2019-07-01 21:49:51 +02:00
// get the claim id from the channel name, we will use that instead
2019-09-27 00:56:55 +02:00
const namedChannelClaim = myChannels ? myChannels . find ( myChannel => myChannel . name === channel ) : null ;
2019-07-01 21:49:51 +02:00
const channelId = namedChannelClaim ? namedChannelClaim . claim _id : '' ;
const publishPayload = {
name ,
title ,
description ,
2019-10-02 01:00:59 +02:00
locations : [ ] ,
2019-07-05 04:20:56 +02:00
bid : creditsToString ( bid ) ,
languages : [ language ] ,
tags : tags && tags . map ( tag => tag . name ) ,
2019-10-02 01:00:59 +02:00
thumbnail _url : thumbnail ,
blocking : true
2019-07-05 04:20:56 +02:00
} ;
2019-07-01 21:49:51 +02:00
// Temporary solution to keep the same publish flow with the new tags api
// Eventually we will allow users to enter their own tags on publish
// `nsfw` will probably be removed
2019-07-05 04:20:56 +02:00
if ( publishingLicense ) {
publishPayload . license = publishingLicense ;
}
2019-07-01 21:49:51 +02:00
if ( licenseUrl ) {
publishPayload . license _url = licenseUrl ;
}
if ( thumbnail ) {
publishPayload . thumbnail _url = thumbnail ;
}
2019-07-29 20:42:28 +02:00
// Set release time to curret date. On edits, keep original release/transaction time as release_time
2019-07-05 04:20:56 +02:00
if ( myClaimForUri && myClaimForUri . value . release _time ) {
publishPayload . release _time = Number ( myClaimForUri . value . release _time ) ;
2019-07-29 20:42:28 +02:00
} else if ( myClaimForUri && myClaimForUri . timestamp ) {
publishPayload . release _time = Number ( myClaimForUri . timestamp ) ;
2019-07-01 21:49:51 +02:00
} else {
2019-07-29 20:42:28 +02:00
publishPayload . release _time = Number ( Math . round ( Date . now ( ) / 1000 ) ) ;
2019-07-01 21:49:51 +02:00
}
if ( channelId ) {
publishPayload . channel _id = channelId ;
}
2019-10-02 01:00:59 +02:00
if ( myClaimForUri && myClaimForUri . value && myClaimForUri . value . locations ) {
publishPayload . locations = myClaimForUri . value . locations ;
}
2019-07-01 21:49:51 +02:00
if ( ! contentIsFree && fee && fee . currency && Number ( fee . amount ) > 0 ) {
publishPayload . fee _currency = fee . currency ;
publishPayload . fee _amount = creditsToString ( fee . amount ) ;
}
// Only pass file on new uploads, not metadata only edits.
// The sdk will figure it out
if ( filePath ) publishPayload . file _path = filePath ;
2019-07-05 04:20:56 +02:00
return lbryProxy . publish ( publishPayload ) . then ( success , fail ) ;
2019-07-01 21:49:51 +02:00
} ;
// Calls claim_list_mine until any pending publishes are confirmed
2019-07-13 03:33:28 +02:00
const doCheckPendingPublishes = onConfirmed => ( dispatch , getState ) => {
2019-07-01 21:49:51 +02:00
const state = getState ( ) ;
const pendingById = selectPendingById ( state ) ;
if ( ! Object . keys ( pendingById ) . length ) {
return ;
}
let publishCheckInterval ;
const checkFileList = ( ) => {
lbryProxy . claim _list ( ) . then ( claims => {
2019-07-05 04:20:56 +02:00
// $FlowFixMe
2019-07-01 21:49:51 +02:00
claims . forEach ( claim => {
// If it's confirmed, check if it was pending previously
if ( claim . confirmations > 0 && pendingById [ claim . claim _id ] ) {
delete pendingById [ claim . claim _id ] ;
2019-07-13 03:33:28 +02:00
if ( onConfirmed ) {
onConfirmed ( claim ) ;
}
2019-07-01 21:49:51 +02:00
}
} ) ;
dispatch ( {
type : FETCH _CLAIM _LIST _MINE _COMPLETED ,
data : {
claims
}
} ) ;
if ( ! Object . keys ( pendingById ) . length ) {
clearInterval ( publishCheckInterval ) ;
}
} ) ;
} ;
publishCheckInterval = setInterval ( ( ) => {
checkFileList ( ) ;
} , 30000 ) ;
} ;
2019-04-03 19:12:51 +02:00
// Returns a function, that, as long as it continues to be invoked, will not
// be triggered. The function will be called after it stops being called for
// N milliseconds. If `immediate` is passed, trigger the function on the
// leading edge, instead of the trailing.
function debouce ( func , wait , immediate ) {
let timeout ;
return function ( ) {
const context = this ;
const args = arguments ;
const later = ( ) => {
timeout = null ;
if ( ! immediate ) func . apply ( context , args ) ;
} ;
const callNow = immediate && ! timeout ;
clearTimeout ( timeout ) ;
timeout = setTimeout ( later , wait ) ;
if ( callNow ) func . apply ( context , args ) ;
} ;
}
2019-04-23 19:22:14 +02:00
//
2019-04-03 19:12:51 +02:00
function handleFetchResponse ( response ) {
return response . status === 200 ? Promise . resolve ( response . json ( ) ) : Promise . reject ( new Error ( response . statusText ) ) ;
}
//
const DEBOUNCED _SEARCH _SUGGESTION _MS = 300 ;
// We can't use env's because they aren't passed into node_modules
2019-05-10 19:29:51 +02:00
let CONNECTION _STRING = 'https://lighthouse.lbry.com/' ;
2019-04-03 19:12:51 +02:00
const setSearchApi = endpoint => {
CONNECTION _STRING = endpoint . replace ( /\/*$/ , '/' ) ; // exactly one slash at the end;
} ;
const getSearchSuggestions = value => ( dispatch , getState ) => {
const query = value . trim ( ) ;
// strip out any basic stuff for more accurate search results
let searchValue = query . replace ( /lbry:\/\//g , '' ) . replace ( /-/g , ' ' ) ;
if ( searchValue . includes ( '#' ) ) {
// This should probably be more robust, but I think it's fine for now
// Remove everything after # to get rid of the claim id
searchValue = searchValue . substring ( 0 , searchValue . indexOf ( '#' ) ) ;
}
const suggestions = selectSuggestions ( getState ( ) ) ;
if ( suggestions [ searchValue ] ) {
return ;
}
fetch ( ` ${ CONNECTION _STRING } autocomplete?s= ${ searchValue } ` ) . then ( handleFetchResponse ) . then ( apiSuggestions => {
dispatch ( {
type : UPDATE _SEARCH _SUGGESTIONS ,
data : {
query : searchValue ,
suggestions : apiSuggestions
}
} ) ;
} ) . catch ( ( ) => {
// If the fetch fails, do nothing
// Basic search suggestions are already populated at this point
} ) ;
} ;
const throttledSearchSuggestions = debouce ( ( dispatch , query ) => {
dispatch ( getSearchSuggestions ( query ) ) ;
} , DEBOUNCED _SEARCH _SUGGESTION _MS ) ;
const doUpdateSearchQuery = ( query , shouldSkipSuggestions ) => dispatch => {
dispatch ( {
type : UPDATE _SEARCH _QUERY ,
data : { query }
} ) ;
// Don't fetch new suggestions if the user just added a space
if ( ! query . endsWith ( ' ' ) || ! shouldSkipSuggestions ) {
throttledSearchSuggestions ( dispatch , query ) ;
}
} ;
const doSearch = ( rawQuery , // pass in a query if you don't want to search for what's in the search bar
size , // only pass in if you don't want to use the users setting (ex: related content)
from , isBackgroundSearch = false ) => ( dispatch , getState ) => {
const query = rawQuery . replace ( /^lbry:\/\//i , '' ) . replace ( /\// , ' ' ) ;
if ( ! query ) {
dispatch ( {
type : SEARCH _FAIL
} ) ;
return ;
}
const state = getState ( ) ;
const queryWithOptions = makeSelectQueryWithOptions ( query , size , from , isBackgroundSearch ) ( state ) ;
// If we have already searched for something, we don't need to do anything
const urisForQuery = makeSelectSearchUris ( queryWithOptions ) ( state ) ;
if ( urisForQuery && ! ! urisForQuery . length ) {
return ;
}
dispatch ( {
type : SEARCH _START
} ) ;
// If the user is on the file page with a pre-populated uri and they select
// the search option without typing anything, searchQuery will be empty
// We need to populate it so the input is filled on the search page
// isBackgroundSearch means the search is happening in the background, don't update the search query
if ( ! state . search . searchQuery && ! isBackgroundSearch ) {
dispatch ( doUpdateSearchQuery ( query ) ) ;
}
fetch ( ` ${ CONNECTION _STRING } search? ${ queryWithOptions } ` ) . then ( handleFetchResponse ) . then ( data => {
const uris = [ ] ;
const actions = [ ] ;
data . forEach ( result => {
2019-08-20 22:00:26 +02:00
if ( result ) {
const { name , claimId } = result ;
const urlObj = { } ;
if ( name . startsWith ( '@' ) ) {
urlObj . channelName = name ;
urlObj . channelClaimId = claimId ;
} else {
urlObj . streamName = name ;
urlObj . streamClaimId = claimId ;
}
const url = buildURI ( urlObj ) ;
actions . push ( doResolveUri ( url ) ) ;
uris . push ( url ) ;
2019-06-27 08:13:54 +02:00
}
2019-04-03 19:12:51 +02:00
} ) ;
actions . push ( {
type : SEARCH _SUCCESS ,
data : {
query : queryWithOptions ,
uris
}
} ) ;
dispatch ( batchActions ( ... actions ) ) ;
2019-06-27 08:13:54 +02:00
} ) . catch ( e => {
2019-04-03 19:12:51 +02:00
dispatch ( {
type : SEARCH _FAIL
} ) ;
} ) ;
} ;
const doFocusSearchInput = ( ) => dispatch => dispatch ( {
type : SEARCH _FOCUS
} ) ;
const doBlurSearchInput = ( ) => dispatch => dispatch ( {
type : SEARCH _BLUR
} ) ;
const doUpdateSearchOptions = newOptions => ( dispatch , getState ) => {
const state = getState ( ) ;
const searchValue = selectSearchValue ( state ) ;
dispatch ( {
type : UPDATE _SEARCH _OPTIONS ,
data : newOptions
} ) ;
if ( searchValue ) {
// After updating, perform a search with the new options
dispatch ( doSearch ( searchValue ) ) ;
}
} ;
function savePosition ( claimId , outpoint , position ) {
return dispatch => {
dispatch ( {
type : SET _CONTENT _POSITION ,
data : { claimId , outpoint , position }
} ) ;
} ;
}
2019-04-23 19:22:14 +02:00
//
2019-04-03 19:12:51 +02:00
2019-06-10 04:45:47 +02:00
const doToggleTagFollow = name => ( {
type : TOGGLE _TAG _FOLLOW ,
data : {
name
}
} ) ;
const doAddTag = name => ( {
type : TAG _ADD ,
data : {
name
}
} ) ;
const doDeleteTag = name => ( {
type : TAG _DELETE ,
data : {
name
}
} ) ;
2019-06-12 03:14:37 +02:00
//
function doCommentList ( uri ) {
return ( dispatch , getState ) => {
const state = getState ( ) ;
const claim = selectClaimsByUri ( state ) [ uri ] ;
const claimId = claim ? claim . claim _id : null ;
dispatch ( {
type : COMMENT _LIST _STARTED
} ) ;
lbryProxy . comment _list ( {
claim _id : claimId
} ) . then ( results => {
dispatch ( {
type : COMMENT _LIST _COMPLETED ,
data : {
comments : results ,
claimId : claimId ,
uri : uri
}
} ) ;
} ) . catch ( error => {
console . log ( error ) ;
2019-06-27 01:13:29 +02:00
dispatch ( {
type : COMMENT _LIST _FAILED ,
data : error
} ) ;
2019-06-12 03:14:37 +02:00
} ) ;
} ;
}
function doCommentCreate ( comment = '' , claim _id = '' , channel , parent _id ) {
return ( dispatch , getState ) => {
const state = getState ( ) ;
dispatch ( {
type : COMMENT _CREATE _STARTED
} ) ;
const myChannels = selectMyChannelClaims ( state ) ;
const namedChannelClaim = myChannels . find ( myChannel => myChannel . name === channel ) ;
const channel _id = namedChannelClaim ? namedChannelClaim . claim _id : null ;
return lbryProxy . comment _create ( {
comment ,
claim _id ,
channel _id
} ) . then ( result => {
dispatch ( {
type : COMMENT _CREATE _COMPLETED ,
data : {
comment : result ,
claimId : claim _id
}
} ) ;
} ) . catch ( error => {
dispatch ( {
type : COMMENT _CREATE _FAILED ,
data : error
} ) ;
dispatch ( doToast ( {
message : 'Oops, someone broke comments.' ,
isError : true
} ) ) ;
} ) ;
} ;
}
2019-08-02 02:57:27 +02:00
//
const doToggleBlockChannel = uri => ( {
type : TOGGLE _BLOCK _CHANNEL ,
data : {
uri
}
} ) ;
2019-07-01 21:49:51 +02:00
var _extends$5 = Object . assign || function ( target ) { for ( var i = 1 ; i < arguments . length ; i ++ ) { var source = arguments [ i ] ; for ( var key in source ) { if ( Object . prototype . hasOwnProperty . call ( source , key ) ) { target [ key ] = source [ key ] ; } } } return target ; } ;
2019-06-10 04:45:47 +02:00
2019-09-20 17:22:21 +02:00
function extractUserState ( rawObj ) {
if ( rawObj && rawObj . version === '0.1' && rawObj . shared ) {
2019-09-13 21:52:52 +02:00
const { subscriptions , tags } = rawObj . shared ;
2019-09-20 17:22:21 +02:00
2019-09-10 20:14:40 +02:00
return _extends$5 ( { } , subscriptions ? { subscriptions } : { } , tags ? { tags } : { } ) ;
}
return { } ;
}
2019-09-20 17:22:21 +02:00
function doPopulateSharedUserState ( settings ) {
2019-09-10 20:14:40 +02:00
return dispatch => {
2019-09-20 17:22:21 +02:00
const { subscriptions , tags } = extractUserState ( settings ) ;
2019-09-13 21:52:52 +02:00
dispatch ( { type : USER _STATE _POPULATE , data : { subscriptions , tags } } ) ;
2019-09-10 20:14:40 +02:00
} ;
}
var _extends$6 = Object . assign || function ( target ) { for ( var i = 1 ; i < arguments . length ; i ++ ) { var source = arguments [ i ] ; for ( var key in source ) { if ( Object . prototype . hasOwnProperty . call ( source , key ) ) { target [ key ] = source [ key ] ; } } } return target ; } ;
2019-04-23 19:22:14 +02:00
const reducers = { } ;
2019-04-03 19:12:51 +02:00
const defaultState = {
2019-04-23 19:22:14 +02:00
byId : { } ,
claimsByUri : { } ,
claimsByChannel : { } ,
channelClaimCounts : { } ,
fetchingChannelClaims : { } ,
resolvingUris : [ ] ,
// This should not be a Set
// Storing sets in reducers can cause issues
2019-09-13 21:52:52 +02:00
myChannelClaims : undefined ,
2019-09-24 21:57:51 +02:00
myClaims : undefined ,
2019-04-23 19:22:14 +02:00
fetchingMyChannels : false ,
abandoningById : { } ,
2019-06-11 20:11:18 +02:00
pendingById : { } ,
2019-07-17 23:34:00 +02:00
claimSearchError : false ,
2019-07-30 17:48:45 +02:00
claimSearchByQuery : { } ,
2019-08-13 17:27:32 +02:00
claimSearchByQueryLastPageReached : { } ,
2019-09-15 13:00:14 +02:00
fetchingClaimSearchByQuery : { } ,
updateChannelError : '' ,
2019-08-27 06:42:52 +02:00
updatingChannel : false ,
2019-09-10 20:14:40 +02:00
creatingChannel : false ,
2019-09-12 21:06:49 +02:00
createChannelError : undefined ,
pendingChannelImport : false
2019-04-03 19:12:51 +02:00
} ;
2019-06-10 04:45:47 +02:00
function handleClaimAction ( state , action ) {
2019-06-06 23:37:36 +02:00
const {
resolveInfo
} = action . data ;
2019-04-03 19:12:51 +02:00
const byUri = Object . assign ( { } , state . claimsByUri ) ;
const byId = Object . assign ( { } , state . byId ) ;
const channelClaimCounts = Object . assign ( { } , state . channelClaimCounts ) ;
2019-09-04 17:57:48 +02:00
let newResolvingUrls = new Set ( state . resolvingUris ) ;
2019-04-03 19:12:51 +02:00
2019-08-20 22:00:26 +02:00
Object . entries ( resolveInfo ) . forEach ( ( [ url , resolveResponse ] ) => {
2019-04-23 19:22:14 +02:00
// $FlowFixMe
2019-08-20 22:00:26 +02:00
const { claimsInChannel , stream , channel } = resolveResponse ;
if ( claimsInChannel ) {
channelClaimCounts [ url ] = claimsInChannel ;
2019-04-03 19:12:51 +02:00
}
2019-06-11 18:22:44 +02:00
if ( stream ) {
2019-06-06 23:37:36 +02:00
byId [ stream . claim _id ] = stream ;
2019-08-20 22:00:26 +02:00
byUri [ url ] = stream . claim _id ;
2019-09-04 17:57:48 +02:00
// Also add the permanent_url here until lighthouse returns canonical_url for search results
byUri [ stream . permanent _url ] = stream . claim _id ;
newResolvingUrls . delete ( stream . canonical _url ) ;
newResolvingUrls . delete ( stream . permanent _url ) ;
}
if ( channel ) {
if ( ! stream ) {
byUri [ url ] = channel . claim _id ;
}
2019-06-06 23:37:36 +02:00
byId [ channel . claim _id ] = channel ;
2019-09-04 17:57:48 +02:00
// Also add the permanent_url here until lighthouse returns canonical_url for search results
byUri [ channel . permanent _url ] = channel . claim _id ;
byUri [ channel . canonical _url ] = channel . claim _id ;
newResolvingUrls . delete ( channel . canonical _url ) ;
newResolvingUrls . delete ( channel . permanent _url ) ;
2019-06-11 18:22:44 +02:00
}
2019-08-20 22:00:26 +02:00
2019-09-04 17:57:48 +02:00
newResolvingUrls . delete ( url ) ;
2019-06-11 18:22:44 +02:00
if ( ! stream && ! channel ) {
2019-08-20 22:00:26 +02:00
byUri [ url ] = null ;
2019-04-03 19:12:51 +02:00
}
} ) ;
return Object . assign ( { } , state , {
byId ,
claimsByUri : byUri ,
channelClaimCounts ,
2019-09-04 17:57:48 +02:00
resolvingUris : Array . from ( newResolvingUrls )
2019-04-03 19:12:51 +02:00
} ) ;
2019-06-10 04:45:47 +02:00
}
2019-09-04 17:57:48 +02:00
reducers [ RESOLVE _URIS _STARTED ] = ( state , action ) => {
const { uris } = action . data ;
const oldResolving = state . resolvingUris || [ ] ;
const newResolving = oldResolving . slice ( ) ;
uris . forEach ( uri => {
if ( ! newResolving . includes ( uri ) ) {
newResolving . push ( uri ) ;
}
} ) ;
return Object . assign ( { } , state , {
resolvingUris : newResolving
} ) ;
} ;
2019-06-10 04:45:47 +02:00
reducers [ RESOLVE _URIS _COMPLETED ] = ( state , action ) => {
2019-09-10 20:14:40 +02:00
return _extends$6 ( { } , handleClaimAction ( state , action ) ) ;
2019-04-03 19:12:51 +02:00
} ;
reducers [ FETCH _CLAIM _LIST _MINE _STARTED ] = state => Object . assign ( { } , state , {
isFetchingClaimListMine : true
} ) ;
reducers [ FETCH _CLAIM _LIST _MINE _COMPLETED ] = ( state , action ) => {
const { claims } = action . data ;
const byId = Object . assign ( { } , state . byId ) ;
const byUri = Object . assign ( { } , state . claimsByUri ) ;
const pendingById = Object . assign ( { } , state . pendingById ) ;
2019-09-24 21:57:51 +02:00
const myClaims = state . myClaims || [ ] ;
2019-04-03 19:12:51 +02:00
claims . forEach ( claim => {
2019-08-29 09:28:04 +02:00
const uri = buildURI ( { streamName : claim . name , streamClaimId : claim . claim _id } ) ;
2019-04-03 19:12:51 +02:00
if ( claim . type && claim . type . match ( /claim|update/ ) ) {
if ( claim . confirmations < 1 ) {
pendingById [ claim . claim _id ] = claim ;
delete byId [ claim . claim _id ] ;
delete byUri [ claim . claim _id ] ;
} else {
byId [ claim . claim _id ] = claim ;
byUri [ uri ] = claim . claim _id ;
}
}
} ) ;
// Remove old pending publishes
2019-04-23 19:22:14 +02:00
Object . values ( pendingById )
// $FlowFixMe
. filter ( pendingClaim => byId [ pendingClaim . claim _id ] ) . forEach ( pendingClaim => {
// $FlowFixMe
2019-04-03 19:12:51 +02:00
delete pendingById [ pendingClaim . claim _id ] ;
} ) ;
return Object . assign ( { } , state , {
isFetchingClaimListMine : false ,
2019-09-24 21:57:51 +02:00
myClaims : concatClaims ( myClaims , claims ) ,
2019-04-03 19:12:51 +02:00
byId ,
claimsByUri : byUri ,
pendingById
} ) ;
} ;
reducers [ FETCH _CHANNEL _LIST _STARTED ] = state => Object . assign ( { } , state , { fetchingMyChannels : true } ) ;
reducers [ FETCH _CHANNEL _LIST _COMPLETED ] = ( state , action ) => {
const { claims } = action . data ;
2019-09-24 21:57:51 +02:00
const myClaims = state . myClaims || [ ] ;
2019-04-03 19:12:51 +02:00
2019-09-13 21:52:52 +02:00
let myChannelClaims ;
let byId = Object . assign ( { } , state . byId ) ;
if ( ! claims . length ) {
// $FlowFixMe
myChannelClaims = null ;
} else {
myChannelClaims = new Set ( state . myChannelClaims ) ;
claims . forEach ( claim => {
// $FlowFixMe
myChannelClaims . add ( claim . claim _id ) ;
byId [ claim . claim _id ] = claim ;
} ) ;
}
2019-04-03 19:12:51 +02:00
return Object . assign ( { } , state , {
byId ,
fetchingMyChannels : false ,
2019-09-15 13:00:14 +02:00
myChannelClaims ,
2019-09-24 21:57:51 +02:00
myClaims : concatClaims ( myClaims , claims )
2019-04-03 19:12:51 +02:00
} ) ;
} ;
reducers [ FETCH _CHANNEL _CLAIMS _STARTED ] = ( state , action ) => {
const { uri , page } = action . data ;
const fetchingChannelClaims = Object . assign ( { } , state . fetchingChannelClaims ) ;
fetchingChannelClaims [ uri ] = page ;
return Object . assign ( { } , state , {
fetchingChannelClaims ,
currentChannelPage : page
} ) ;
} ;
reducers [ FETCH _CHANNEL _CLAIMS _COMPLETED ] = ( state , action ) => {
2019-04-23 19:22:14 +02:00
const {
uri ,
claims ,
page
} = action . data ;
2019-04-03 19:12:51 +02:00
const claimsByChannel = Object . assign ( { } , state . claimsByChannel ) ;
const byChannel = Object . assign ( { } , claimsByChannel [ uri ] ) ;
const allClaimIds = new Set ( byChannel . all ) ;
const currentPageClaimIds = [ ] ;
const byId = Object . assign ( { } , state . byId ) ;
const fetchingChannelClaims = Object . assign ( { } , state . fetchingChannelClaims ) ;
const claimsByUri = Object . assign ( { } , state . claimsByUri ) ;
if ( claims !== undefined ) {
claims . forEach ( claim => {
allClaimIds . add ( claim . claim _id ) ;
currentPageClaimIds . push ( claim . claim _id ) ;
byId [ claim . claim _id ] = claim ;
2019-09-04 17:57:48 +02:00
claimsByUri [ claim . canonical _url ] = claim . claim _id ;
2019-04-03 19:12:51 +02:00
} ) ;
}
byChannel . all = allClaimIds ;
byChannel [ page ] = currentPageClaimIds ;
claimsByChannel [ uri ] = byChannel ;
delete fetchingChannelClaims [ uri ] ;
return Object . assign ( { } , state , {
claimsByChannel ,
byId ,
fetchingChannelClaims ,
claimsByUri ,
currentChannelPage : page
} ) ;
} ;
reducers [ ABANDON _CLAIM _STARTED ] = ( state , action ) => {
const { claimId } = action . data ;
const abandoningById = Object . assign ( { } , state . abandoningById ) ;
abandoningById [ claimId ] = true ;
return Object . assign ( { } , state , {
abandoningById
} ) ;
} ;
reducers [ ABANDON _CLAIM _SUCCEEDED ] = ( state , action ) => {
const { claimId } = action . data ;
const byId = Object . assign ( { } , state . byId ) ;
const claimsByUri = Object . assign ( { } , state . claimsByUri ) ;
Object . keys ( claimsByUri ) . forEach ( uri => {
if ( claimsByUri [ uri ] === claimId ) {
delete claimsByUri [ uri ] ;
}
} ) ;
delete byId [ claimId ] ;
return Object . assign ( { } , state , {
byId ,
claimsByUri
} ) ;
} ;
2019-09-10 20:14:40 +02:00
reducers [ CREATE _CHANNEL _STARTED ] = state => _extends$6 ( { } , state , {
creatingChannel : true ,
createChannelError : null
2019-08-27 06:42:52 +02:00
} ) ;
2019-04-03 19:12:51 +02:00
reducers [ CREATE _CHANNEL _COMPLETED ] = ( state , action ) => {
2019-04-23 19:22:14 +02:00
const channelClaim = action . data . channelClaim ;
2019-04-03 19:12:51 +02:00
const byId = Object . assign ( { } , state . byId ) ;
const myChannelClaims = new Set ( state . myChannelClaims ) ;
byId [ channelClaim . claim _id ] = channelClaim ;
myChannelClaims . add ( channelClaim . claim _id ) ;
return Object . assign ( { } , state , {
byId ,
2019-08-27 06:42:52 +02:00
myChannelClaims ,
creatingChannel : false
2019-04-03 19:12:51 +02:00
} ) ;
} ;
2019-09-10 20:14:40 +02:00
reducers [ CREATE _CHANNEL _FAILED ] = ( state , action ) => {
return Object . assign ( { } , state , {
creatingChannel : false ,
createChannelError : action . data
} ) ;
} ;
2019-04-03 19:12:51 +02:00
2019-09-15 13:00:14 +02:00
reducers [ UPDATE _CHANNEL _STARTED ] = ( state , action ) => {
return Object . assign ( { } , state , {
updateChannelError : '' ,
updatingChannel : true
} ) ;
} ;
2019-07-01 03:16:44 +02:00
reducers [ UPDATE _CHANNEL _COMPLETED ] = ( state , action ) => {
const channelClaim = action . data . channelClaim ;
const byId = Object . assign ( { } , state . byId ) ;
byId [ channelClaim . claim _id ] = channelClaim ;
return Object . assign ( { } , state , {
2019-09-15 13:00:14 +02:00
byId ,
updateChannelError : '' ,
updatingChannel : false
} ) ;
} ;
reducers [ UPDATE _CHANNEL _FAILED ] = ( state , action ) => {
return Object . assign ( { } , state , {
updateChannelError : action . data . message ,
updatingChannel : false
2019-07-01 03:16:44 +02:00
} ) ;
} ;
2019-09-23 17:06:02 +02:00
reducers [ IMPORT _CHANNEL _STARTED ] = state => Object . assign ( { } , state , { pendingChannelImports : true } ) ;
2019-09-12 21:06:49 +02:00
reducers [ IMPORT _CHANNEL _COMPLETED ] = state => Object . assign ( { } , state , { pendingChannelImports : false } ) ;
2019-07-30 17:48:45 +02:00
reducers [ CLAIM _SEARCH _STARTED ] = ( state , action ) => {
const fetchingClaimSearchByQuery = Object . assign ( { } , state . fetchingClaimSearchByQuery ) ;
fetchingClaimSearchByQuery [ action . data . query ] = true ;
2019-06-27 00:01:49 +02:00
2019-06-10 04:45:47 +02:00
return Object . assign ( { } , state , {
2019-07-30 17:48:45 +02:00
fetchingClaimSearchByQuery
2019-06-10 04:45:47 +02:00
} ) ;
} ;
2019-07-30 17:48:45 +02:00
reducers [ CLAIM _SEARCH _COMPLETED ] = ( state , action ) => {
const fetchingClaimSearchByQuery = Object . assign ( { } , state . fetchingClaimSearchByQuery ) ;
const claimSearchByQuery = Object . assign ( { } , state . claimSearchByQuery ) ;
2019-08-13 17:27:32 +02:00
const claimSearchByQueryLastPageReached = Object . assign ( { } , state . claimSearchByQueryLastPageReached ) ;
2019-08-20 22:00:26 +02:00
const { append , query , urls , pageSize } = action . data ;
2019-07-15 04:44:02 +02:00
2019-07-30 17:48:45 +02:00
if ( append ) {
2019-08-20 22:00:26 +02:00
// todo: check for duplicate urls when concatenating?
claimSearchByQuery [ query ] = claimSearchByQuery [ query ] && claimSearchByQuery [ query ] . length ? claimSearchByQuery [ query ] . concat ( urls ) : urls ;
2019-07-16 11:15:51 +02:00
} else {
2019-08-20 22:00:26 +02:00
claimSearchByQuery [ query ] = urls ;
2019-07-16 11:15:51 +02:00
}
2019-07-15 04:44:02 +02:00
2019-08-20 22:00:26 +02:00
// the returned number of urls is less than the page size, so we're on the last page
claimSearchByQueryLastPageReached [ query ] = urls . length < pageSize ;
2019-08-13 17:27:32 +02:00
2019-07-30 17:48:45 +02:00
delete fetchingClaimSearchByQuery [ query ] ;
2019-09-10 20:14:40 +02:00
return Object . assign ( { } , state , _extends$6 ( { } , handleClaimAction ( state , action ) , {
2019-07-30 17:48:45 +02:00
claimSearchByQuery ,
2019-08-13 17:27:32 +02:00
claimSearchByQueryLastPageReached ,
2019-07-30 17:48:45 +02:00
fetchingClaimSearchByQuery
} ) ) ;
2019-07-15 04:44:02 +02:00
} ;
2019-07-30 17:48:45 +02:00
reducers [ CLAIM _SEARCH _FAILED ] = ( state , action ) => {
const fetchingClaimSearchByQuery = Object . assign ( { } , state . fetchingClaimSearchByQuery ) ;
2019-08-13 17:27:32 +02:00
delete fetchingClaimSearchByQuery [ action . data . query ] ;
2019-07-15 04:44:02 +02:00
return Object . assign ( { } , state , {
2019-07-30 17:48:45 +02:00
fetchingClaimSearchByQuery
2019-07-15 04:44:02 +02:00
} ) ;
} ;
2019-04-03 19:12:51 +02:00
function claimsReducer ( state = defaultState , action ) {
const handler = reducers [ action . type ] ;
if ( handler ) return handler ( state , action ) ;
return state ;
}
2019-07-01 21:49:51 +02:00
// util for creating reducers
// based off of redux-actions
// https://redux-actions.js.org/docs/api/handleAction.html#handleactions
2019-04-03 19:12:51 +02:00
2019-07-01 21:49:51 +02:00
// eslint-disable-next-line import/prefer-default-export
const handleActions = ( actionMap , defaultState ) => ( state = defaultState , action ) => {
const handler = actionMap [ action . type ] ;
2019-05-27 15:59:21 +02:00
2019-07-01 21:49:51 +02:00
if ( handler ) {
const newState = handler ( state , action ) ;
return Object . assign ( { } , state , newState ) ;
2019-05-27 15:59:21 +02:00
}
2019-07-01 21:49:51 +02:00
// just return the original state if no handler
// returning a copy here breaks redux-persist
return state ;
2019-05-21 21:18:07 +02:00
} ;
2019-09-10 20:14:40 +02:00
var _extends$7 = Object . assign || function ( target ) { for ( var i = 1 ; i < arguments . length ; i ++ ) { var source = arguments [ i ] ; for ( var key in source ) { if ( Object . prototype . hasOwnProperty . call ( source , key ) ) { target [ key ] = source [ key ] ; } } } return target ; } ;
2019-05-21 21:18:07 +02:00
2019-07-01 21:49:51 +02:00
const defaultState$1 = {
byId : { } ,
commentsByUri : { } ,
isLoading : false
2019-05-21 21:18:07 +02:00
} ;
2019-07-01 21:49:51 +02:00
const commentReducer = handleActions ( {
2019-09-10 20:14:40 +02:00
[ COMMENT _CREATE _STARTED ] : ( state , action ) => _extends$7 ( { } , state , {
2019-07-01 21:49:51 +02:00
isLoading : true
} ) ,
2019-05-27 15:59:21 +02:00
2019-09-10 20:14:40 +02:00
[ COMMENT _CREATE _FAILED ] : ( state , action ) => _extends$7 ( { } , state , {
2019-07-01 21:49:51 +02:00
isLoading : false
} ) ,
2019-05-21 21:18:07 +02:00
2019-07-01 21:49:51 +02:00
[ COMMENT _CREATE _COMPLETED ] : ( state , action ) => {
const { comment , claimId } = action . data ;
const byId = Object . assign ( { } , state . byId ) ;
const comments = byId [ claimId ] ;
const newComments = comments . slice ( ) ;
2019-05-27 15:59:21 +02:00
2019-07-01 21:49:51 +02:00
newComments . unshift ( comment ) ;
byId [ claimId ] = newComments ;
2019-05-27 15:59:21 +02:00
2019-09-10 20:14:40 +02:00
return _extends$7 ( { } , state , {
2019-07-01 21:49:51 +02:00
byId
} ) ;
} ,
2019-09-10 20:14:40 +02:00
[ COMMENT _LIST _STARTED ] : state => _extends$7 ( { } , state , { isLoading : true } ) ,
2019-07-01 21:49:51 +02:00
[ COMMENT _LIST _COMPLETED ] : ( state , action ) => {
const { comments , claimId , uri } = action . data ;
const byId = Object . assign ( { } , state . byId ) ;
const commentsByUri = Object . assign ( { } , state . commentsByUri ) ;
if ( comments [ 'items' ] ) {
byId [ claimId ] = comments [ 'items' ] ;
commentsByUri [ uri ] = claimId ;
}
2019-09-10 20:14:40 +02:00
return _extends$7 ( { } , state , {
2019-07-01 21:49:51 +02:00
byId ,
commentsByUri ,
isLoading : false
} ) ;
} ,
2019-09-10 20:14:40 +02:00
[ COMMENT _LIST _FAILED ] : ( state , action ) => _extends$7 ( { } , state , {
2019-07-01 21:49:51 +02:00
isLoading : false
} )
} , defaultState$1 ) ;
2019-09-10 20:14:40 +02:00
var _extends$8 = Object . assign || function ( target ) { for ( var i = 1 ; i < arguments . length ; i ++ ) { var source = arguments [ i ] ; for ( var key in source ) { if ( Object . prototype . hasOwnProperty . call ( source , key ) ) { target [ key ] = source [ key ] ; } } } return target ; } ;
2019-07-01 21:49:51 +02:00
const reducers$1 = { } ;
const defaultState$2 = {
positions : { }
} ;
reducers$1 [ SET _CONTENT _POSITION ] = ( state , action ) => {
const { claimId , outpoint , position } = action . data ;
2019-09-10 20:14:40 +02:00
return _extends$8 ( { } , state , {
positions : _extends$8 ( { } , state . positions , {
[ claimId ] : _extends$8 ( { } , state . positions [ claimId ] , {
2019-07-01 21:49:51 +02:00
[ outpoint ] : position
} )
} )
2019-05-21 21:18:07 +02:00
} ) ;
} ;
2019-07-01 21:49:51 +02:00
function contentReducer ( state = defaultState$2 , action ) {
2019-05-21 21:18:07 +02:00
const handler = reducers$1 [ action . type ] ;
if ( handler ) return handler ( state , action ) ;
return state ;
}
const reducers$2 = { } ;
2019-07-01 21:49:51 +02:00
const defaultState$3 = {
2019-04-03 19:12:51 +02:00
fileListPublishedSort : DATE _NEW ,
fileListDownloadedSort : DATE _NEW
} ;
2019-05-21 21:18:07 +02:00
reducers$2 [ FILE _LIST _STARTED ] = state => Object . assign ( { } , state , {
2019-04-03 19:12:51 +02:00
isFetchingFileList : true
} ) ;
2019-05-21 21:18:07 +02:00
reducers$2 [ FILE _LIST _SUCCEEDED ] = ( state , action ) => {
2019-04-03 19:12:51 +02:00
const { fileInfos } = action . data ;
const newByOutpoint = Object . assign ( { } , state . byOutpoint ) ;
const pendingByOutpoint = Object . assign ( { } , state . pendingByOutpoint ) ;
fileInfos . forEach ( fileInfo => {
const { outpoint } = fileInfo ;
if ( outpoint ) newByOutpoint [ fileInfo . outpoint ] = fileInfo ;
} ) ;
return Object . assign ( { } , state , {
isFetchingFileList : false ,
byOutpoint : newByOutpoint ,
pendingByOutpoint
} ) ;
} ;
2019-05-21 21:18:07 +02:00
reducers$2 [ FETCH _FILE _INFO _STARTED ] = ( state , action ) => {
2019-04-03 19:12:51 +02:00
const { outpoint } = action . data ;
const newFetching = Object . assign ( { } , state . fetching ) ;
newFetching [ outpoint ] = true ;
return Object . assign ( { } , state , {
fetching : newFetching
} ) ;
} ;
2019-05-21 21:18:07 +02:00
reducers$2 [ FETCH _FILE _INFO _COMPLETED ] = ( state , action ) => {
2019-04-03 19:12:51 +02:00
const { fileInfo , outpoint } = action . data ;
const newByOutpoint = Object . assign ( { } , state . byOutpoint ) ;
const newFetching = Object . assign ( { } , state . fetching ) ;
newByOutpoint [ outpoint ] = fileInfo ;
delete newFetching [ outpoint ] ;
return Object . assign ( { } , state , {
byOutpoint : newByOutpoint ,
fetching : newFetching
} ) ;
} ;
2019-08-13 19:33:32 +02:00
reducers$2 [ FETCH _FILE _INFO _FAILED ] = ( state , action ) => {
const { outpoint } = action . data ;
const newFetching = Object . assign ( { } , state . fetching ) ;
delete newFetching [ outpoint ] ;
return Object . assign ( { } , state , {
fetching : newFetching
} ) ;
} ;
2019-05-21 21:18:07 +02:00
reducers$2 [ DOWNLOADING _STARTED ] = ( state , action ) => {
2019-04-03 19:12:51 +02:00
const { uri , outpoint , fileInfo } = action . data ;
const newByOutpoint = Object . assign ( { } , state . byOutpoint ) ;
const newDownloading = Object . assign ( { } , state . downloadingByOutpoint ) ;
newDownloading [ outpoint ] = true ;
newByOutpoint [ outpoint ] = fileInfo ;
return Object . assign ( { } , state , {
downloadingByOutpoint : newDownloading ,
byOutpoint : newByOutpoint
} ) ;
} ;
2019-05-21 21:18:07 +02:00
reducers$2 [ DOWNLOADING _PROGRESSED ] = ( state , action ) => {
2019-04-03 19:12:51 +02:00
const { outpoint , fileInfo } = action . data ;
const newByOutpoint = Object . assign ( { } , state . byOutpoint ) ;
const newDownloading = Object . assign ( { } , state . downloadingByOutpoint ) ;
newByOutpoint [ outpoint ] = fileInfo ;
newDownloading [ outpoint ] = true ;
return Object . assign ( { } , state , {
byOutpoint : newByOutpoint ,
downloadingByOutpoint : newDownloading
} ) ;
} ;
2019-05-21 21:18:07 +02:00
reducers$2 [ DOWNLOADING _CANCELED ] = ( state , action ) => {
2019-08-02 08:21:28 +02:00
const { uri , outpoint } = action . data ;
2019-04-03 19:12:51 +02:00
const newDownloading = Object . assign ( { } , state . downloadingByOutpoint ) ;
delete newDownloading [ outpoint ] ;
return Object . assign ( { } , state , {
downloadingByOutpoint : newDownloading
} ) ;
} ;
2019-05-21 21:18:07 +02:00
reducers$2 [ DOWNLOADING _COMPLETED ] = ( state , action ) => {
2019-04-03 19:12:51 +02:00
const { outpoint , fileInfo } = action . data ;
const newByOutpoint = Object . assign ( { } , state . byOutpoint ) ;
const newDownloading = Object . assign ( { } , state . downloadingByOutpoint ) ;
newByOutpoint [ outpoint ] = fileInfo ;
delete newDownloading [ outpoint ] ;
return Object . assign ( { } , state , {
byOutpoint : newByOutpoint ,
downloadingByOutpoint : newDownloading
} ) ;
} ;
2019-05-21 21:18:07 +02:00
reducers$2 [ FILE _DELETE ] = ( state , action ) => {
2019-04-03 19:12:51 +02:00
const { outpoint } = action . data ;
const newByOutpoint = Object . assign ( { } , state . byOutpoint ) ;
const downloadingByOutpoint = Object . assign ( { } , state . downloadingByOutpoint ) ;
delete newByOutpoint [ outpoint ] ;
delete downloadingByOutpoint [ outpoint ] ;
return Object . assign ( { } , state , {
byOutpoint : newByOutpoint ,
downloadingByOutpoint
} ) ;
} ;
2019-05-21 21:18:07 +02:00
reducers$2 [ SET _FILE _LIST _SORT ] = ( state , action ) => {
2019-04-03 19:12:51 +02:00
const pageSortStates = {
[ PUBLISHED ] : 'fileListPublishedSort' ,
[ DOWNLOADED ] : 'fileListDownloadedSort'
} ;
const pageSortState = pageSortStates [ action . data . page ] ;
const { value } = action . data ;
return Object . assign ( { } , state , {
[ pageSortState ] : value
} ) ;
} ;
2019-07-01 21:49:51 +02:00
function fileInfoReducer ( state = defaultState$3 , action ) {
2019-05-21 21:18:07 +02:00
const handler = reducers$2 [ action . type ] ;
2019-04-03 19:12:51 +02:00
if ( handler ) return handler ( state , action ) ;
return state ;
}
2019-09-10 20:14:40 +02:00
var _extends$9 = Object . assign || function ( target ) { for ( var i = 1 ; i < arguments . length ; i ++ ) { var source = arguments [ i ] ; for ( var key in source ) { if ( Object . prototype . hasOwnProperty . call ( source , key ) ) { target [ key ] = source [ key ] ; } } } return target ; } ;
2019-04-03 19:12:51 +02:00
2019-07-01 21:49:51 +02:00
const reducers$3 = { } ;
const defaultState$4 = {
failedPurchaseUris : [ ] ,
purchasedUris : [ ] ,
purchaseUriErrorMessage : ''
} ;
2019-04-03 19:12:51 +02:00
2019-07-01 21:49:51 +02:00
reducers$3 [ PURCHASE _URI _STARTED ] = ( state , action ) => {
const { uri } = action . data ;
const newFailedPurchaseUris = state . failedPurchaseUris . slice ( ) ;
if ( newFailedPurchaseUris . includes ( uri ) ) {
newFailedPurchaseUris . splice ( newFailedPurchaseUris . indexOf ( uri ) , 1 ) ;
2019-04-03 19:12:51 +02:00
}
2019-09-10 20:14:40 +02:00
return _extends$9 ( { } , state , {
2019-07-01 21:49:51 +02:00
failedPurchaseUris : newFailedPurchaseUris ,
purchaseUriErrorMessage : ''
} ) ;
2019-04-03 19:12:51 +02:00
} ;
2019-07-01 21:49:51 +02:00
reducers$3 [ PURCHASE _URI _COMPLETED ] = ( state , action ) => {
2019-08-06 04:52:46 +02:00
const { uri } = action . data ;
2019-07-01 21:49:51 +02:00
const newPurchasedUris = state . purchasedUris . slice ( ) ;
const newFailedPurchaseUris = state . failedPurchaseUris . slice ( ) ;
2019-04-03 19:12:51 +02:00
2019-07-01 21:49:51 +02:00
if ( ! newPurchasedUris . includes ( uri ) ) {
newPurchasedUris . push ( uri ) ;
}
if ( newFailedPurchaseUris . includes ( uri ) ) {
newFailedPurchaseUris . splice ( newFailedPurchaseUris . indexOf ( uri ) , 1 ) ;
}
2019-09-10 20:14:40 +02:00
return _extends$9 ( { } , state , {
2019-07-01 21:49:51 +02:00
failedPurchaseUris : newFailedPurchaseUris ,
purchasedUris : newPurchasedUris ,
purchaseUriErrorMessage : ''
} ) ;
} ;
reducers$3 [ PURCHASE _URI _FAILED ] = ( state , action ) => {
const { uri , error } = action . data ;
const newFailedPurchaseUris = state . failedPurchaseUris . slice ( ) ;
if ( ! newFailedPurchaseUris . includes ( uri ) ) {
newFailedPurchaseUris . push ( uri ) ;
}
2019-09-10 20:14:40 +02:00
return _extends$9 ( { } , state , {
2019-07-01 21:49:51 +02:00
failedPurchaseUris : newFailedPurchaseUris ,
purchaseUriErrorMessage : error
} ) ;
} ;
reducers$3 [ DELETE _PURCHASED _URI ] = ( state , action ) => {
const { uri } = action . data ;
const newPurchasedUris = state . purchasedUris . slice ( ) ;
if ( newPurchasedUris . includes ( uri ) ) {
newPurchasedUris . splice ( newPurchasedUris . indexOf ( uri ) , 1 ) ;
}
2019-09-10 20:14:40 +02:00
return _extends$9 ( { } , state , {
2019-07-01 21:49:51 +02:00
purchasedUris : newPurchasedUris
} ) ;
} ;
function fileReducer ( state = defaultState$4 , action ) {
const handler = reducers$3 [ action . type ] ;
if ( handler ) return handler ( state , action ) ;
return state ;
}
2019-09-10 20:14:40 +02:00
var _extends$a = Object . assign || function ( target ) { for ( var i = 1 ; i < arguments . length ; i ++ ) { var source = arguments [ i ] ; for ( var key in source ) { if ( Object . prototype . hasOwnProperty . call ( source , key ) ) { target [ key ] = source [ key ] ; } } } return target ; } ;
2019-07-01 21:49:51 +02:00
const defaultState$5 = {
2019-04-03 19:12:51 +02:00
notifications : [ ] ,
toasts : [ ] ,
errors : [ ]
} ;
const notificationsReducer = handleActions ( {
// Toasts
[ CREATE _TOAST ] : ( state , action ) => {
const toast = action . data ;
const newToasts = state . toasts . slice ( ) ;
newToasts . push ( toast ) ;
2019-09-10 20:14:40 +02:00
return _extends$a ( { } , state , {
2019-04-03 19:12:51 +02:00
toasts : newToasts
} ) ;
} ,
[ DISMISS _TOAST ] : state => {
const newToasts = state . toasts . slice ( ) ;
newToasts . shift ( ) ;
2019-09-10 20:14:40 +02:00
return _extends$a ( { } , state , {
2019-04-03 19:12:51 +02:00
toasts : newToasts
} ) ;
} ,
// Notifications
[ CREATE _NOTIFICATION ] : ( state , action ) => {
const notification = action . data ;
const newNotifications = state . notifications . slice ( ) ;
newNotifications . push ( notification ) ;
2019-09-10 20:14:40 +02:00
return _extends$a ( { } , state , {
2019-04-03 19:12:51 +02:00
notifications : newNotifications
} ) ;
} ,
// Used to mark notifications as read/dismissed
[ EDIT _NOTIFICATION ] : ( state , action ) => {
const { notification } = action . data ;
let notifications = state . notifications . slice ( ) ;
notifications = notifications . map ( pastNotification => pastNotification . id === notification . id ? notification : pastNotification ) ;
2019-09-10 20:14:40 +02:00
return _extends$a ( { } , state , {
2019-04-03 19:12:51 +02:00
notifications
} ) ;
} ,
[ DELETE _NOTIFICATION ] : ( state , action ) => {
const { id } = action . data ;
let newNotifications = state . notifications . slice ( ) ;
newNotifications = newNotifications . filter ( notification => notification . id !== id ) ;
2019-09-10 20:14:40 +02:00
return _extends$a ( { } , state , {
2019-04-03 19:12:51 +02:00
notifications : newNotifications
} ) ;
} ,
// Errors
[ CREATE _ERROR ] : ( state , action ) => {
const error = action . data ;
const newErrors = state . errors . slice ( ) ;
newErrors . push ( error ) ;
2019-09-10 20:14:40 +02:00
return _extends$a ( { } , state , {
2019-04-03 19:12:51 +02:00
errors : newErrors
} ) ;
} ,
[ DISMISS _ERROR ] : state => {
const newErrors = state . errors . slice ( ) ;
newErrors . shift ( ) ;
2019-09-10 20:14:40 +02:00
return _extends$a ( { } , state , {
2019-04-03 19:12:51 +02:00
errors : newErrors
} ) ;
}
2019-07-01 21:49:51 +02:00
} , defaultState$5 ) ;
2019-09-10 20:14:40 +02:00
var _extends$b = Object . assign || function ( target ) { for ( var i = 1 ; i < arguments . length ; i ++ ) { var source = arguments [ i ] ; for ( var key in source ) { if ( Object . prototype . hasOwnProperty . call ( source , key ) ) { target [ key ] = source [ key ] ; } } } return target ; } ;
2019-07-01 21:49:51 +02:00
2019-08-20 22:00:26 +02:00
function _objectWithoutProperties$3 ( obj , keys ) { var target = { } ; for ( var i in obj ) { if ( keys . indexOf ( i ) >= 0 ) continue ; if ( ! Object . prototype . hasOwnProperty . call ( obj , i ) ) continue ; target [ i ] = obj [ i ] ; } return target ; }
2019-07-01 21:49:51 +02:00
const defaultState$6 = {
editingURI : undefined ,
filePath : undefined ,
contentIsFree : true ,
fee : {
amount : 1 ,
currency : 'LBC'
} ,
title : '' ,
thumbnail _url : '' ,
thumbnailPath : '' ,
uploadThumbnailStatus : API _DOWN ,
description : '' ,
language : 'en' ,
nsfw : false ,
channel : CHANNEL _ANONYMOUS ,
channelId : '' ,
name : '' ,
nameError : undefined ,
bid : 0.1 ,
bidError : undefined ,
licenseType : 'None' ,
otherLicenseDescription : 'All rights reserved' ,
licenseUrl : '' ,
2019-07-05 04:20:56 +02:00
tags : [ ] ,
2019-07-01 21:49:51 +02:00
publishing : false ,
publishSuccess : false ,
publishError : undefined
} ;
const publishReducer = handleActions ( {
[ UPDATE _PUBLISH _FORM ] : ( state , action ) => {
const { data } = action ;
2019-09-10 20:14:40 +02:00
return _extends$b ( { } , state , data ) ;
2019-07-01 21:49:51 +02:00
} ,
2019-09-10 20:14:40 +02:00
[ CLEAR _PUBLISH ] : ( ) => _extends$b ( { } , defaultState$6 ) ,
[ PUBLISH _START ] : state => _extends$b ( { } , state , {
2019-07-01 21:49:51 +02:00
publishing : true ,
publishSuccess : false
} ) ,
2019-09-10 20:14:40 +02:00
[ PUBLISH _FAIL ] : state => _extends$b ( { } , state , {
2019-07-01 21:49:51 +02:00
publishing : false
} ) ,
2019-09-10 20:14:40 +02:00
[ PUBLISH _SUCCESS ] : state => _extends$b ( { } , state , {
2019-07-01 21:49:51 +02:00
publishing : false ,
publishSuccess : true
} ) ,
[ DO _PREPARE _EDIT ] : ( state , action ) => {
2019-08-20 22:00:26 +02:00
const publishData = _objectWithoutProperties$3 ( action . data , [ ] ) ;
2019-07-01 21:49:51 +02:00
const { channel , name , uri } = publishData ;
// The short uri is what is presented to the user
// The editingUri is the full uri with claim id
const shortUri = buildURI ( {
channelName : channel ,
2019-08-28 01:59:04 +02:00
streamName : name
2019-07-01 21:49:51 +02:00
} ) ;
2019-09-10 20:14:40 +02:00
return _extends$b ( { } , defaultState$6 , publishData , {
2019-07-01 21:49:51 +02:00
editingURI : uri ,
uri : shortUri
} ) ;
}
} , defaultState$6 ) ;
2019-04-03 19:12:51 +02:00
2019-09-10 20:14:40 +02:00
var _extends$c = Object . assign || function ( target ) { for ( var i = 1 ; i < arguments . length ; i ++ ) { var source = arguments [ i ] ; for ( var key in source ) { if ( Object . prototype . hasOwnProperty . call ( source , key ) ) { target [ key ] = source [ key ] ; } } } return target ; } ;
2019-04-03 19:12:51 +02:00
2019-07-01 21:49:51 +02:00
const defaultState$7 = {
2019-04-03 19:12:51 +02:00
isActive : false , // does the user have any typed text in the search input
focused : false , // is the search input focused
searchQuery : '' , // needs to be an empty string for input focusing
options : {
[ SEARCH _OPTIONS . RESULT _COUNT ] : 30 ,
[ SEARCH _OPTIONS . CLAIM _TYPE ] : SEARCH _OPTIONS . INCLUDE _FILES _AND _CHANNELS ,
[ SEARCH _OPTIONS . MEDIA _AUDIO ] : true ,
[ SEARCH _OPTIONS . MEDIA _VIDEO ] : true ,
[ SEARCH _OPTIONS . MEDIA _TEXT ] : true ,
[ SEARCH _OPTIONS . MEDIA _IMAGE ] : true ,
[ SEARCH _OPTIONS . MEDIA _APPLICATION ] : true
} ,
suggestions : { } ,
urisByQuery : { }
} ;
const searchReducer = handleActions ( {
2019-09-10 20:14:40 +02:00
[ SEARCH _START ] : state => _extends$c ( { } , state , {
2019-04-03 19:12:51 +02:00
searching : true
} ) ,
[ SEARCH _SUCCESS ] : ( state , action ) => {
const { query , uris } = action . data ;
2019-09-10 20:14:40 +02:00
return _extends$c ( { } , state , {
2019-04-03 19:12:51 +02:00
searching : false ,
urisByQuery : Object . assign ( { } , state . urisByQuery , { [ query ] : uris } )
} ) ;
} ,
2019-09-10 20:14:40 +02:00
[ SEARCH _FAIL ] : state => _extends$c ( { } , state , {
2019-04-03 19:12:51 +02:00
searching : false
} ) ,
2019-09-10 20:14:40 +02:00
[ UPDATE _SEARCH _QUERY ] : ( state , action ) => _extends$c ( { } , state , {
2019-04-03 19:12:51 +02:00
searchQuery : action . data . query ,
isActive : true
} ) ,
2019-09-10 20:14:40 +02:00
[ UPDATE _SEARCH _SUGGESTIONS ] : ( state , action ) => _extends$c ( { } , state , {
suggestions : _extends$c ( { } , state . suggestions , {
2019-04-03 19:12:51 +02:00
[ action . data . query ] : action . data . suggestions
} )
} ) ,
// sets isActive to false so the uri will be populated correctly if the
// user is on a file page. The search query will still be present on any
// other page
2019-09-10 20:14:40 +02:00
[ DISMISS _NOTIFICATION ] : state => _extends$c ( { } , state , {
2019-04-03 19:12:51 +02:00
isActive : false
} ) ,
2019-09-10 20:14:40 +02:00
[ SEARCH _FOCUS ] : state => _extends$c ( { } , state , {
2019-04-03 19:12:51 +02:00
focused : true
} ) ,
2019-09-10 20:14:40 +02:00
[ SEARCH _BLUR ] : state => _extends$c ( { } , state , {
2019-04-03 19:12:51 +02:00
focused : false
} ) ,
[ UPDATE _SEARCH _OPTIONS ] : ( state , action ) => {
const { options : oldOptions } = state ;
const newOptions = action . data ;
2019-09-10 20:14:40 +02:00
const options = _extends$c ( { } , oldOptions , newOptions ) ;
return _extends$c ( { } , state , {
2019-04-03 19:12:51 +02:00
options
} ) ;
}
2019-07-01 21:49:51 +02:00
} , defaultState$7 ) ;
2019-09-10 20:14:40 +02:00
var _extends$d = Object . assign || function ( target ) { for ( var i = 1 ; i < arguments . length ; i ++ ) { var source = arguments [ i ] ; for ( var key in source ) { if ( Object . prototype . hasOwnProperty . call ( source , key ) ) { target [ key ] = source [ key ] ; } } } return target ; } ;
2019-07-01 21:49:51 +02:00
2019-07-02 22:33:57 +02:00
function getDefaultKnownTags ( ) {
2019-09-10 20:14:40 +02:00
return DEFAULT _FOLLOWED _TAGS . concat ( DEFAULT _KNOWN _TAGS ) . reduce ( ( tagsMap , tag ) => _extends$d ( { } , tagsMap , {
2019-07-02 22:33:57 +02:00
[ tag ] : { name : tag }
} ) , { } ) ;
}
const defaultState$8 = {
2019-09-10 21:44:16 +02:00
followedTags : [ ] ,
2019-07-02 22:33:57 +02:00
knownTags : getDefaultKnownTags ( )
} ;
const tagsReducer = handleActions ( {
2019-07-01 21:49:51 +02:00
[ TOGGLE _TAG _FOLLOW ] : ( state , action ) => {
const { followedTags } = state ;
const { name } = action . data ;
let newFollowedTags = followedTags . slice ( ) ;
if ( newFollowedTags . includes ( name ) ) {
newFollowedTags = newFollowedTags . filter ( tag => tag !== name ) ;
} else {
newFollowedTags . push ( name ) ;
}
2019-09-10 20:14:40 +02:00
return _extends$d ( { } , state , {
2019-07-01 21:49:51 +02:00
followedTags : newFollowedTags
} ) ;
} ,
[ TAG _ADD ] : ( state , action ) => {
const { knownTags } = state ;
const { name } = action . data ;
2019-09-10 20:14:40 +02:00
let newKnownTags = _extends$d ( { } , knownTags ) ;
2019-07-01 21:49:51 +02:00
newKnownTags [ name ] = { name } ;
2019-09-10 20:14:40 +02:00
return _extends$d ( { } , state , {
2019-07-01 21:49:51 +02:00
knownTags : newKnownTags
} ) ;
} ,
[ TAG _DELETE ] : ( state , action ) => {
const { knownTags , followedTags } = state ;
const { name } = action . data ;
2019-09-10 20:14:40 +02:00
let newKnownTags = _extends$d ( { } , knownTags ) ;
2019-07-01 21:49:51 +02:00
delete newKnownTags [ name ] ;
const newFollowedTags = followedTags . filter ( tag => tag !== name ) ;
2019-09-10 20:14:40 +02:00
return _extends$d ( { } , state , {
2019-07-01 21:49:51 +02:00
knownTags : newKnownTags ,
followedTags : newFollowedTags
} ) ;
2019-09-09 20:57:56 +02:00
} ,
2019-09-13 21:52:52 +02:00
[ USER _STATE _POPULATE ] : ( state , action ) => {
2019-09-10 20:14:40 +02:00
const { tags } = action . data ;
return _extends$d ( { } , state , {
2019-09-20 17:22:21 +02:00
followedTags : tags && tags . length ? tags : DEFAULT _FOLLOWED _TAGS
2019-09-10 20:14:40 +02:00
} ) ;
2019-07-01 21:49:51 +02:00
}
2019-07-02 22:33:57 +02:00
} , defaultState$8 ) ;
2019-04-03 19:12:51 +02:00
2019-08-02 02:57:27 +02:00
//
const defaultState$9 = {
blockedChannels : [ ]
} ;
2019-08-02 16:56:32 +02:00
const blockedReducer = handleActions ( {
2019-08-02 02:57:27 +02:00
[ TOGGLE _BLOCK _CHANNEL ] : ( state , action ) => {
const { blockedChannels } = state ;
const { uri } = action . data ;
let newBlockedChannels = blockedChannels . slice ( ) ;
if ( newBlockedChannels . includes ( uri ) ) {
newBlockedChannels = newBlockedChannels . filter ( id => id !== uri ) ;
} else {
newBlockedChannels . push ( uri ) ;
}
return {
blockedChannels : newBlockedChannels
} ;
}
} , defaultState$9 ) ;
2019-09-10 20:14:40 +02:00
var _extends$e = Object . assign || function ( target ) { for ( var i = 1 ; i < arguments . length ; i ++ ) { var source = arguments [ i ] ; for ( var key in source ) { if ( Object . prototype . hasOwnProperty . call ( source , key ) ) { target [ key ] = source [ key ] ; } } } return target ; } ;
2019-04-03 19:12:51 +02:00
const buildDraftTransaction = ( ) => ( {
amount : undefined ,
address : undefined
} ) ;
// TODO: Split into common success and failure types
// See details in https://github.com/lbryio/lbry/issues/1307
2019-08-02 02:57:27 +02:00
const defaultState$a = {
2019-04-03 19:12:51 +02:00
balance : undefined ,
2019-04-18 09:56:16 +02:00
totalBalance : undefined ,
2019-09-24 00:56:53 +02:00
reservedBalance : undefined ,
claimsBalance : undefined ,
supportsBalance : undefined ,
tipsBalance : undefined ,
2019-04-03 19:12:51 +02:00
latestBlock : undefined ,
transactions : { } ,
fetchingTransactions : false ,
2019-05-10 07:02:03 +02:00
supports : { } ,
fetchingSupports : false ,
2019-05-14 06:50:21 +02:00
abandoningSupportsByOutpoint : { } ,
2019-04-03 19:12:51 +02:00
gettingNewAddress : false ,
draftTransaction : buildDraftTransaction ( ) ,
sendingSupport : false ,
walletIsEncrypted : false ,
walletEncryptPending : false ,
walletEncryptSucceded : null ,
walletEncryptResult : null ,
walletDecryptPending : false ,
walletDecryptSucceded : null ,
walletDecryptResult : null ,
walletUnlockPending : false ,
walletUnlockSucceded : null ,
walletUnlockResult : null ,
walletLockPending : false ,
walletLockSucceded : null ,
walletLockResult : null ,
transactionListFilter : 'all'
} ;
2019-05-10 07:02:03 +02:00
const walletReducer = handleActions ( {
2019-09-10 20:14:40 +02:00
[ FETCH _TRANSACTIONS _STARTED ] : state => _extends$e ( { } , state , {
2019-05-10 07:02:03 +02:00
fetchingTransactions : true
} ) ,
2019-04-03 19:12:51 +02:00
2019-05-10 07:02:03 +02:00
[ FETCH _TRANSACTIONS _COMPLETED ] : ( state , action ) => {
2019-09-10 20:14:40 +02:00
const byId = _extends$e ( { } , state . transactions ) ;
2019-04-03 19:12:51 +02:00
2019-05-10 07:02:03 +02:00
const { transactions } = action . data ;
transactions . forEach ( transaction => {
byId [ transaction . txid ] = transaction ;
} ) ;
2019-04-03 19:12:51 +02:00
2019-09-10 20:14:40 +02:00
return _extends$e ( { } , state , {
2019-05-10 07:02:03 +02:00
transactions : byId ,
fetchingTransactions : false
} ) ;
} ,
2019-04-03 19:12:51 +02:00
2019-09-10 20:14:40 +02:00
[ FETCH _SUPPORTS _STARTED ] : state => _extends$e ( { } , state , {
2019-05-10 07:02:03 +02:00
fetchingSupports : true
} ) ,
2019-04-03 19:12:51 +02:00
2019-05-10 07:02:03 +02:00
[ FETCH _SUPPORTS _COMPLETED ] : ( state , action ) => {
2019-05-14 06:50:21 +02:00
const byOutpoint = state . supports ;
2019-05-10 07:02:03 +02:00
const { supports } = action . data ;
2019-04-03 19:12:51 +02:00
2019-05-14 06:50:21 +02:00
supports . forEach ( transaction => {
const { txid , nout } = transaction ;
byOutpoint [ ` ${ txid } : ${ nout } ` ] = transaction ;
2019-05-10 07:02:03 +02:00
} ) ;
2019-04-03 19:12:51 +02:00
2019-09-10 20:14:40 +02:00
return _extends$e ( { } , state , { supports : byOutpoint , fetchingSupports : false } ) ;
2019-05-10 07:02:03 +02:00
} ,
2019-04-03 19:12:51 +02:00
2019-05-10 07:02:03 +02:00
[ ABANDON _SUPPORT _STARTED ] : ( state , action ) => {
2019-05-14 06:50:21 +02:00
const { outpoint } = action . data ;
const currentlyAbandoning = state . abandoningSupportsByOutpoint ;
2019-04-03 19:12:51 +02:00
2019-05-14 06:50:21 +02:00
currentlyAbandoning [ outpoint ] = true ;
2019-04-18 09:56:16 +02:00
2019-09-10 20:14:40 +02:00
return _extends$e ( { } , state , {
2019-05-14 06:50:21 +02:00
abandoningSupportsByOutpoint : currentlyAbandoning
2019-05-10 07:02:03 +02:00
} ) ;
} ,
2019-04-03 19:12:51 +02:00
2019-05-10 07:02:03 +02:00
[ ABANDON _SUPPORT _COMPLETED ] : ( state , action ) => {
2019-05-14 06:50:21 +02:00
const { outpoint } = action . data ;
const byOutpoint = state . supports ;
const currentlyAbandoning = state . abandoningSupportsByOutpoint ;
2019-04-03 19:12:51 +02:00
2019-05-14 06:50:21 +02:00
delete currentlyAbandoning [ outpoint ] ;
delete byOutpoint [ outpoint ] ;
2019-04-03 19:12:51 +02:00
2019-09-10 20:14:40 +02:00
return _extends$e ( { } , state , {
2019-05-14 06:50:21 +02:00
supports : byOutpoint ,
abandoningSupportsById : currentlyAbandoning
2019-05-10 07:02:03 +02:00
} ) ;
} ,
2019-04-03 19:12:51 +02:00
2019-09-10 20:14:40 +02:00
[ GET _NEW _ADDRESS _STARTED ] : state => _extends$e ( { } , state , {
2019-05-10 07:02:03 +02:00
gettingNewAddress : true
} ) ,
2019-04-03 19:12:51 +02:00
2019-05-10 07:02:03 +02:00
[ GET _NEW _ADDRESS _COMPLETED ] : ( state , action ) => {
const { address } = action . data ;
2019-04-03 19:12:51 +02:00
2019-09-10 20:14:40 +02:00
return _extends$e ( { } , state , { gettingNewAddress : false , receiveAddress : address } ) ;
2019-05-10 07:02:03 +02:00
} ,
2019-04-03 19:12:51 +02:00
2019-09-10 20:14:40 +02:00
[ UPDATE _BALANCE ] : ( state , action ) => _extends$e ( { } , state , {
2019-09-24 00:56:53 +02:00
totalBalance : action . data . totalBalance ,
balance : action . data . balance ,
reservedBalance : action . data . reservedBalance ,
claimsBalance : action . data . claimsBalance ,
supportsBalance : action . data . supportsBalance ,
tipsBalance : action . data . tipsBalance
2019-05-10 07:02:03 +02:00
} ) ,
2019-04-03 19:12:51 +02:00
2019-09-10 20:14:40 +02:00
[ CHECK _ADDRESS _IS _MINE _STARTED ] : state => _extends$e ( { } , state , {
2019-05-10 07:02:03 +02:00
checkingAddressOwnership : true
} ) ,
2019-04-03 19:12:51 +02:00
2019-09-10 20:14:40 +02:00
[ CHECK _ADDRESS _IS _MINE _COMPLETED ] : state => _extends$e ( { } , state , {
2019-05-10 07:02:03 +02:00
checkingAddressOwnership : false
} ) ,
2019-04-03 19:12:51 +02:00
2019-05-10 07:02:03 +02:00
[ SET _DRAFT _TRANSACTION _AMOUNT ] : ( state , action ) => {
const oldDraft = state . draftTransaction ;
2019-09-10 20:14:40 +02:00
const newDraft = _extends$e ( { } , oldDraft , { amount : parseFloat ( action . data . amount ) } ) ;
2019-04-03 19:12:51 +02:00
2019-09-10 20:14:40 +02:00
return _extends$e ( { } , state , { draftTransaction : newDraft } ) ;
2019-05-10 07:02:03 +02:00
} ,
2019-04-03 19:12:51 +02:00
2019-05-10 07:02:03 +02:00
[ SET _DRAFT _TRANSACTION _ADDRESS ] : ( state , action ) => {
const oldDraft = state . draftTransaction ;
2019-09-10 20:14:40 +02:00
const newDraft = _extends$e ( { } , oldDraft , { address : action . data . address } ) ;
2019-04-03 19:12:51 +02:00
2019-09-10 20:14:40 +02:00
return _extends$e ( { } , state , { draftTransaction : newDraft } ) ;
2019-05-10 07:02:03 +02:00
} ,
2019-04-03 19:12:51 +02:00
2019-05-10 07:02:03 +02:00
[ SEND _TRANSACTION _STARTED ] : state => {
2019-09-10 20:14:40 +02:00
const newDraftTransaction = _extends$e ( { } , state . draftTransaction , { sending : true } ) ;
2019-04-03 19:12:51 +02:00
2019-09-10 20:14:40 +02:00
return _extends$e ( { } , state , { draftTransaction : newDraftTransaction } ) ;
2019-05-10 07:02:03 +02:00
} ,
2019-04-03 19:12:51 +02:00
2019-05-10 07:02:03 +02:00
[ SEND _TRANSACTION _COMPLETED ] : state => Object . assign ( { } , state , {
draftTransaction : buildDraftTransaction ( )
} ) ,
2019-04-03 19:12:51 +02:00
2019-05-10 07:02:03 +02:00
[ SEND _TRANSACTION _FAILED ] : ( state , action ) => {
const newDraftTransaction = Object . assign ( { } , state . draftTransaction , {
sending : false ,
error : action . data . error
} ) ;
2019-04-03 19:12:51 +02:00
2019-09-10 20:14:40 +02:00
return _extends$e ( { } , state , { draftTransaction : newDraftTransaction } ) ;
2019-05-10 07:02:03 +02:00
} ,
2019-04-03 19:12:51 +02:00
2019-09-10 20:14:40 +02:00
[ SUPPORT _TRANSACTION _STARTED ] : state => _extends$e ( { } , state , {
2019-05-10 07:02:03 +02:00
sendingSupport : true
} ) ,
2019-04-03 19:12:51 +02:00
2019-09-10 20:14:40 +02:00
[ SUPPORT _TRANSACTION _COMPLETED ] : state => _extends$e ( { } , state , {
2019-05-10 07:02:03 +02:00
sendingSupport : false
} ) ,
2019-04-03 19:12:51 +02:00
2019-09-10 20:14:40 +02:00
[ SUPPORT _TRANSACTION _FAILED ] : ( state , action ) => _extends$e ( { } , state , {
2019-05-10 07:02:03 +02:00
error : action . data . error ,
sendingSupport : false
} ) ,
2019-04-03 19:12:51 +02:00
2019-09-10 20:14:40 +02:00
[ WALLET _STATUS _COMPLETED ] : ( state , action ) => _extends$e ( { } , state , {
2019-05-10 07:02:03 +02:00
walletIsEncrypted : action . result
} ) ,
2019-04-03 19:12:51 +02:00
2019-09-10 20:14:40 +02:00
[ WALLET _ENCRYPT _START ] : state => _extends$e ( { } , state , {
2019-05-10 07:02:03 +02:00
walletEncryptPending : true ,
walletEncryptSucceded : null ,
walletEncryptResult : null
} ) ,
2019-04-03 19:12:51 +02:00
2019-09-10 20:14:40 +02:00
[ WALLET _ENCRYPT _COMPLETED ] : ( state , action ) => _extends$e ( { } , state , {
2019-05-10 07:02:03 +02:00
walletEncryptPending : false ,
walletEncryptSucceded : true ,
walletEncryptResult : action . result
} ) ,
2019-04-03 19:12:51 +02:00
2019-09-10 20:14:40 +02:00
[ WALLET _ENCRYPT _FAILED ] : ( state , action ) => _extends$e ( { } , state , {
2019-05-10 07:02:03 +02:00
walletEncryptPending : false ,
walletEncryptSucceded : false ,
walletEncryptResult : action . result
} ) ,
2019-04-03 19:12:51 +02:00
2019-09-10 20:14:40 +02:00
[ WALLET _DECRYPT _START ] : state => _extends$e ( { } , state , {
2019-05-10 07:02:03 +02:00
walletDecryptPending : true ,
walletDecryptSucceded : null ,
walletDecryptResult : null
} ) ,
2019-04-03 19:12:51 +02:00
2019-09-10 20:14:40 +02:00
[ WALLET _DECRYPT _COMPLETED ] : ( state , action ) => _extends$e ( { } , state , {
2019-05-10 07:02:03 +02:00
walletDecryptPending : false ,
walletDecryptSucceded : true ,
walletDecryptResult : action . result
} ) ,
2019-04-03 19:12:51 +02:00
2019-09-10 20:14:40 +02:00
[ WALLET _DECRYPT _FAILED ] : ( state , action ) => _extends$e ( { } , state , {
2019-05-10 07:02:03 +02:00
walletDecryptPending : false ,
walletDecryptSucceded : false ,
walletDecryptResult : action . result
} ) ,
2019-04-03 19:12:51 +02:00
2019-09-10 20:14:40 +02:00
[ WALLET _UNLOCK _START ] : state => _extends$e ( { } , state , {
2019-05-10 07:02:03 +02:00
walletUnlockPending : true ,
walletUnlockSucceded : null ,
walletUnlockResult : null
} ) ,
2019-04-03 19:12:51 +02:00
2019-09-10 20:14:40 +02:00
[ WALLET _UNLOCK _COMPLETED ] : ( state , action ) => _extends$e ( { } , state , {
2019-05-10 07:02:03 +02:00
walletUnlockPending : false ,
walletUnlockSucceded : true ,
walletUnlockResult : action . result
} ) ,
2019-09-10 20:14:40 +02:00
[ WALLET _UNLOCK _FAILED ] : ( state , action ) => _extends$e ( { } , state , {
2019-05-10 07:02:03 +02:00
walletUnlockPending : false ,
walletUnlockSucceded : false ,
walletUnlockResult : action . result
} ) ,
2019-09-10 20:14:40 +02:00
[ WALLET _LOCK _START ] : state => _extends$e ( { } , state , {
2019-05-10 07:02:03 +02:00
walletLockPending : false ,
walletLockSucceded : null ,
walletLockResult : null
} ) ,
2019-09-10 20:14:40 +02:00
[ WALLET _LOCK _COMPLETED ] : ( state , action ) => _extends$e ( { } , state , {
2019-05-10 07:02:03 +02:00
walletLockPending : false ,
walletLockSucceded : true ,
walletLockResult : action . result
} ) ,
2019-09-10 20:14:40 +02:00
[ WALLET _LOCK _FAILED ] : ( state , action ) => _extends$e ( { } , state , {
2019-05-10 07:02:03 +02:00
walletLockPending : false ,
walletLockSucceded : false ,
walletLockResult : action . result
} ) ,
2019-09-10 20:14:40 +02:00
[ SET _TRANSACTION _LIST _FILTER ] : ( state , action ) => _extends$e ( { } , state , {
2019-05-10 07:02:03 +02:00
transactionListFilter : action . data
} ) ,
2019-09-10 20:14:40 +02:00
[ UPDATE _CURRENT _HEIGHT ] : ( state , action ) => _extends$e ( { } , state , {
2019-05-10 07:02:03 +02:00
latestBlock : action . data
} )
2019-08-02 02:57:27 +02:00
} , defaultState$a ) ;
2019-06-10 04:45:47 +02:00
2019-07-05 04:20:56 +02:00
const selectState$6 = state => state . content || { } ;
2019-04-03 19:12:51 +02:00
2019-07-05 04:20:56 +02:00
const makeSelectContentPositionForUri = uri => reselect . createSelector ( selectState$6 , makeSelectClaimForUri ( uri ) , ( state , claim ) => {
2019-04-03 19:12:51 +02:00
if ( ! claim ) {
return null ;
}
const outpoint = ` ${ claim . txid } : ${ claim . nout } ` ;
const id = claim . claim _id ;
return state . positions [ id ] ? state . positions [ id ] [ outpoint ] : null ;
} ) ;
2019-09-10 20:14:40 +02:00
var _extends$f = Object . assign || function ( target ) { for ( var i = 1 ; i < arguments . length ; i ++ ) { var source = arguments [ i ] ; for ( var key in source ) { if ( Object . prototype . hasOwnProperty . call ( source , key ) ) { target [ key ] = source [ key ] ; } } } return target ; } ;
2019-04-03 19:12:51 +02:00
2019-07-05 04:20:56 +02:00
const selectState$7 = state => state . notifications || { } ;
2019-04-03 19:12:51 +02:00
2019-07-05 04:20:56 +02:00
const selectToast = reselect . createSelector ( selectState$7 , state => {
2019-04-03 19:12:51 +02:00
if ( state . toasts . length ) {
const { id , params } = state . toasts [ 0 ] ;
2019-09-10 20:14:40 +02:00
return _extends$f ( {
2019-04-03 19:12:51 +02:00
id
} , params ) ;
}
return null ;
} ) ;
2019-07-05 04:20:56 +02:00
const selectError = reselect . createSelector ( selectState$7 , state => {
2019-04-03 19:12:51 +02:00
if ( state . errors . length ) {
const { error } = state . errors [ 0 ] ;
return {
error
} ;
}
return null ;
} ) ;
2019-06-10 04:45:47 +02:00
//
2019-07-05 04:20:56 +02:00
const selectState$8 = state => state . comments || { } ;
2019-06-12 03:14:37 +02:00
2019-07-05 04:20:56 +02:00
const selectCommentsById = reselect . createSelector ( selectState$8 , state => state . byId || { } ) ;
2019-06-12 03:14:37 +02:00
2019-07-05 04:20:56 +02:00
const selectCommentsByUri = reselect . createSelector ( selectState$8 , state => {
2019-06-12 03:14:37 +02:00
const byUri = state . commentsByUri || { } ;
const comments = { } ;
Object . keys ( byUri ) . forEach ( uri => {
const claimId = byUri [ uri ] ;
if ( claimId === null ) {
comments [ uri ] = null ;
} else {
comments [ uri ] = claimId ;
}
} ) ;
return comments ;
} ) ;
const makeSelectCommentsForUri = uri => reselect . createSelector ( selectCommentsById , selectCommentsByUri , ( byId , byUri ) => {
const claimId = byUri [ uri ] ;
return byId && byId [ claimId ] ;
} ) ;
//
2019-07-01 21:49:51 +02:00
const selectState$9 = state => state . tags || { } ;
2019-06-10 04:45:47 +02:00
2019-07-01 21:49:51 +02:00
const selectKnownTagsByName = reselect . createSelector ( selectState$9 , state => state . knownTags ) ;
2019-06-10 04:45:47 +02:00
2019-07-01 21:49:51 +02:00
const selectFollowedTagsList = reselect . createSelector ( selectState$9 , state => state . followedTags ) ;
2019-06-10 04:45:47 +02:00
2019-07-26 08:45:02 +02:00
const selectFollowedTags = reselect . createSelector ( selectFollowedTagsList , followedTags => followedTags . map ( tag => ( { name : tag . toLowerCase ( ) } ) ) . sort ( ( a , b ) => a . name . localeCompare ( b . name ) ) ) ;
2019-06-10 04:45:47 +02:00
const selectUnfollowedTags = reselect . createSelector ( selectKnownTagsByName , selectFollowedTagsList , ( tagsByName , followedTags ) => {
const followedTagsSet = new Set ( followedTags ) ;
let tagsToReturn = [ ] ;
Object . keys ( tagsByName ) . forEach ( key => {
if ( ! followedTagsSet . has ( key ) ) {
const { name } = tagsByName [ key ] ;
2019-08-13 17:27:32 +02:00
tagsToReturn . push ( { name : name . toLowerCase ( ) } ) ;
2019-06-10 04:45:47 +02:00
}
} ) ;
return tagsToReturn ;
} ) ;
2019-09-09 20:57:56 +02:00
const makeSelectIsFollowingTag = tag => reselect . createSelector ( selectFollowedTags , followedTags => {
return followedTags . some ( followedTag => followedTag . name === tag . toLowerCase ( ) ) ;
} ) ;
2019-08-02 02:57:27 +02:00
//
2019-08-02 16:56:32 +02:00
const selectState$a = state => state . blocked || { } ;
2019-08-02 02:57:27 +02:00
const selectBlockedChannels = reselect . createSelector ( selectState$a , state => state . blockedChannels ) ;
2019-08-02 16:56:32 +02:00
const selectBlockedChannelsCount = reselect . createSelector ( selectBlockedChannels , state => state . length ) ;
2019-08-02 02:57:27 +02:00
2019-08-02 16:56:32 +02:00
const selectChannelIsBlocked = uri => reselect . createSelector ( selectBlockedChannels , state => {
return state . includes ( uri ) ;
2019-08-02 02:57:27 +02:00
} ) ;
2019-04-03 19:12:51 +02:00
exports . ACTIONS = action _types ;
2019-07-01 21:49:51 +02:00
exports . CLAIM _VALUES = claim ;
2019-07-02 22:33:57 +02:00
exports . DEFAULT _FOLLOWED _TAGS = DEFAULT _FOLLOWED _TAGS ;
exports . DEFAULT _KNOWN _TAGS = DEFAULT _KNOWN _TAGS ;
2019-07-01 21:49:51 +02:00
exports . LICENSES = licenses ;
2019-04-03 19:12:51 +02:00
exports . Lbry = lbryProxy ;
2019-07-02 22:33:57 +02:00
exports . MATURE _TAGS = MATURE _TAGS ;
2019-04-03 19:12:51 +02:00
exports . PAGES = pages ;
exports . SEARCH _OPTIONS = SEARCH _OPTIONS ;
exports . SEARCH _TYPES = SEARCH _TYPES ;
exports . SETTINGS = settings ;
exports . SORT _OPTIONS = sort _options ;
exports . THUMBNAIL _STATUSES = thumbnail _upload _statuses ;
exports . TRANSACTIONS = transaction _types ;
2019-09-25 18:30:26 +02:00
exports . TX _LIST = transaction _list ;
2019-04-03 19:12:51 +02:00
exports . batchActions = batchActions ;
2019-08-02 16:56:32 +02:00
exports . blockedReducer = blockedReducer ;
2019-04-03 19:12:51 +02:00
exports . buildURI = buildURI ;
exports . claimsReducer = claimsReducer ;
2019-06-12 03:14:37 +02:00
exports . commentReducer = commentReducer ;
2019-04-03 19:12:51 +02:00
exports . contentReducer = contentReducer ;
exports . convertToShareLink = convertToShareLink ;
2019-07-30 17:48:45 +02:00
exports . createNormalizedClaimSearchKey = createNormalizedClaimSearchKey ;
2019-04-03 19:12:51 +02:00
exports . creditsToString = creditsToString ;
exports . doAbandonClaim = doAbandonClaim ;
2019-06-10 04:45:47 +02:00
exports . doAddTag = doAddTag ;
2019-04-03 19:12:51 +02:00
exports . doBalanceSubscribe = doBalanceSubscribe ;
exports . doBlurSearchInput = doBlurSearchInput ;
exports . doCheckAddressIsMine = doCheckAddressIsMine ;
2019-07-01 21:49:51 +02:00
exports . doCheckPendingPublishes = doCheckPendingPublishes ;
2019-06-11 20:11:18 +02:00
exports . doClaimSearch = doClaimSearch ;
2019-07-01 21:49:51 +02:00
exports . doClearPublish = doClearPublish ;
2019-06-12 03:14:37 +02:00
exports . doCommentCreate = doCommentCreate ;
exports . doCommentList = doCommentList ;
2019-04-23 19:22:14 +02:00
exports . doCreateChannel = doCreateChannel ;
2019-05-27 15:59:21 +02:00
exports . doDeletePurchasedUri = doDeletePurchasedUri ;
2019-06-10 04:45:47 +02:00
exports . doDeleteTag = doDeleteTag ;
2019-04-03 19:12:51 +02:00
exports . doDismissError = doDismissError ;
exports . doDismissToast = doDismissToast ;
exports . doError = doError ;
2019-04-23 19:22:14 +02:00
exports . doFetchChannelListMine = doFetchChannelListMine ;
2019-04-03 19:12:51 +02:00
exports . doFetchClaimListMine = doFetchClaimListMine ;
exports . doFetchClaimsByChannel = doFetchClaimsByChannel ;
exports . doFetchFileInfo = doFetchFileInfo ;
exports . doFetchFileInfosAndPublishedClaims = doFetchFileInfosAndPublishedClaims ;
exports . doFetchTransactions = doFetchTransactions ;
2019-05-21 21:18:07 +02:00
exports . doFileGet = doFileGet ;
2019-04-03 19:12:51 +02:00
exports . doFileList = doFileList ;
exports . doFocusSearchInput = doFocusSearchInput ;
exports . doGetNewAddress = doGetNewAddress ;
2019-09-12 21:06:49 +02:00
exports . doImportChannel = doImportChannel ;
2019-09-20 17:22:21 +02:00
exports . doPopulateSharedUserState = doPopulateSharedUserState ;
2019-07-01 21:49:51 +02:00
exports . doPrepareEdit = doPrepareEdit ;
exports . doPublish = doPublish ;
2019-05-21 21:18:07 +02:00
exports . doPurchaseUri = doPurchaseUri ;
2019-07-01 21:49:51 +02:00
exports . doResetThumbnailStatus = doResetThumbnailStatus ;
2019-04-03 19:12:51 +02:00
exports . doResolveUri = doResolveUri ;
exports . doResolveUris = doResolveUris ;
exports . doSearch = doSearch ;
exports . doSendDraftTransaction = doSendDraftTransaction ;
exports . doSendTip = doSendTip ;
exports . doSetDraftTransactionAddress = doSetDraftTransactionAddress ;
exports . doSetDraftTransactionAmount = doSetDraftTransactionAmount ;
exports . doSetFileListSort = doSetFileListSort ;
exports . doSetTransactionListFilter = doSetTransactionListFilter ;
exports . doToast = doToast ;
2019-08-02 02:57:27 +02:00
exports . doToggleBlockChannel = doToggleBlockChannel ;
2019-06-10 04:45:47 +02:00
exports . doToggleTagFollow = doToggleTagFollow ;
2019-04-03 19:12:51 +02:00
exports . doUpdateBalance = doUpdateBalance ;
exports . doUpdateBlockHeight = doUpdateBlockHeight ;
2019-07-01 03:16:44 +02:00
exports . doUpdateChannel = doUpdateChannel ;
2019-07-01 21:49:51 +02:00
exports . doUpdatePublishForm = doUpdatePublishForm ;
2019-04-03 19:12:51 +02:00
exports . doUpdateSearchOptions = doUpdateSearchOptions ;
exports . doUpdateSearchQuery = doUpdateSearchQuery ;
2019-07-01 21:49:51 +02:00
exports . doUploadThumbnail = doUploadThumbnail ;
2019-04-03 19:12:51 +02:00
exports . doWalletDecrypt = doWalletDecrypt ;
exports . doWalletEncrypt = doWalletEncrypt ;
exports . doWalletStatus = doWalletStatus ;
exports . doWalletUnlock = doWalletUnlock ;
exports . fileInfoReducer = fileInfoReducer ;
2019-05-21 21:18:07 +02:00
exports . fileReducer = fileReducer ;
2019-04-03 19:12:51 +02:00
exports . formatCredits = formatCredits ;
exports . formatFullPrice = formatFullPrice ;
2019-05-09 15:57:58 +02:00
exports . isClaimNsfw = isClaimNsfw ;
2019-04-03 19:12:51 +02:00
exports . isNameValid = isNameValid ;
exports . isURIClaimable = isURIClaimable ;
exports . isURIValid = isURIValid ;
2019-07-01 03:16:44 +02:00
exports . makeSelectAmountForUri = makeSelectAmountForUri ;
2019-08-20 22:00:26 +02:00
exports . makeSelectCanonicalUrlForUri = makeSelectCanonicalUrlForUri ;
2019-04-03 19:12:51 +02:00
exports . makeSelectChannelForClaimUri = makeSelectChannelForClaimUri ;
exports . makeSelectClaimForUri = makeSelectClaimForUri ;
exports . makeSelectClaimIsMine = makeSelectClaimIsMine ;
2019-04-23 21:02:32 +02:00
exports . makeSelectClaimIsNsfw = makeSelectClaimIsNsfw ;
2019-04-03 19:12:51 +02:00
exports . makeSelectClaimIsPending = makeSelectClaimIsPending ;
exports . makeSelectClaimsInChannelForCurrentPageState = makeSelectClaimsInChannelForCurrentPageState ;
exports . makeSelectClaimsInChannelForPage = makeSelectClaimsInChannelForPage ;
2019-06-12 03:14:37 +02:00
exports . makeSelectCommentsForUri = makeSelectCommentsForUri ;
2019-04-03 19:12:51 +02:00
exports . makeSelectContentPositionForUri = makeSelectContentPositionForUri ;
exports . makeSelectContentTypeForUri = makeSelectContentTypeForUri ;
2019-05-01 16:21:51 +02:00
exports . makeSelectCoverForUri = makeSelectCoverForUri ;
2019-05-06 04:00:45 +02:00
exports . makeSelectDateForUri = makeSelectDateForUri ;
2019-08-02 08:21:28 +02:00
exports . makeSelectDownloadPathForUri = makeSelectDownloadPathForUri ;
2019-09-25 23:37:21 +02:00
exports . makeSelectDownloadUrlsForPage = makeSelectDownloadUrlsForPage ;
2019-04-03 19:12:51 +02:00
exports . makeSelectDownloadingForUri = makeSelectDownloadingForUri ;
exports . makeSelectFetchingChannelClaims = makeSelectFetchingChannelClaims ;
exports . makeSelectFileInfoForUri = makeSelectFileInfoForUri ;
2019-08-02 08:21:28 +02:00
exports . makeSelectFileNameForUri = makeSelectFileNameForUri ;
2019-08-14 18:52:24 +02:00
exports . makeSelectFilePartlyDownloaded = makeSelectFilePartlyDownloaded ;
2019-09-23 04:25:12 +02:00
exports . makeSelectFilteredTransactionsForPage = makeSelectFilteredTransactionsForPage ;
2019-04-03 19:12:51 +02:00
exports . makeSelectFirstRecommendedFileForUri = makeSelectFirstRecommendedFileForUri ;
2019-09-09 20:57:56 +02:00
exports . makeSelectIsFollowingTag = makeSelectIsFollowingTag ;
2019-04-03 19:12:51 +02:00
exports . makeSelectIsUriResolving = makeSelectIsUriResolving ;
exports . makeSelectLoadingForUri = makeSelectLoadingForUri ;
2019-08-02 08:21:28 +02:00
exports . makeSelectMediaTypeForUri = makeSelectMediaTypeForUri ;
2019-04-03 19:12:51 +02:00
exports . makeSelectMetadataForUri = makeSelectMetadataForUri ;
2019-05-06 19:57:07 +02:00
exports . makeSelectMetadataItemForUri = makeSelectMetadataItemForUri ;
2019-09-25 23:37:21 +02:00
exports . makeSelectMyStreamUrlsForPage = makeSelectMyStreamUrlsForPage ;
2019-04-03 19:12:51 +02:00
exports . makeSelectNsfwCountForChannel = makeSelectNsfwCountForChannel ;
exports . makeSelectNsfwCountFromUris = makeSelectNsfwCountFromUris ;
exports . makeSelectPendingByUri = makeSelectPendingByUri ;
2019-09-04 17:57:48 +02:00
exports . makeSelectPermanentUrlForUri = makeSelectPermanentUrlForUri ;
2019-07-05 04:20:56 +02:00
exports . makeSelectPublishFormValue = makeSelectPublishFormValue ;
2019-04-03 19:12:51 +02:00
exports . makeSelectQueryWithOptions = makeSelectQueryWithOptions ;
exports . makeSelectRecommendedContentForUri = makeSelectRecommendedContentForUri ;
exports . makeSelectSearchUris = makeSelectSearchUris ;
2019-07-08 20:28:14 +02:00
exports . makeSelectShortUrlForUri = makeSelectShortUrlForUri ;
2019-05-21 21:18:07 +02:00
exports . makeSelectStreamingUrlForUri = makeSelectStreamingUrlForUri ;
2019-08-15 08:13:50 +02:00
exports . makeSelectSupportsForUri = makeSelectSupportsForUri ;
2019-06-10 04:45:47 +02:00
exports . makeSelectTagsForUri = makeSelectTagsForUri ;
2019-04-23 19:22:14 +02:00
exports . makeSelectThumbnailForUri = makeSelectThumbnailForUri ;
2019-04-03 19:12:51 +02:00
exports . makeSelectTitleForUri = makeSelectTitleForUri ;
exports . makeSelectTotalItemsForChannel = makeSelectTotalItemsForChannel ;
exports . makeSelectTotalPagesForChannel = makeSelectTotalPagesForChannel ;
2019-08-02 08:21:28 +02:00
exports . makeSelectUriIsStreamable = makeSelectUriIsStreamable ;
2019-04-03 19:12:51 +02:00
exports . normalizeURI = normalizeURI ;
exports . notificationsReducer = notificationsReducer ;
exports . parseQueryParams = parseQueryParams ;
exports . parseURI = parseURI ;
2019-07-01 21:49:51 +02:00
exports . publishReducer = publishReducer ;
2019-04-03 19:12:51 +02:00
exports . regexAddress = regexAddress ;
exports . regexInvalidURI = regexInvalidURI ;
exports . savePosition = savePosition ;
exports . searchReducer = searchReducer ;
exports . selectAbandoningIds = selectAbandoningIds ;
exports . selectAllClaimsByChannel = selectAllClaimsByChannel ;
exports . selectAllFetchingChannelClaims = selectAllFetchingChannelClaims ;
exports . selectAllMyClaimsByOutpoint = selectAllMyClaimsByOutpoint ;
exports . selectBalance = selectBalance ;
2019-08-02 02:57:27 +02:00
exports . selectBlockedChannels = selectBlockedChannels ;
exports . selectBlockedChannelsCount = selectBlockedChannelsCount ;
2019-04-03 19:12:51 +02:00
exports . selectBlocks = selectBlocks ;
exports . selectChannelClaimCounts = selectChannelClaimCounts ;
2019-09-12 21:06:49 +02:00
exports . selectChannelImportPending = selectChannelImportPending ;
2019-08-02 02:57:27 +02:00
exports . selectChannelIsBlocked = selectChannelIsBlocked ;
2019-07-17 22:50:58 +02:00
exports . selectClaimSearchByQuery = selectClaimSearchByQuery ;
2019-08-13 17:27:32 +02:00
exports . selectClaimSearchByQueryLastPageReached = selectClaimSearchByQueryLastPageReached ;
2019-09-24 00:56:53 +02:00
exports . selectClaimsBalance = selectClaimsBalance ;
2019-04-03 19:12:51 +02:00
exports . selectClaimsById = selectClaimsById ;
exports . selectClaimsByUri = selectClaimsByUri ;
2019-09-13 21:52:52 +02:00
exports . selectCreateChannelError = selectCreateChannelError ;
2019-08-27 06:42:52 +02:00
exports . selectCreatingChannel = selectCreatingChannel ;
2019-04-03 19:12:51 +02:00
exports . selectCurrentChannelPage = selectCurrentChannelPage ;
2019-09-25 23:37:21 +02:00
exports . selectDownloadUrlsCount = selectDownloadUrlsCount ;
2019-06-10 04:45:47 +02:00
exports . selectDownloadedUris = selectDownloadedUris ;
2019-04-03 19:12:51 +02:00
exports . selectDownloadingByOutpoint = selectDownloadingByOutpoint ;
exports . selectDownloadingFileInfos = selectDownloadingFileInfos ;
exports . selectDraftTransaction = selectDraftTransaction ;
exports . selectDraftTransactionAddress = selectDraftTransactionAddress ;
exports . selectDraftTransactionAmount = selectDraftTransactionAmount ;
exports . selectDraftTransactionError = selectDraftTransactionError ;
exports . selectError = selectError ;
2019-05-21 21:18:07 +02:00
exports . selectFailedPurchaseUris = selectFailedPurchaseUris ;
2019-06-11 20:11:18 +02:00
exports . selectFetchingClaimSearch = selectFetchingClaimSearch ;
2019-07-31 21:14:51 +02:00
exports . selectFetchingClaimSearchByQuery = selectFetchingClaimSearchByQuery ;
2019-04-03 19:12:51 +02:00
exports . selectFetchingMyChannels = selectFetchingMyChannels ;
exports . selectFileInfosByOutpoint = selectFileInfosByOutpoint ;
exports . selectFileInfosDownloaded = selectFileInfosDownloaded ;
exports . selectFileListDownloadedSort = selectFileListDownloadedSort ;
exports . selectFileListPublishedSort = selectFileListPublishedSort ;
2019-09-23 04:25:12 +02:00
exports . selectFilteredTransactionCount = selectFilteredTransactionCount ;
exports . selectFilteredTransactions = selectFilteredTransactions ;
2019-06-10 04:45:47 +02:00
exports . selectFollowedTags = selectFollowedTags ;
2019-04-03 19:12:51 +02:00
exports . selectGettingNewAddress = selectGettingNewAddress ;
exports . selectHasTransactions = selectHasTransactions ;
exports . selectIsFetchingClaimListMine = selectIsFetchingClaimListMine ;
exports . selectIsFetchingFileList = selectIsFetchingFileList ;
exports . selectIsFetchingFileListDownloadedOrPublished = selectIsFetchingFileListDownloadedOrPublished ;
exports . selectIsFetchingTransactions = selectIsFetchingTransactions ;
2019-07-01 21:49:51 +02:00
exports . selectIsResolvingPublishUris = selectIsResolvingPublishUris ;
2019-04-03 19:12:51 +02:00
exports . selectIsSearching = selectIsSearching ;
exports . selectIsSendingSupport = selectIsSendingSupport ;
2019-07-01 21:49:51 +02:00
exports . selectIsStillEditing = selectIsStillEditing ;
2019-05-21 21:18:07 +02:00
exports . selectLastPurchasedUri = selectLastPurchasedUri ;
2019-04-03 19:12:51 +02:00
exports . selectMyActiveClaims = selectMyActiveClaims ;
exports . selectMyChannelClaims = selectMyChannelClaims ;
2019-07-01 21:49:51 +02:00
exports . selectMyClaimForUri = selectMyClaimForUri ;
2019-06-11 20:36:01 +02:00
exports . selectMyClaimUrisWithoutChannels = selectMyClaimUrisWithoutChannels ;
2019-04-03 19:12:51 +02:00
exports . selectMyClaims = selectMyClaims ;
exports . selectMyClaimsOutpoints = selectMyClaimsOutpoints ;
exports . selectMyClaimsRaw = selectMyClaimsRaw ;
exports . selectMyClaimsWithoutChannels = selectMyClaimsWithoutChannels ;
2019-09-25 23:37:21 +02:00
exports . selectMyStreamUrlsCount = selectMyStreamUrlsCount ;
2019-04-03 19:12:51 +02:00
exports . selectPendingById = selectPendingById ;
exports . selectPendingClaims = selectPendingClaims ;
exports . selectPlayingUri = selectPlayingUri ;
2019-07-01 21:49:51 +02:00
exports . selectPublishFormValues = selectPublishFormValues ;
2019-05-27 15:59:21 +02:00
exports . selectPurchaseUriErrorMessage = selectPurchaseUriErrorMessage ;
2019-05-21 21:18:07 +02:00
exports . selectPurchasedUris = selectPurchasedUris ;
2019-04-03 19:12:51 +02:00
exports . selectReceiveAddress = selectReceiveAddress ;
exports . selectRecentTransactions = selectRecentTransactions ;
2019-09-24 00:56:53 +02:00
exports . selectReservedBalance = selectReservedBalance ;
2019-04-03 19:12:51 +02:00
exports . selectResolvingUris = selectResolvingUris ;
exports . selectSearchBarFocused = selectSearchBarFocused ;
exports . selectSearchOptions = selectSearchOptions ;
exports . selectSearchState = selectState ;
exports . selectSearchSuggestions = selectSearchSuggestions ;
exports . selectSearchUrisByQuery = selectSearchUrisByQuery ;
exports . selectSearchValue = selectSearchValue ;
2019-09-24 00:56:53 +02:00
exports . selectSupportsBalance = selectSupportsBalance ;
2019-05-14 06:50:21 +02:00
exports . selectSupportsByOutpoint = selectSupportsByOutpoint ;
2019-07-01 21:49:51 +02:00
exports . selectTakeOverAmount = selectTakeOverAmount ;
2019-09-24 00:56:53 +02:00
exports . selectTipsBalance = selectTipsBalance ;
2019-04-03 19:12:51 +02:00
exports . selectToast = selectToast ;
2019-04-18 09:56:16 +02:00
exports . selectTotalBalance = selectTotalBalance ;
2019-04-03 19:12:51 +02:00
exports . selectTotalDownloadProgress = selectTotalDownloadProgress ;
2019-08-15 08:13:50 +02:00
exports . selectTotalSupports = selectTotalSupports ;
2019-04-03 19:12:51 +02:00
exports . selectTransactionItems = selectTransactionItems ;
exports . selectTransactionListFilter = selectTransactionListFilter ;
exports . selectTransactionsById = selectTransactionsById ;
2019-06-10 04:45:47 +02:00
exports . selectUnfollowedTags = selectUnfollowedTags ;
2019-09-15 13:00:14 +02:00
exports . selectUpdateChannelError = selectUpdateChannelError ;
exports . selectUpdatingChannel = selectUpdatingChannel ;
2019-04-03 19:12:51 +02:00
exports . selectUrisLoading = selectUrisLoading ;
exports . selectWalletDecryptPending = selectWalletDecryptPending ;
exports . selectWalletDecryptResult = selectWalletDecryptResult ;
exports . selectWalletDecryptSucceeded = selectWalletDecryptSucceeded ;
exports . selectWalletEncryptPending = selectWalletEncryptPending ;
exports . selectWalletEncryptResult = selectWalletEncryptResult ;
exports . selectWalletEncryptSucceeded = selectWalletEncryptSucceeded ;
exports . selectWalletIsEncrypted = selectWalletIsEncrypted ;
exports . selectWalletState = selectWalletState ;
exports . selectWalletUnlockPending = selectWalletUnlockPending ;
exports . selectWalletUnlockResult = selectWalletUnlockResult ;
exports . selectWalletUnlockSucceeded = selectWalletUnlockSucceeded ;
exports . setSearchApi = setSearchApi ;
2019-07-02 22:33:57 +02:00
exports . tagsReducer = tagsReducer ;
2019-04-03 19:12:51 +02:00
exports . toQueryString = toQueryString ;
exports . walletReducer = walletReducer ;