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' ) ) ;
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-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' ;
// 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' ;
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' ;
// 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' ;
// ShapeShift
const GET _SUPPORTED _COINS _START = 'GET_SUPPORTED_COINS_START' ;
const GET _SUPPORTED _COINS _SUCCESS = 'GET_SUPPORTED_COINS_SUCCESS' ;
const GET _SUPPORTED _COINS _FAIL = 'GET_SUPPORTED_COINS_FAIL' ;
const GET _COIN _STATS _START = 'GET_COIN_STATS_START' ;
const GET _COIN _STATS _SUCCESS = 'GET_COIN_STATS_SUCCESS' ;
const GET _COIN _STATS _FAIL = 'GET_COIN_STATS_FAIL' ;
const PREPARE _SHAPE _SHIFT _START = 'PREPARE_SHAPE_SHIFT_START' ;
const PREPARE _SHAPE _SHIFT _SUCCESS = 'PREPARE_SHAPE_SHIFT_SUCCESS' ;
const PREPARE _SHAPE _SHIFT _FAIL = 'PREPARE_SHAPE_SHIFT_FAIL' ;
const GET _ACTIVE _SHIFT _START = 'GET_ACTIVE_SHIFT_START' ;
const GET _ACTIVE _SHIFT _SUCCESS = 'GET_ACTIVE_SHIFT_SUCCESS' ;
const GET _ACTIVE _SHIFT _FAIL = 'GET_ACTIVE_SHIFT_FAIL' ;
const CLEAR _SHAPE _SHIFT = 'CLEAR_SHAPE_SHIFT' ;
// 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' ;
var action _types = /*#__PURE__*/ Object . freeze ( {
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 ,
2019-05-10 07:02:03 +02:00
FETCH _SUPPORTS _STARTED : FETCH _SUPPORTS _STARTED ,
FETCH _SUPPORTS _COMPLETED : FETCH _SUPPORTS _COMPLETED ,
ABANDON _SUPPORT _STARTED : ABANDON _SUPPORT _STARTED ,
ABANDON _SUPPORT _COMPLETED : ABANDON _SUPPORT _COMPLETED ,
2019-04-03 19:12:51 +02:00
UPDATE _BALANCE : UPDATE _BALANCE ,
2019-04-18 09:56:16 +02:00
UPDATE _TOTAL _BALANCE : UPDATE _TOTAL _BALANCE ,
2019-04-03 19:12:51 +02:00
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 ,
2019-04-18 09:56:16 +02:00
SET _DRAFT _TRANSACTION _AMOUNT : SET _DRAFT _TRANSACTION _AMOUNT ,
SET _DRAFT _TRANSACTION _ADDRESS : SET _DRAFT _TRANSACTION _ADDRESS ,
2019-04-03 19:12:51 +02:00
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 ,
2019-04-23 19:22:14 +02:00
CREATE _CHANNEL _FAILED : CREATE _CHANNEL _FAILED ,
2019-04-03 19:12: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 ,
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 ,
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 ,
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 ,
GET _SUPPORTED _COINS _START : GET _SUPPORTED _COINS _START ,
GET _SUPPORTED _COINS _SUCCESS : GET _SUPPORTED _COINS _SUCCESS ,
GET _SUPPORTED _COINS _FAIL : GET _SUPPORTED _COINS _FAIL ,
GET _COIN _STATS _START : GET _COIN _STATS _START ,
GET _COIN _STATS _SUCCESS : GET _COIN _STATS _SUCCESS ,
GET _COIN _STATS _FAIL : GET _COIN _STATS _FAIL ,
PREPARE _SHAPE _SHIFT _START : PREPARE _SHAPE _SHIFT _START ,
PREPARE _SHAPE _SHIFT _SUCCESS : PREPARE _SHAPE _SHIFT _SUCCESS ,
PREPARE _SHAPE _SHIFT _FAIL : PREPARE _SHAPE _SHIFT _FAIL ,
GET _ACTIVE _SHIFT _START : GET _ACTIVE _SHIFT _START ,
GET _ACTIVE _SHIFT _SUCCESS : GET _ACTIVE _SHIFT _SUCCESS ,
GET _ACTIVE _SHIFT _FAIL : GET _ACTIVE _SHIFT _FAIL ,
CLEAR _SHAPE _SHIFT : CLEAR _SHAPE _SHIFT ,
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 ,
2019-04-18 09:56:16 +02:00
DISMISS _NOTIFICATION : DISMISS _NOTIFICATION ,
2019-04-03 19:12:51 +02:00
CREATE _TOAST : CREATE _TOAST ,
DISMISS _TOAST : DISMISS _TOAST ,
CREATE _ERROR : CREATE _ERROR ,
DISMISS _ERROR : DISMISS _ERROR ,
2019-04-18 09:56:16 +02:00
FETCH _DATE : FETCH _DATE
2019-04-03 19:12: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
} ) ;
/* 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 ( {
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
} ) ;
// eslint-disable-next-line import/prefer-default-export
const ALL = 'all' ;
const SPEND = 'spend' ;
const RECEIVE = 'receive' ;
const PUBLISH = 'publish' ;
const CHANNEL = 'channel' ;
const TIP = 'tip' ;
const SUPPORT = 'support' ;
const UPDATE = 'update' ;
const ABANDON = 'abandon' ;
var transaction _types = /*#__PURE__*/ Object . freeze ( {
ALL : ALL ,
SPEND : SPEND ,
RECEIVE : RECEIVE ,
PUBLISH : PUBLISH ,
CHANNEL : CHANNEL ,
TIP : TIP ,
SUPPORT : SUPPORT ,
UPDATE : UPDATE ,
ABANDON : ABANDON
} ) ;
const DATE _NEW = 'dateNew' ;
const DATE _OLD = 'dateOld' ;
const TITLE = 'title' ;
const FILENAME = 'filename' ;
var sort _options = /*#__PURE__*/ Object . freeze ( {
DATE _NEW : DATE _NEW ,
DATE _OLD : DATE _OLD ,
TITLE : TITLE ,
FILENAME : FILENAME
} ) ;
const AUTH = 'auth' ;
const BACKUP = 'backup' ;
const CHANNEL$1 = '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$1 = '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$1 ,
DISCOVER : DISCOVER ,
FILE : FILE ,
DOWNLOADED : DOWNLOADED ,
PUBLISHED : PUBLISHED ,
GET _CREDITS : GET _CREDITS ,
HELP : HELP ,
INVITE : INVITE ,
PUBLISH : PUBLISH$1 ,
REPORT : REPORT ,
REWARDS : REWARDS ,
SEARCH : SEARCH ,
SEND _CREDITS : SEND _CREDITS ,
SETTINGS : SETTINGS ,
SHOW : SHOW ,
SUBSCRIPTIONS : SUBSCRIPTIONS ,
TRANSACTION _HISTORY : TRANSACTION _HISTORY ,
HISTORY : HISTORY ,
WALLET : WALLET
} ) ;
const SEARCH _TYPES = {
FILE : 'file' ,
CHANNEL : 'channel' ,
SEARCH : 'search'
} ;
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'
} ;
//
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-04-23 19:22:14 +02:00
// Allow overriding daemon connection string (e.g. to `/api/proxy` for lbryweb)
setDaemonConnectionString : value => {
Lbry . daemonConnectionString = value ;
} ,
// 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
getMediaType : ( contentType , extname ) => {
if ( extname ) {
const formats = [ [ /^(mp4|m4v|webm|flv|f4v|ogv)$/i , 'video' ] , [ /^(mp3|m4a|aac|wav|flac|ogg|opus)$/i , 'audio' ] , [ /^(html|htm|xml|pdf|odf|doc|docx|md|markdown|txt|epub|org)$/i , 'document' ] , [ /^(stl|obj|fbx|gcode)$/i , '3D-file' ] ] ;
const res = formats . reduce ( ( ret , testpair ) => {
switch ( testpair [ 0 ] . test ( ret ) ) {
case true :
return testpair [ 1 ] ;
default :
return ret ;
}
} , extname ) ;
return res === extname ? 'unknown' : res ;
} else if ( contentType ) {
// $FlowFixMe
return ( /^[^/]+/ . exec ( contentType ) [ 0 ]
) ;
}
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 ) ,
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
account _balance : ( params = { } ) => daemonCallWithResult ( 'account_balance' , params ) ,
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 ) ,
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 ) ,
// 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' ,
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 ; } ;
const channelNameMinLength = 1 ;
const claimIdMaxLength = 40 ;
const regexInvalidURI = /[^A-Za-z0-9-]/g ;
const regexAddress = /^(b|r)(?=[^0OIl]{32,33})[0-9A-Za-z]{32,33}$/ ;
/ * *
* Parses a LBRY name into its component parts . Throws errors with user - friendly
* messages for invalid names .
*
* N . B . that "name" indicates the value in the name position of the URI . For
* claims for channel content , this will actually be the channel name , and
* the content name is in the path ( e . g . lbry : //@channel/content)
*
* In most situations , you ' ll want to use the contentName and channelName keys
* and ignore the name key .
*
* Returns a dictionary with keys :
* - name ( string ) : The value in the "name" position in the URI . Note that this
* could be either content name or channel name ; see above .
* - path ( string , if persent )
* - claimSequence ( int , if present )
* - bidPosition ( int , if present )
* - claimId ( string , if present )
* - isChannel ( boolean )
* - contentName ( string ) : For anon claims , the name ; for channel claims , the path
* - channelName ( string , if present ) : Channel name without @
* /
function parseURI ( URI , requireProto = false ) {
// Break into components. Empty sub-matches are converted to null
const componentsRegex = new RegExp ( '^((?:lbry://)?)' + // protocol
'([^:$#/]*)' + // claim name (stops at the first separator or end)
'([:$#]?)([^/]*)' + // modifier separator, modifier (stops at the first path separator or end)
'(/?)(.*)' // path separator, path
) ;
const [ proto , claimName , modSep , modVal , pathSep , path ] = componentsRegex . exec ( URI ) . slice ( 1 ) . map ( match => match || null ) ;
let contentName ;
// Validate protocol
if ( requireProto && ! proto ) {
throw new Error ( _ _ ( 'LBRY URIs must include a protocol prefix (lbry://).' ) ) ;
}
// Validate and process name
if ( ! claimName ) {
throw new Error ( _ _ ( 'URI does not include name.' ) ) ;
}
const isChannel = claimName . startsWith ( '@' ) ;
const channelName = isChannel ? claimName . slice ( 1 ) : claimName ;
if ( isChannel ) {
if ( ! channelName ) {
throw new Error ( _ _ ( 'No channel name after @.' ) ) ;
}
if ( channelName . length < channelNameMinLength ) {
throw new Error ( _ _ ( ` Channel names must be at least %s characters. ` , channelNameMinLength ) ) ;
}
contentName = path ;
}
const nameBadChars = ( channelName || claimName ) . match ( regexInvalidURI ) ;
if ( nameBadChars ) {
throw new Error ( _ _ ( ` Invalid character %s in name: %s. ` , nameBadChars . length === 1 ? '' : 's' , nameBadChars . join ( ', ' ) ) ) ;
}
// Validate and process modifier (claim ID, bid position or claim sequence)
let claimId ;
let claimSequence ;
let bidPosition ;
if ( modSep ) {
if ( ! modVal ) {
throw new Error ( _ _ ( ` No modifier provided after separator %s. ` , modSep ) ) ;
}
if ( modSep === '#' ) {
claimId = modVal ;
} else if ( modSep === ':' ) {
claimSequence = modVal ;
} else if ( modSep === '$' ) {
bidPosition = modVal ;
}
}
if ( claimId && ( claimId . length > claimIdMaxLength || ! claimId . match ( /^[0-9a-f]+$/ ) ) ) {
throw new Error ( _ _ ( ` Invalid claim ID %s. ` , claimId ) ) ;
}
if ( claimSequence && ! claimSequence . match ( /^-?[1-9][0-9]*$/ ) ) {
throw new Error ( _ _ ( 'Claim sequence must be a number.' ) ) ;
}
if ( bidPosition && ! bidPosition . match ( /^-?[1-9][0-9]*$/ ) ) {
throw new Error ( _ _ ( 'Bid position must be a number.' ) ) ;
}
// Validate and process path
if ( path ) {
if ( ! isChannel ) {
throw new Error ( _ _ ( 'Only channel URIs may have a path.' ) ) ;
}
const pathBadChars = path . match ( regexInvalidURI ) ;
if ( pathBadChars ) {
throw new Error ( _ _ ( ` Invalid character in path: %s ` , pathBadChars . join ( ', ' ) ) ) ;
}
contentName = path ;
} else if ( pathSep ) {
throw new Error ( _ _ ( 'No path provided after /' ) ) ;
}
return _extends ( {
claimName ,
path ,
isChannel
} , contentName ? { contentName } : { } , channelName ? { channelName } : { } , claimSequence ? { claimSequence : parseInt ( claimSequence , 10 ) } : { } , bidPosition ? { bidPosition : parseInt ( bidPosition , 10 ) } : { } , claimId ? { claimId } : { } , path ? { path } : { } ) ;
}
/ * *
* 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 .
* /
function buildURI ( URIObj , includeProto = true , protoDefault = 'lbry://' ) {
const { claimId , claimSequence , bidPosition , contentName , channelName } = URIObj ;
let { claimName , path } = URIObj ;
if ( channelName ) {
const channelNameFormatted = channelName . startsWith ( '@' ) ? channelName : ` @ ${ channelName } ` ;
if ( ! claimName ) {
claimName = channelNameFormatted ;
} else if ( claimName !== channelNameFormatted ) {
throw new Error ( _ _ ( 'Received a channel content URI, but claim name and channelName do not match. "name" represents the value in the name position of the URI (lbry://name...), which for channel content will be the channel name. In most cases, to construct a channel URI you should just pass channelName and contentName.' ) ) ;
}
}
if ( contentName ) {
if ( ! claimName ) {
claimName = contentName ;
} else if ( ! path ) {
path = contentName ;
}
if ( path && path !== contentName ) {
throw new Error ( _ _ ( 'Path and contentName do not match. Only one is required; most likely you wanted contentName.' ) ) ;
}
}
return ( includeProto ? protoDefault : '' ) + claimName + ( claimId ? ` # ${ claimId } ` : '' ) + ( claimSequence ? ` : ${ claimSequence } ` : '' ) + ( bidPosition ? ` ${ bidPosition } ` : '' ) + ( path ? ` / ${ path } ` : '' ) ;
}
/* Takes a parseable LBRY URI and converts it to standard, canonical format */
function normalizeURI ( URI ) {
const { claimName , path , bidPosition , claimSequence , claimId } = parseURI ( URI ) ;
return buildURI ( { claimName , path , claimSequence , bidPosition , claimId } ) ;
}
function isURIValid ( URI ) {
let parts ;
try {
parts = parseURI ( normalizeURI ( URI ) ) ;
} catch ( error ) {
return false ;
}
return parts && parts . claimName ;
}
function isNameValid ( claimName , checkCase = true ) {
const regexp = new RegExp ( '^[a-z0-9-]+$' , checkCase ? '' : 'i' ) ;
return regexp . test ( claimName ) ;
}
function isURIClaimable ( URI ) {
let parts ;
try {
parts = parseURI ( normalizeURI ( URI ) ) ;
} catch ( error ) {
return false ;
}
return parts && parts . claimName && ! parts . claimId && ! parts . bidPosition && ! parts . claimSequence && ! parts . isChannel && ! parts . path ;
}
function convertToShareLink ( URI ) {
const { claimName , path , bidPosition , claimSequence , claimId } = parseURI ( URI ) ;
2019-05-10 19:29:51 +02:00
return buildURI ( { claimName , path , claimSequence , bidPosition , claimId } , 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 [ ] ;
}
const queryIsPrefix = query === 'lbry:' || query === 'lbry:/' || query === 'lbry://' ;
if ( query . startsWith ( 'lbry://' ) && query !== 'lbry://' ) {
// If it starts with a prefix, don't show any autocomplete results
// They are probably typing/pasting in a lbry uri
return [ {
value : query ,
type : SEARCH _TYPES . FILE
} ] ;
} else if ( queryIsPrefix ) {
// If it is a prefix, wait until something else comes to figure out what to do
return [ ] ;
}
let searchSuggestions = [ ] ;
try {
const uri = normalizeURI ( query ) ;
const { claimName , isChannel } = parseURI ( uri ) ;
searchSuggestions . push ( {
value : claimName ,
type : SEARCH _TYPES . SEARCH
} , {
value : uri ,
shorthand : isChannel ? claimName . slice ( 1 ) : claimName ,
type : isChannel ? SEARCH _TYPES . CHANNEL : SEARCH _TYPES . FILE
} ) ;
} catch ( e ) {
searchSuggestions . push ( {
value : query ,
type : SEARCH _TYPES . SEARCH
} ) ;
}
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 ) ;
const { claimName , isChannel } = parseURI ( uri ) ;
return {
value : uri ,
shorthand : isChannel ? claimName . slice ( 1 ) : claimName ,
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-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 ; } ;
//
const naughtyTags = [ 'porn' , 'nsfw' , 'mature' , 'xxx' ] . reduce ( ( acc , tag ) => _extends$2 ( { } , acc , { [ tag ] : true } ) , { } ) ;
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 ( ) ;
if ( naughtyTags [ tag ] ) {
2019-04-23 19:22:14 +02:00
return true ;
}
}
return false ;
} ;
//
2019-04-03 19:12:51 +02:00
const selectState$1 = state => state . claims || { } ;
const selectClaimsById = reselect . createSelector ( selectState$1 , state => state . byId || { } ) ;
const selectCurrentChannelPage = reselect . createSelector ( selectState$1 , state => state . currentChannelPage || 1 ) ;
const selectClaimsByUri = reselect . createSelector ( selectState$1 , selectClaimsById , ( state , byId ) => {
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 ;
} ) ;
const selectAllClaimsByChannel = reselect . createSelector ( selectState$1 , state => state . claimsByChannel || { } ) ;
const selectPendingById = reselect . createSelector ( selectState$1 , state => state . pendingById || { } ) ;
const selectPendingClaims = reselect . createSelector ( selectState$1 , state => Object . values ( state . pendingById || [ ] ) ) ;
const makeSelectClaimIsPending = uri => reselect . createSelector ( selectPendingById , pendingById => {
const { claimId } = parseURI ( uri ) ;
return Boolean ( pendingById [ claimId ] ) ;
} ) ;
const makeSelectPendingByUri = uri => reselect . createSelector ( selectPendingById , pendingById => {
const { claimId } = parseURI ( uri ) ;
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
const { claimId } = parseURI ( uri ) ;
const pendingClaim = pendingById [ claimId ] ;
if ( pendingClaim ) {
return pendingClaim ;
}
return byUri && byUri [ normalizeURI ( uri ) ] ;
} ) ;
const selectMyClaimsRaw = reselect . createSelector ( selectState$1 , state => state . myClaims ) ;
const selectAbandoningIds = reselect . createSelector ( selectState$1 , state => Object . keys ( state . abandoningById || { } ) ) ;
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 => {
const uri = normalizeURI ( rawUri ) ;
return reselect . createSelector ( selectClaimsByUri , selectMyActiveClaims , ( claims , myClaims ) => claims && claims [ uri ] && claims [ uri ] . claim _id && myClaims . has ( claims [ uri ] . claim _id ) ) ;
} ;
const selectAllFetchingChannelClaims = reselect . createSelector ( selectState$1 , state => state . fetchingChannelClaims || { } ) ;
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 => {
const timestamp = claim && claim . timestamp ? claim . timestamp * 1000 : undefined ;
if ( ! timestamp ) {
return undefined ;
}
const dateObj = new Date ( timestamp ) ;
return dateObj ;
} ) ;
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 ;
return thumbnail ? thumbnail . url : 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 ;
return cover ? cover . url : undefined ;
} ) ;
2019-04-03 19:12:51 +02:00
const selectIsFetchingClaimListMine = reselect . createSelector ( selectState$1 , state => state . isFetchingClaimListMine ) ;
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 ] ;
} ) ;
const selectMyClaimsWithoutChannels = reselect . createSelector ( selectMyClaims , myClaims => myClaims . filter ( claim => ! claim . name . match ( /^@/ ) ) ) ;
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 ;
} ) ;
const selectFetchingMyChannels = reselect . createSelector ( selectState$1 , state => state . fetchingMyChannels ) ;
const selectMyChannelClaims = reselect . createSelector ( selectState$1 , selectClaimsById , ( state , byId ) => {
const ids = state . myChannelClaims || [ ] ;
const claims = [ ] ;
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 ;
} ) ;
const selectResolvingUris = reselect . createSelector ( selectState$1 , state => state . resolvingUris || [ ] ) ;
const makeSelectIsUriResolving = uri => reselect . createSelector ( selectResolvingUris , resolvingUris => resolvingUris && resolvingUris . indexOf ( uri ) !== - 1 ) ;
const selectPlayingUri = reselect . createSelector ( selectState$1 , state => state . playingUri ) ;
const selectChannelClaimCounts = reselect . createSelector ( selectState$1 , state => state . channelClaimCounts || { } ) ;
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 ) {
// If we are at a vanity uri, build the full uri so we can properly filter
const currentUri = atVanityURI ? buildURI ( { claimId : claim . claim _id , claimName : claim . name } ) : uri ;
2019-04-23 19:22:14 +02:00
const { title } = claim . value ;
2019-04-03 19:12:51 +02:00
const searchQuery = getSearchQueryString ( title . replace ( /\// , ' ' ) ) ;
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-04-23 19:22:14 +02:00
if ( ! claim || ! claim . signing _channel ) {
2019-04-03 19:12:51 +02:00
return null ;
}
2019-04-23 19:22:14 +02:00
const { claim _id : claimId , name } = claim . signing _channel ;
let channel = ` ${ name } # ${ claimId } ` ;
return includePrefix ? ` lbry:// ${ channel } ` : channel ;
2019-04-03 19:12:51 +02:00
} ) ;
const selectState$2 = state => state . wallet || { } ;
const selectWalletState = selectState$2 ;
const selectWalletIsEncrypted = reselect . createSelector ( selectState$2 , state => state . walletIsEncrypted ) ;
const selectWalletEncryptPending = reselect . createSelector ( selectState$2 , state => state . walletEncryptPending ) ;
const selectWalletEncryptSucceeded = reselect . createSelector ( selectState$2 , state => state . walletEncryptSucceded ) ;
const selectWalletEncryptResult = reselect . createSelector ( selectState$2 , state => state . walletEncryptResult ) ;
const selectWalletDecryptPending = reselect . createSelector ( selectState$2 , state => state . walletDecryptPending ) ;
const selectWalletDecryptSucceeded = reselect . createSelector ( selectState$2 , state => state . walletDecryptSucceded ) ;
const selectWalletDecryptResult = reselect . createSelector ( selectState$2 , state => state . walletDecryptResult ) ;
const selectWalletUnlockPending = reselect . createSelector ( selectState$2 , state => state . walletUnlockPending ) ;
const selectWalletUnlockSucceeded = reselect . createSelector ( selectState$2 , state => state . walletUnlockSucceded ) ;
const selectWalletUnlockResult = reselect . createSelector ( selectState$2 , state => state . walletUnlockResult ) ;
const selectWalletLockPending = reselect . createSelector ( selectState$2 , state => state . walletLockPending ) ;
const selectWalletLockSucceeded = reselect . createSelector ( selectState$2 , state => state . walletLockSucceded ) ;
const selectWalletLockResult = reselect . createSelector ( selectState$2 , state => state . walletLockResult ) ;
const selectBalance = reselect . createSelector ( selectState$2 , state => state . balance ) ;
2019-04-18 09:56:16 +02:00
const selectTotalBalance = reselect . createSelector ( selectState$2 , state => state . totalBalance ) ;
2019-05-10 07:02:03 +02:00
const selectTransactionsById = reselect . createSelector ( selectState$2 , state => state . transactions || { } ) ;
2019-05-14 06:50:21 +02:00
const selectSupportsByOutpoint = reselect . createSelector ( selectState$2 , state => state . supports || { } ) ;
2019-04-03 19:12:51 +02:00
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 : PUBLISH
} ) ) ) ;
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$2 , state => state . fetchingTransactions ) ;
const selectIsSendingSupport = reselect . createSelector ( selectState$2 , state => state . sendingSupport ) ;
const selectReceiveAddress = reselect . createSelector ( selectState$2 , state => state . receiveAddress ) ;
const selectGettingNewAddress = reselect . createSelector ( selectState$2 , state => state . gettingNewAddress ) ;
const selectDraftTransaction = reselect . createSelector ( selectState$2 , 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$2 , state => state . blocks ) ;
const selectCurrentHeight = reselect . createSelector ( selectState$2 , state => state . latestBlock ) ;
const selectTransactionListFilter = reselect . createSelector ( selectState$2 , state => state . transactionListFilter || '' ) ;
function formatCredits ( amount , precision ) {
if ( Number . isNaN ( parseFloat ( amount ) ) ) return '0' ;
return parseFloat ( amount ) . toFixed ( precision || 1 ) . replace ( /\.?0+$/ , '' ) ;
}
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 ;
}
function doUpdateBalance ( ) {
return ( dispatch , getState ) => {
const {
wallet : { balance : balanceInStore }
} = getState ( ) ;
lbryProxy . account _balance ( ) . then ( balanceAsString => {
const balance = parseFloat ( balanceAsString ) ;
if ( balanceInStore !== balance ) {
dispatch ( {
type : UPDATE _BALANCE ,
data : {
balance
}
} ) ;
}
} ) ;
} ;
}
2019-04-18 09:56:16 +02:00
function doUpdateTotalBalance ( ) {
return ( dispatch , getState ) => {
const {
wallet : { totalBalance : totalBalanceInStore }
} = getState ( ) ;
lbryProxy . account _list ( ) . then ( accountList => {
const { lbc _mainnet : accounts } = accountList ;
const totalSatoshis = accounts . length === 1 ? accounts [ 0 ] . satoshis : accounts . reduce ( ( a , b ) => a . satoshis + b . satoshis ) ;
const totalBalance = ( Number . isNaN ( totalSatoshis ) ? 0 : totalSatoshis ) / Math . pow ( 10 , 8 ) ;
if ( totalBalanceInStore !== totalBalance ) {
dispatch ( {
type : UPDATE _TOTAL _BALANCE ,
data : {
totalBalance
}
} ) ;
}
} ) ;
} ;
}
2019-04-03 19:12:51 +02:00
function doBalanceSubscribe ( ) {
return dispatch => {
dispatch ( doUpdateBalance ( ) ) ;
setInterval ( ( ) => dispatch ( doUpdateBalance ( ) ) , 5000 ) ;
} ;
}
2019-04-18 09:56:16 +02:00
function doTotalBalanceSubscribe ( ) {
return dispatch => {
dispatch ( doUpdateTotalBalance ( ) ) ;
setInterval ( ( ) => dispatch ( doUpdateTotalBalance ( ) ) , 5000 ) ;
} ;
}
2019-04-03 19:12:51 +02:00
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-04-03 19:12:51 +02:00
amount : creditsToString ( amount )
} ) . 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 }
} ;
}
function doSendTip ( amount , claimId , uri , successCallback , errorCallback ) {
return ( dispatch , getState ) => {
const state = getState ( ) ;
const balance = selectBalance ( state ) ;
if ( balance - amount <= 0 ) {
dispatch ( doToast ( {
message : 'Insufficient credits' ,
isError : true
} ) ) ;
return ;
}
const success = ( ) => {
dispatch ( doToast ( {
message : _ _ ( ` You sent ${ amount } LBC as a tip, Mahalo! ` ) ,
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-04-23 19:22:14 +02:00
amount : creditsToString ( amount ) ,
tip : 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-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 = {
claim : null ,
claimsInChannel : null ,
certificate : null
} ;
2019-04-23 19:22:14 +02:00
// Flow has terrible Object.entries support
// https://github.com/facebook/flow/issues/2221
// $FlowFixMe
if ( uriResolveInfo . error ) {
resolveInfo [ uri ] = _extends$3 ( { } , fallbackResolveInfo ) ;
} else {
// $FlowFixMe
const { claim , certificate , claims _in _channel : claimsInChannel } = uriResolveInfo ;
resolveInfo [ uri ] = { claim , certificate , claimsInChannel } ;
}
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-05-10 07:02:03 +02:00
message : isClaim ? 'Error abandoning your claim' : '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-04-23 19:22:14 +02:00
dispatch ( doToast ( {
2019-05-10 07:02:03 +02:00
message : isClaim ? 'Successfully abandoned your claim' : 'Successfully unlocked your tip!'
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
dispatch ( doFetchClaimListMine ( ) ) ;
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-04-29 16:29:24 +02:00
const { claimId } = parseURI ( uri ) ;
lbryProxy . claim _search ( { channel _id : claimId , page : page || 1 } ) . then ( result => {
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-04-23 19:22:14 +02:00
function doCreateChannel ( name , amount ) {
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-04-23 19:22:14 +02:00
return lbryProxy . channel _create ( {
name ,
bid : creditsToString ( amount )
} )
// 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 ,
data : error
2019-04-03 19:12:51 +02:00
} ) ;
} ) ;
} ;
}
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-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 ] ;
} ) ;
const selectUrisLoading = reselect . createSelector ( selectState$3 , state => state . urisLoading || { } ) ;
const makeSelectLoadingForUri = uri => reselect . createSelector ( selectUrisLoading , byUri => byUri && byUri [ uri ] ) ;
const selectFileInfosDownloaded = reselect . createSelector ( selectFileInfosByOutpoint , selectMyClaims , ( byOutpoint , myClaims ) => Object . values ( byOutpoint ) . filter ( fileInfo => {
const myClaimIds = myClaims . map ( claim => claim . claim _id ) ;
return fileInfo && myClaimIds . indexOf ( fileInfo . claim _id ) === - 1 && ( fileInfo . completed || fileInfo . written _bytes ) ;
} ) ) ;
// 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 selectSearchDownloadUris = query => reselect . createSelector ( selectFileInfosDownloaded , selectClaimsById , ( fileInfos , claimsById ) => {
if ( ! query || ! fileInfos . length ) {
return null ;
}
const queryParts = query . toLowerCase ( ) . split ( ' ' ) ;
const searchQueryDictionary = { } ;
queryParts . forEach ( subQuery => {
searchQueryDictionary [ subQuery ] = subQuery ;
} ) ;
const arrayContainsQueryPart = array => {
for ( let i = 0 ; i < array . length ; i += 1 ) {
const subQuery = array [ i ] ;
if ( searchQueryDictionary [ subQuery ] ) {
return true ;
}
}
return false ;
} ;
const downloadResultsFromQuery = [ ] ;
fileInfos . forEach ( fileInfo => {
const { channel _name : channelName , claim _name : claimName , metadata } = fileInfo ;
const { author , description , title } = metadata ;
if ( channelName ) {
const lowerCaseChannel = channelName . toLowerCase ( ) ;
const strippedOutChannelName = lowerCaseChannel . slice ( 1 ) ; // trim off the @
if ( searchQueryDictionary [ channelName ] || searchQueryDictionary [ strippedOutChannelName ] ) {
downloadResultsFromQuery . push ( fileInfo ) ;
return ;
}
}
const nameParts = claimName . toLowerCase ( ) . split ( '-' ) ;
if ( arrayContainsQueryPart ( nameParts ) ) {
downloadResultsFromQuery . push ( fileInfo ) ;
return ;
}
const titleParts = title . toLowerCase ( ) . split ( ' ' ) ;
if ( arrayContainsQueryPart ( titleParts ) ) {
downloadResultsFromQuery . push ( fileInfo ) ;
return ;
}
if ( author ) {
const authorParts = author . toLowerCase ( ) . split ( ' ' ) ;
if ( arrayContainsQueryPart ( authorParts ) ) {
downloadResultsFromQuery . push ( fileInfo ) ;
return ;
}
}
if ( description ) {
const descriptionParts = description . toLowerCase ( ) . split ( ' ' ) ;
if ( arrayContainsQueryPart ( descriptionParts ) ) {
downloadResultsFromQuery . push ( fileInfo ) ;
}
}
} ) ;
return downloadResultsFromQuery . length ? downloadResultsFromQuery . map ( fileInfo => {
2019-05-06 04:00:45 +02:00
const {
channel _name : channelName ,
claim _id : claimId ,
claim _name : claimName
} = fileInfo ;
2019-04-03 19:12:51 +02:00
const uriParams = { } ;
if ( channelName ) {
const claim = claimsById [ claimId ] ;
2019-05-06 04:00:45 +02:00
if ( claim && claim . signing _channel ) {
uriParams . claimId = claim . signing _channel . claim _id ;
2019-04-03 19:12:51 +02:00
} else {
uriParams . claimId = claimId ;
}
uriParams . channelName = channelName ;
uriParams . contentName = claimName ;
} else {
uriParams . claimId = claimId ;
uriParams . claimName = claimName ;
}
const uri = buildURI ( uriParams ) ;
return uri ;
} ) : null ;
} ) ;
const selectFileListPublishedSort = reselect . createSelector ( selectState$3 , state => state . fileListPublishedSort ) ;
const selectFileListDownloadedSort = reselect . createSelector ( selectState$3 , state => state . fileListDownloadedSort ) ;
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 }
} ;
}
// https://github.com/reactjs/redux/issues/911
function batchActions ( ... actions ) {
return {
type : 'BATCH_ACTIONS' ,
actions
} ;
}
// 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 => {
const uri = buildURI ( {
claimName : result . name ,
claimId : result . claimId
} ) ;
actions . push ( doResolveUri ( uri ) ) ;
uris . push ( uri ) ;
} ) ;
actions . push ( {
type : SEARCH _SUCCESS ,
data : {
query : queryWithOptions ,
uris
}
} ) ;
dispatch ( batchActions ( ... actions ) ) ;
} ) . catch ( ( ) => {
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-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
myChannelClaims : new Set ( ) ,
fetchingMyChannels : false ,
abandoningById : { } ,
pendingById : { }
2019-04-03 19:12:51 +02:00
} ;
reducers [ RESOLVE _URIS _COMPLETED ] = ( state , action ) => {
const { resolveInfo } = action . data ;
const byUri = Object . assign ( { } , state . claimsByUri ) ;
const byId = Object . assign ( { } , state . byId ) ;
const channelClaimCounts = Object . assign ( { } , state . channelClaimCounts ) ;
2019-04-23 19:22:14 +02:00
Object . entries ( resolveInfo ) . forEach ( ( [ uri , resolveResponse ] ) => {
// $FlowFixMe
if ( resolveResponse . certificate && ! Number . isNaN ( resolveResponse . claimsInChannel ) ) {
// $FlowFixMe
channelClaimCounts [ uri ] = resolveResponse . claimsInChannel ;
2019-04-03 19:12:51 +02:00
}
} ) ;
2019-04-23 19:22:14 +02:00
// $FlowFixMe
2019-04-03 19:12:51 +02:00
Object . entries ( resolveInfo ) . forEach ( ( [ uri , { certificate , claim } ] ) => {
2019-04-23 19:22:14 +02:00
if ( claim && ! certificate ) {
byId [ claim . claim _id ] = claim ;
byUri [ uri ] = claim . claim _id ;
} else if ( claim && certificate ) {
2019-04-03 19:12:51 +02:00
byId [ claim . claim _id ] = claim ;
byUri [ uri ] = claim . claim _id ;
2019-04-23 19:22:14 +02:00
2019-04-03 19:12:51 +02:00
byId [ certificate . claim _id ] = certificate ;
2019-04-23 19:22:14 +02:00
const channelUri = ` lbry:// ${ certificate . name } # ${ certificate . claim _id } ` ;
byUri [ channelUri ] = certificate . claim _id ;
} else if ( ! claim && certificate ) {
byId [ certificate . claim _id ] = certificate ;
byUri [ uri ] = certificate . claim _id ;
2019-04-03 19:12:51 +02:00
} else {
byUri [ uri ] = null ;
}
} ) ;
return Object . assign ( { } , state , {
byId ,
claimsByUri : byUri ,
channelClaimCounts ,
resolvingUris : ( state . resolvingUris || [ ] ) . filter ( uri => ! resolveInfo [ uri ] )
} ) ;
} ;
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 ) ;
claims . forEach ( claim => {
const uri = buildURI ( { claimName : claim . name , claimId : claim . claim _id } ) ;
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 ,
myClaims : claims ,
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 ;
const myChannelClaims = new Set ( state . myChannelClaims ) ;
const byId = Object . assign ( { } , state . byId ) ;
claims . forEach ( claim => {
myChannelClaims . add ( claim . claim _id ) ;
byId [ claim . claim _id ] = claim ;
} ) ;
return Object . assign ( { } , state , {
byId ,
fetchingMyChannels : false ,
myChannelClaims
} ) ;
} ;
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 ;
claimsByUri [ ` lbry:// ${ claim . name } # ${ claim . claim _id } ` ] = claim . claim _id ;
} ) ;
}
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
} ) ;
} ;
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 ,
myChannelClaims
} ) ;
} ;
reducers [ RESOLVE _URIS _STARTED ] = ( state , action ) => {
const { uris } = action . data ;
const oldResolving = state . resolvingUris || [ ] ;
2019-04-23 19:22:14 +02:00
const newResolving = oldResolving . slice ( ) ;
2019-04-03 19:12:51 +02:00
uris . forEach ( uri => {
if ( ! newResolving . includes ( uri ) ) {
newResolving . push ( uri ) ;
}
} ) ;
return Object . assign ( { } , state , {
resolvingUris : newResolving
} ) ;
} ;
function claimsReducer ( state = defaultState , action ) {
const handler = reducers [ action . type ] ;
if ( handler ) return handler ( state , action ) ;
return state ;
}
2019-04-23 19:22:14 +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 ; } ;
2019-04-03 19:12:51 +02:00
const reducers$1 = { } ;
const defaultState$1 = {
fileListPublishedSort : DATE _NEW ,
fileListDownloadedSort : DATE _NEW
} ;
reducers$1 [ FILE _LIST _STARTED ] = state => Object . assign ( { } , state , {
isFetchingFileList : true
} ) ;
reducers$1 [ FILE _LIST _SUCCEEDED ] = ( state , action ) => {
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
} ) ;
} ;
reducers$1 [ FETCH _FILE _INFO _STARTED ] = ( state , action ) => {
const { outpoint } = action . data ;
const newFetching = Object . assign ( { } , state . fetching ) ;
newFetching [ outpoint ] = true ;
return Object . assign ( { } , state , {
fetching : newFetching
} ) ;
} ;
reducers$1 [ FETCH _FILE _INFO _COMPLETED ] = ( state , action ) => {
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
} ) ;
} ;
reducers$1 [ DOWNLOADING _STARTED ] = ( state , action ) => {
const { uri , outpoint , fileInfo } = action . data ;
const newByOutpoint = Object . assign ( { } , state . byOutpoint ) ;
const newDownloading = Object . assign ( { } , state . downloadingByOutpoint ) ;
const newLoading = Object . assign ( { } , state . urisLoading ) ;
newDownloading [ outpoint ] = true ;
newByOutpoint [ outpoint ] = fileInfo ;
delete newLoading [ uri ] ;
return Object . assign ( { } , state , {
downloadingByOutpoint : newDownloading ,
urisLoading : newLoading ,
byOutpoint : newByOutpoint
} ) ;
} ;
reducers$1 [ DOWNLOADING _PROGRESSED ] = ( state , action ) => {
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
} ) ;
} ;
reducers$1 [ DOWNLOADING _CANCELED ] = ( state , action ) => {
const { outpoint } = action . data ;
const newDownloading = Object . assign ( { } , state . downloadingByOutpoint ) ;
delete newDownloading [ outpoint ] ;
return Object . assign ( { } , state , {
downloadingByOutpoint : newDownloading
} ) ;
} ;
reducers$1 [ DOWNLOADING _COMPLETED ] = ( state , action ) => {
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
} ) ;
} ;
reducers$1 [ FILE _DELETE ] = ( state , action ) => {
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
} ) ;
} ;
reducers$1 [ LOADING _VIDEO _STARTED ] = ( state , action ) => {
const { uri } = action . data ;
const newLoading = Object . assign ( { } , state . urisLoading ) ;
newLoading [ uri ] = true ;
2019-04-23 19:22:14 +02:00
const newErrors = _extends$4 ( { } , state . errors ) ;
2019-04-03 19:12:51 +02:00
if ( uri in newErrors ) delete newErrors [ uri ] ;
return Object . assign ( { } , state , {
urisLoading : newLoading ,
2019-04-23 19:22:14 +02:00
errors : _extends$4 ( { } , newErrors )
2019-04-03 19:12:51 +02:00
} ) ;
} ;
reducers$1 [ LOADING _VIDEO _FAILED ] = ( state , action ) => {
const { uri } = action . data ;
const newLoading = Object . assign ( { } , state . urisLoading ) ;
delete newLoading [ uri ] ;
2019-04-23 19:22:14 +02:00
const newErrors = _extends$4 ( { } , state . errors ) ;
2019-04-03 19:12:51 +02:00
newErrors [ uri ] = true ;
return Object . assign ( { } , state , {
urisLoading : newLoading ,
2019-04-23 19:22:14 +02:00
errors : _extends$4 ( { } , newErrors )
2019-04-03 19:12:51 +02:00
} ) ;
} ;
reducers$1 [ FETCH _DATE ] = ( state , action ) => {
const { time } = action . data ;
if ( time ) {
return Object . assign ( { } , state , {
publishedDate : time
} ) ;
}
return null ;
} ;
reducers$1 [ SET _FILE _LIST _SORT ] = ( state , action ) => {
const pageSortStates = {
[ PUBLISHED ] : 'fileListPublishedSort' ,
[ DOWNLOADED ] : 'fileListDownloadedSort'
} ;
const pageSortState = pageSortStates [ action . data . page ] ;
const { value } = action . data ;
return Object . assign ( { } , state , {
[ pageSortState ] : value
} ) ;
} ;
function fileInfoReducer ( state = defaultState$1 , action ) {
const handler = reducers$1 [ action . type ] ;
if ( handler ) return handler ( state , action ) ;
return state ;
}
// util for creating reducers
// based off of redux-actions
// https://redux-actions.js.org/docs/api/handleAction.html#handleactions
// eslint-disable-next-line import/prefer-default-export
const handleActions = ( actionMap , defaultState ) => ( state = defaultState , action ) => {
const handler = actionMap [ action . type ] ;
if ( handler ) {
const newState = handler ( state , action ) ;
return Object . assign ( { } , state , newState ) ;
}
// just return the original state if no handler
// returning a copy here breaks redux-persist
return state ;
} ;
2019-04-23 19:22:14 +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-04-03 19:12:51 +02:00
const defaultState$2 = {
notifications : [ ] ,
toasts : [ ] ,
errors : [ ]
} ;
const notificationsReducer = handleActions ( {
// Toasts
[ CREATE _TOAST ] : ( state , action ) => {
const toast = action . data ;
const newToasts = state . toasts . slice ( ) ;
newToasts . push ( toast ) ;
2019-04-23 19:22:14 +02:00
return _extends$5 ( { } , state , {
2019-04-03 19:12:51 +02:00
toasts : newToasts
} ) ;
} ,
[ DISMISS _TOAST ] : state => {
const newToasts = state . toasts . slice ( ) ;
newToasts . shift ( ) ;
2019-04-23 19:22:14 +02:00
return _extends$5 ( { } , 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-04-23 19:22:14 +02:00
return _extends$5 ( { } , 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-04-23 19:22:14 +02:00
return _extends$5 ( { } , 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-04-23 19:22:14 +02:00
return _extends$5 ( { } , 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-04-23 19:22:14 +02:00
return _extends$5 ( { } , state , {
2019-04-03 19:12:51 +02:00
errors : newErrors
} ) ;
} ,
[ DISMISS _ERROR ] : state => {
const newErrors = state . errors . slice ( ) ;
newErrors . shift ( ) ;
2019-04-23 19:22:14 +02:00
return _extends$5 ( { } , state , {
2019-04-03 19:12:51 +02:00
errors : newErrors
} ) ;
}
} , defaultState$2 ) ;
2019-04-23 19:22:14 +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-03 19:12:51 +02:00
const defaultState$3 = {
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-04-23 19:22:14 +02:00
[ SEARCH _START ] : state => _extends$6 ( { } , state , {
2019-04-03 19:12:51 +02:00
searching : true
} ) ,
[ SEARCH _SUCCESS ] : ( state , action ) => {
const { query , uris } = action . data ;
2019-04-23 19:22:14 +02:00
return _extends$6 ( { } , state , {
2019-04-03 19:12:51 +02:00
searching : false ,
urisByQuery : Object . assign ( { } , state . urisByQuery , { [ query ] : uris } )
} ) ;
} ,
2019-04-23 19:22:14 +02:00
[ SEARCH _FAIL ] : state => _extends$6 ( { } , state , {
2019-04-03 19:12:51 +02:00
searching : false
} ) ,
2019-04-23 19:22:14 +02:00
[ UPDATE _SEARCH _QUERY ] : ( state , action ) => _extends$6 ( { } , state , {
2019-04-03 19:12:51 +02:00
searchQuery : action . data . query ,
isActive : true
} ) ,
2019-04-23 19:22:14 +02:00
[ UPDATE _SEARCH _SUGGESTIONS ] : ( state , action ) => _extends$6 ( { } , state , {
suggestions : _extends$6 ( { } , 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-04-23 19:22:14 +02:00
[ DISMISS _NOTIFICATION ] : state => _extends$6 ( { } , state , {
2019-04-03 19:12:51 +02:00
isActive : false
} ) ,
2019-04-23 19:22:14 +02:00
[ SEARCH _FOCUS ] : state => _extends$6 ( { } , state , {
2019-04-03 19:12:51 +02:00
focused : true
} ) ,
2019-04-23 19:22:14 +02:00
[ SEARCH _BLUR ] : state => _extends$6 ( { } , 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-04-23 19:22:14 +02:00
const options = _extends$6 ( { } , oldOptions , newOptions ) ;
return _extends$6 ( { } , state , {
2019-04-03 19:12:51 +02:00
options
} ) ;
}
} , defaultState$3 ) ;
2019-05-10 07:02:03 +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-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
const defaultState$4 = {
balance : undefined ,
2019-04-18 09:56:16 +02:00
totalBalance : 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 ( {
[ FETCH _TRANSACTIONS _STARTED ] : state => _extends$7 ( { } , state , {
fetchingTransactions : true
} ) ,
2019-04-03 19:12:51 +02:00
2019-05-10 07:02:03 +02:00
[ FETCH _TRANSACTIONS _COMPLETED ] : ( state , action ) => {
const byId = _extends$7 ( { } , 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-05-10 07:02:03 +02:00
return _extends$7 ( { } , state , {
transactions : byId ,
fetchingTransactions : false
} ) ;
} ,
2019-04-03 19:12:51 +02:00
2019-05-10 07:02:03 +02:00
[ FETCH _SUPPORTS _STARTED ] : state => _extends$7 ( { } , state , {
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-05-14 06:50:21 +02:00
return _extends$7 ( { } , 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-05-10 07:02:03 +02:00
return _extends$7 ( { } , 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-05-10 07:02:03 +02:00
return _extends$7 ( { } , 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-05-10 07:02:03 +02:00
[ GET _NEW _ADDRESS _STARTED ] : state => _extends$7 ( { } , state , {
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-05-10 07:02:03 +02:00
return _extends$7 ( { } , state , { gettingNewAddress : false , receiveAddress : address } ) ;
} ,
2019-04-03 19:12:51 +02:00
2019-05-10 07:02:03 +02:00
[ UPDATE _BALANCE ] : ( state , action ) => _extends$7 ( { } , state , {
balance : action . data . balance
} ) ,
2019-04-03 19:12:51 +02:00
2019-05-10 07:02:03 +02:00
[ UPDATE _TOTAL _BALANCE ] : ( state , action ) => _extends$7 ( { } , state , {
totalBalance : action . data . totalBalance
} ) ,
2019-04-03 19:12:51 +02:00
2019-05-10 07:02:03 +02:00
[ CHECK _ADDRESS _IS _MINE _STARTED ] : state => _extends$7 ( { } , state , {
checkingAddressOwnership : true
} ) ,
2019-04-03 19:12:51 +02:00
2019-05-10 07:02:03 +02:00
[ CHECK _ADDRESS _IS _MINE _COMPLETED ] : state => _extends$7 ( { } , state , {
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 ;
const newDraft = _extends$7 ( { } , oldDraft , { amount : parseFloat ( action . data . amount ) } ) ;
2019-04-03 19:12:51 +02:00
2019-05-10 07:02:03 +02:00
return _extends$7 ( { } , state , { draftTransaction : newDraft } ) ;
} ,
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 ;
const newDraft = _extends$7 ( { } , oldDraft , { address : action . data . address } ) ;
2019-04-03 19:12:51 +02:00
2019-05-10 07:02:03 +02:00
return _extends$7 ( { } , state , { draftTransaction : newDraft } ) ;
} ,
2019-04-03 19:12:51 +02:00
2019-05-10 07:02:03 +02:00
[ SEND _TRANSACTION _STARTED ] : state => {
const newDraftTransaction = _extends$7 ( { } , state . draftTransaction , { sending : true } ) ;
2019-04-03 19:12:51 +02:00
2019-05-10 07:02:03 +02:00
return _extends$7 ( { } , state , { draftTransaction : newDraftTransaction } ) ;
} ,
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-05-10 07:02:03 +02:00
return _extends$7 ( { } , state , { draftTransaction : newDraftTransaction } ) ;
} ,
2019-04-03 19:12:51 +02:00
2019-05-10 07:02:03 +02:00
[ SUPPORT _TRANSACTION _STARTED ] : state => _extends$7 ( { } , state , {
sendingSupport : true
} ) ,
2019-04-03 19:12:51 +02:00
2019-05-10 07:02:03 +02:00
[ SUPPORT _TRANSACTION _COMPLETED ] : state => _extends$7 ( { } , state , {
sendingSupport : false
} ) ,
2019-04-03 19:12:51 +02:00
2019-05-10 07:02:03 +02:00
[ SUPPORT _TRANSACTION _FAILED ] : ( state , action ) => _extends$7 ( { } , state , {
error : action . data . error ,
sendingSupport : false
} ) ,
2019-04-03 19:12:51 +02:00
2019-05-10 07:02:03 +02:00
[ WALLET _STATUS _COMPLETED ] : ( state , action ) => _extends$7 ( { } , state , {
walletIsEncrypted : action . result
} ) ,
2019-04-03 19:12:51 +02:00
2019-05-10 07:02:03 +02:00
[ WALLET _ENCRYPT _START ] : state => _extends$7 ( { } , state , {
walletEncryptPending : true ,
walletEncryptSucceded : null ,
walletEncryptResult : null
} ) ,
2019-04-03 19:12:51 +02:00
2019-05-10 07:02:03 +02:00
[ WALLET _ENCRYPT _COMPLETED ] : ( state , action ) => _extends$7 ( { } , state , {
walletEncryptPending : false ,
walletEncryptSucceded : true ,
walletEncryptResult : action . result
} ) ,
2019-04-03 19:12:51 +02:00
2019-05-10 07:02:03 +02:00
[ WALLET _ENCRYPT _FAILED ] : ( state , action ) => _extends$7 ( { } , state , {
walletEncryptPending : false ,
walletEncryptSucceded : false ,
walletEncryptResult : action . result
} ) ,
2019-04-03 19:12:51 +02:00
2019-05-10 07:02:03 +02:00
[ WALLET _DECRYPT _START ] : state => _extends$7 ( { } , state , {
walletDecryptPending : true ,
walletDecryptSucceded : null ,
walletDecryptResult : null
} ) ,
2019-04-03 19:12:51 +02:00
2019-05-10 07:02:03 +02:00
[ WALLET _DECRYPT _COMPLETED ] : ( state , action ) => _extends$7 ( { } , state , {
walletDecryptPending : false ,
walletDecryptSucceded : true ,
walletDecryptResult : action . result
} ) ,
2019-04-03 19:12:51 +02:00
2019-05-10 07:02:03 +02:00
[ WALLET _DECRYPT _FAILED ] : ( state , action ) => _extends$7 ( { } , state , {
walletDecryptPending : false ,
walletDecryptSucceded : false ,
walletDecryptResult : action . result
} ) ,
2019-04-03 19:12:51 +02:00
2019-05-10 07:02:03 +02:00
[ WALLET _UNLOCK _START ] : state => _extends$7 ( { } , state , {
walletUnlockPending : true ,
walletUnlockSucceded : null ,
walletUnlockResult : null
} ) ,
2019-04-03 19:12:51 +02:00
2019-05-10 07:02:03 +02:00
[ WALLET _UNLOCK _COMPLETED ] : ( state , action ) => _extends$7 ( { } , state , {
walletUnlockPending : false ,
walletUnlockSucceded : true ,
walletUnlockResult : action . result
} ) ,
[ WALLET _UNLOCK _FAILED ] : ( state , action ) => _extends$7 ( { } , state , {
walletUnlockPending : false ,
walletUnlockSucceded : false ,
walletUnlockResult : action . result
} ) ,
[ WALLET _LOCK _START ] : state => _extends$7 ( { } , state , {
walletLockPending : false ,
walletLockSucceded : null ,
walletLockResult : null
} ) ,
[ WALLET _LOCK _COMPLETED ] : ( state , action ) => _extends$7 ( { } , state , {
walletLockPending : false ,
walletLockSucceded : true ,
walletLockResult : action . result
} ) ,
[ WALLET _LOCK _FAILED ] : ( state , action ) => _extends$7 ( { } , state , {
walletLockPending : false ,
walletLockSucceded : false ,
walletLockResult : action . result
} ) ,
[ SET _TRANSACTION _LIST _FILTER ] : ( state , action ) => _extends$7 ( { } , state , {
transactionListFilter : action . data
} ) ,
[ UPDATE _CURRENT _HEIGHT ] : ( state , action ) => _extends$7 ( { } , state , {
latestBlock : action . data
} )
} , defaultState$4 ) ;
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 ; } ;
const reducers$2 = { } ;
2019-04-03 19:12:51 +02:00
const defaultState$5 = {
positions : { }
} ;
2019-05-10 07:02:03 +02:00
reducers$2 [ SET _CONTENT _POSITION ] = ( state , action ) => {
2019-04-03 19:12:51 +02:00
const { claimId , outpoint , position } = action . data ;
2019-05-10 07:02:03 +02:00
return _extends$8 ( { } , state , {
positions : _extends$8 ( { } , state . positions , {
[ claimId ] : _extends$8 ( { } , state . positions [ claimId ] , {
2019-04-03 19:12:51 +02:00
[ outpoint ] : position
} )
} )
} ) ;
} ;
function contentReducer ( state = defaultState$5 , action ) {
2019-05-10 07:02:03 +02:00
const handler = reducers$2 [ action . type ] ;
2019-04-03 19:12:51 +02:00
if ( handler ) return handler ( state , action ) ;
return state ;
}
const selectState$4 = state => state . content || { } ;
const makeSelectContentPositionForUri = uri => reselect . createSelector ( selectState$4 , makeSelectClaimForUri ( uri ) , ( state , claim ) => {
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-05-10 07:02:03 +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
const selectState$5 = state => state . notifications || { } ;
const selectToast = reselect . createSelector ( selectState$5 , state => {
if ( state . toasts . length ) {
const { id , params } = state . toasts [ 0 ] ;
2019-05-10 07:02:03 +02:00
return _extends$9 ( {
2019-04-03 19:12:51 +02:00
id
} , params ) ;
}
return null ;
} ) ;
const selectError = reselect . createSelector ( selectState$5 , state => {
if ( state . errors . length ) {
const { error } = state . errors [ 0 ] ;
return {
error
} ;
}
return null ;
} ) ;
exports . ACTIONS = action _types ;
exports . Lbry = lbryProxy ;
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 ;
exports . batchActions = batchActions ;
exports . buildURI = buildURI ;
exports . claimsReducer = claimsReducer ;
exports . contentReducer = contentReducer ;
exports . convertToShareLink = convertToShareLink ;
exports . creditsToString = creditsToString ;
exports . doAbandonClaim = doAbandonClaim ;
exports . doBalanceSubscribe = doBalanceSubscribe ;
exports . doBlurSearchInput = doBlurSearchInput ;
exports . doCheckAddressIsMine = doCheckAddressIsMine ;
2019-04-23 19:22:14 +02:00
exports . doCreateChannel = doCreateChannel ;
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 ;
exports . doFileList = doFileList ;
exports . doFocusSearchInput = doFocusSearchInput ;
exports . doGetNewAddress = doGetNewAddress ;
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-04-18 09:56:16 +02:00
exports . doTotalBalanceSubscribe = doTotalBalanceSubscribe ;
2019-04-03 19:12:51 +02:00
exports . doUpdateBalance = doUpdateBalance ;
exports . doUpdateBlockHeight = doUpdateBlockHeight ;
exports . doUpdateSearchOptions = doUpdateSearchOptions ;
exports . doUpdateSearchQuery = doUpdateSearchQuery ;
2019-04-18 09:56:16 +02:00
exports . doUpdateTotalBalance = doUpdateTotalBalance ;
2019-04-03 19:12:51 +02:00
exports . doWalletDecrypt = doWalletDecrypt ;
exports . doWalletEncrypt = doWalletEncrypt ;
exports . doWalletStatus = doWalletStatus ;
exports . doWalletUnlock = doWalletUnlock ;
exports . fileInfoReducer = fileInfoReducer ;
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 ;
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 ;
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-04-03 19:12:51 +02:00
exports . makeSelectDownloadingForUri = makeSelectDownloadingForUri ;
exports . makeSelectFetchingChannelClaims = makeSelectFetchingChannelClaims ;
exports . makeSelectFileInfoForUri = makeSelectFileInfoForUri ;
exports . makeSelectFirstRecommendedFileForUri = makeSelectFirstRecommendedFileForUri ;
exports . makeSelectIsUriResolving = makeSelectIsUriResolving ;
exports . makeSelectLoadingForUri = makeSelectLoadingForUri ;
exports . makeSelectMetadataForUri = makeSelectMetadataForUri ;
2019-05-06 19:57:07 +02:00
exports . makeSelectMetadataItemForUri = makeSelectMetadataItemForUri ;
2019-04-03 19:12:51 +02:00
exports . makeSelectNsfwCountForChannel = makeSelectNsfwCountForChannel ;
exports . makeSelectNsfwCountFromUris = makeSelectNsfwCountFromUris ;
exports . makeSelectPendingByUri = makeSelectPendingByUri ;
exports . makeSelectQueryWithOptions = makeSelectQueryWithOptions ;
exports . makeSelectRecommendedContentForUri = makeSelectRecommendedContentForUri ;
exports . makeSelectSearchUris = makeSelectSearchUris ;
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 ;
exports . normalizeURI = normalizeURI ;
exports . notificationsReducer = notificationsReducer ;
exports . parseQueryParams = parseQueryParams ;
exports . parseURI = parseURI ;
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 ;
exports . selectBlocks = selectBlocks ;
exports . selectChannelClaimCounts = selectChannelClaimCounts ;
exports . selectClaimsById = selectClaimsById ;
exports . selectClaimsByUri = selectClaimsByUri ;
exports . selectCurrentChannelPage = selectCurrentChannelPage ;
exports . selectDownloadingByOutpoint = selectDownloadingByOutpoint ;
exports . selectDownloadingFileInfos = selectDownloadingFileInfos ;
exports . selectDraftTransaction = selectDraftTransaction ;
exports . selectDraftTransactionAddress = selectDraftTransactionAddress ;
exports . selectDraftTransactionAmount = selectDraftTransactionAmount ;
exports . selectDraftTransactionError = selectDraftTransactionError ;
exports . selectError = selectError ;
exports . selectFetchingMyChannels = selectFetchingMyChannels ;
exports . selectFileInfosByOutpoint = selectFileInfosByOutpoint ;
exports . selectFileInfosDownloaded = selectFileInfosDownloaded ;
exports . selectFileListDownloadedSort = selectFileListDownloadedSort ;
exports . selectFileListPublishedSort = selectFileListPublishedSort ;
exports . selectGettingNewAddress = selectGettingNewAddress ;
exports . selectHasTransactions = selectHasTransactions ;
exports . selectIsFetchingClaimListMine = selectIsFetchingClaimListMine ;
exports . selectIsFetchingFileList = selectIsFetchingFileList ;
exports . selectIsFetchingFileListDownloadedOrPublished = selectIsFetchingFileListDownloadedOrPublished ;
exports . selectIsFetchingTransactions = selectIsFetchingTransactions ;
exports . selectIsSearching = selectIsSearching ;
exports . selectIsSendingSupport = selectIsSendingSupport ;
exports . selectMyActiveClaims = selectMyActiveClaims ;
exports . selectMyChannelClaims = selectMyChannelClaims ;
exports . selectMyClaims = selectMyClaims ;
exports . selectMyClaimsOutpoints = selectMyClaimsOutpoints ;
exports . selectMyClaimsRaw = selectMyClaimsRaw ;
exports . selectMyClaimsWithoutChannels = selectMyClaimsWithoutChannels ;
exports . selectPendingById = selectPendingById ;
exports . selectPendingClaims = selectPendingClaims ;
exports . selectPlayingUri = selectPlayingUri ;
exports . selectReceiveAddress = selectReceiveAddress ;
exports . selectRecentTransactions = selectRecentTransactions ;
exports . selectResolvingUris = selectResolvingUris ;
exports . selectSearchBarFocused = selectSearchBarFocused ;
exports . selectSearchDownloadUris = selectSearchDownloadUris ;
exports . selectSearchOptions = selectSearchOptions ;
exports . selectSearchState = selectState ;
exports . selectSearchSuggestions = selectSearchSuggestions ;
exports . selectSearchUrisByQuery = selectSearchUrisByQuery ;
exports . selectSearchValue = selectSearchValue ;
2019-05-14 06:50:21 +02:00
exports . selectSupportsByOutpoint = selectSupportsByOutpoint ;
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 ;
exports . selectTransactionItems = selectTransactionItems ;
exports . selectTransactionListFilter = selectTransactionListFilter ;
exports . selectTransactionsById = selectTransactionsById ;
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 ;
exports . toQueryString = toQueryString ;
exports . walletReducer = walletReducer ;