2019-04-03 19:12:51 +02:00
'use strict' ;
Object . defineProperty ( exports , '__esModule' , { value : true } ) ;
function _interopDefault ( ex ) { return ( ex && ( typeof ex === 'object' ) && 'default' in ex ) ? ex [ 'default' ] : ex ; }
require ( 'proxy-polyfill' ) ;
var reselect = require ( 'reselect' ) ;
var uuid = _interopDefault ( require ( 'uuid/v4' ) ) ;
2019-07-01 21:49:51 +02:00
const MINIMUM _PUBLISH _BID = 0.00000001 ;
const CHANNEL _ANONYMOUS = 'anonymous' ;
const CHANNEL _NEW = 'new' ;
const PAGE _SIZE = 20 ;
var claim = /*#__PURE__*/ Object . freeze ( {
MINIMUM _PUBLISH _BID : MINIMUM _PUBLISH _BID ,
CHANNEL _ANONYMOUS : CHANNEL _ANONYMOUS ,
CHANNEL _NEW : CHANNEL _NEW ,
PAGE _SIZE : PAGE _SIZE
} ) ;
2019-04-03 19:12:51 +02:00
const WINDOW _FOCUSED = 'WINDOW_FOCUSED' ;
const DAEMON _READY = 'DAEMON_READY' ;
const DAEMON _VERSION _MATCH = 'DAEMON_VERSION_MATCH' ;
const DAEMON _VERSION _MISMATCH = 'DAEMON_VERSION_MISMATCH' ;
const VOLUME _CHANGED = 'VOLUME_CHANGED' ;
2020-02-20 06:57:55 +01:00
const SET _WELCOME _VERSION = 'SET_WELCOME_VERSION' ;
const SET _ALLOW _ANALYTICS = 'SET_ALLOW_ANALYTICS' ;
2019-04-03 19:12:51 +02:00
// 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' ;
2020-04-10 14:16:27 +02:00
const FETCH _TXO _PAGE _STARTED = 'FETCH_TXO_PAGE_STARTED' ;
const FETCH _TXO _PAGE _COMPLETED = 'FETCH_TXO_PAGE_COMPLETED' ;
const FETCH _TXO _PAGE _FAILED = 'FETCH_TXO_PAGE_FAILED' ;
const UPDATE _TXO _FETCH _PARAMS = 'UPDATE_TXO_FETCH_PARAMS' ;
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' ;
2020-03-25 03:46:35 +01:00
const ABANDON _CLAIM _SUPPORT _STARTED = 'ABANDON_CLAIM_SUPPORT_STARTED' ;
const ABANDON _CLAIM _SUPPORT _COMPLETED = 'ABANDON_CLAIM_SUPPORT_COMPLETED' ;
const ABANDON _CLAIM _SUPPORT _FAILED = 'ABANDON_CLAIM_SUPPORT_FAILED' ;
2020-04-01 20:36:11 +02:00
const ABANDON _CLAIM _SUPPORT _PREVIEW = 'ABANDON_CLAIM_SUPPORT_PREVIEW' ;
2020-03-25 03:46:35 +01:00
const PENDING _SUPPORTS _UPDATED = 'PENDING_SUPPORTS_UPDATED' ;
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' ;
2019-10-30 08:55:15 +01:00
const CLEAR _SUPPORT _TRANSACTION = 'CLEAR_SUPPORT_TRANSACTION' ;
2019-04-03 19:12:51 +02:00
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' ;
2019-12-11 15:45:18 +01:00
const WALLET _RESTART = 'WALLET_RESTART' ;
2019-12-11 20:27:52 +01:00
const WALLET _RESTART _COMPLETED = 'WALLET_RESTART_COMPLETED' ;
2019-04-03 19:12:51 +02:00
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' ;
2020-06-01 20:26:07 +02:00
const FETCH _CHANNEL _LIST _FAILED = 'FETCH_CHANNEL_LIST_FAILED' ;
2019-04-03 19:12:51 +02:00
const CREATE _CHANNEL _STARTED = 'CREATE_CHANNEL_STARTED' ;
const CREATE _CHANNEL _COMPLETED = 'CREATE_CHANNEL_COMPLETED' ;
2019-04-23 19:22:14 +02:00
const CREATE _CHANNEL _FAILED = 'CREATE_CHANNEL_FAILED' ;
2019-07-01 03:16:44 +02:00
const UPDATE _CHANNEL _STARTED = 'UPDATE_CHANNEL_STARTED' ;
const UPDATE _CHANNEL _COMPLETED = 'UPDATE_CHANNEL_COMPLETED' ;
const UPDATE _CHANNEL _FAILED = 'UPDATE_CHANNEL_FAILED' ;
2019-09-12 21:06:49 +02:00
const IMPORT _CHANNEL _STARTED = 'IMPORT_CHANNEL_STARTED' ;
const IMPORT _CHANNEL _COMPLETED = 'IMPORT_CHANNEL_COMPLETED' ;
const IMPORT _CHANNEL _FAILED = 'IMPORT_CHANNEL_FAILED' ;
2019-04-03 19:12:51 +02:00
const PUBLISH _STARTED = 'PUBLISH_STARTED' ;
const PUBLISH _COMPLETED = 'PUBLISH_COMPLETED' ;
const PUBLISH _FAILED = 'PUBLISH_FAILED' ;
const SET _PLAYING _URI = 'SET_PLAYING_URI' ;
const SET _CONTENT _POSITION = 'SET_CONTENT_POSITION' ;
const SET _CONTENT _LAST _VIEWED = 'SET_CONTENT_LAST_VIEWED' ;
const CLEAR _CONTENT _HISTORY _URI = 'CLEAR_CONTENT_HISTORY_URI' ;
const CLEAR _CONTENT _HISTORY _ALL = 'CLEAR_CONTENT_HISTORY_ALL' ;
2019-06-10 04:45:47 +02:00
const CLAIM _SEARCH _STARTED = 'CLAIM_SEARCH_STARTED' ;
const CLAIM _SEARCH _COMPLETED = 'CLAIM_SEARCH_COMPLETED' ;
const CLAIM _SEARCH _FAILED = 'CLAIM_SEARCH_FAILED' ;
2019-07-15 04:44:02 +02:00
const CLAIM _SEARCH _BY _TAGS _STARTED = 'CLAIM_SEARCH_BY_TAGS_STARTED' ;
const CLAIM _SEARCH _BY _TAGS _COMPLETED = 'CLAIM_SEARCH_BY_TAGS_COMPLETED' ;
const CLAIM _SEARCH _BY _TAGS _FAILED = 'CLAIM_SEARCH_BY_TAGS_FAILED' ;
2020-02-10 16:49:45 +01:00
const CLAIM _REPOST _STARTED = 'CLAIM_REPOST_STARTED' ;
const CLAIM _REPOST _COMPLETED = 'CLAIM_REPOST_COMPLETED' ;
const CLAIM _REPOST _FAILED = 'CLAIM_REPOST_FAILED' ;
const CLEAR _REPOST _ERROR = 'CLEAR_REPOST_ERROR' ;
2020-04-25 22:31:53 +02:00
const CHECK _PUBLISH _NAME _STARTED = 'CHECK_PUBLISH_NAME_STARTED' ;
const CHECK _PUBLISH _NAME _COMPLETED = 'CHECK_PUBLISH_NAME_COMPLETED' ;
const UPDATE _PENDING _CLAIMS = 'UPDATE_PENDING_CLAIMS' ;
const UPDATE _CONFIRMED _CLAIMS = 'UPDATE_CONFIRMED_CLAIMS' ;
2020-05-07 13:41:56 +02:00
const ADD _FILES _REFLECTING = 'ADD_FILES_REFLECTING' ;
const UPDATE _FILES _REFLECTING = 'UPDATE_FILES_REFLECTING' ;
const TOGGLE _CHECKING _REFLECTING = 'TOGGLE_CHECKING_REFLECTING' ;
const TOGGLE _CHECKING _PENDING = 'TOGGLE_CHECKING_PENDING' ;
2020-05-08 22:47:33 +02:00
const PURCHASE _LIST _STARTED = 'PURCHASE_LIST_STARTED' ;
const PURCHASE _LIST _COMPLETED = 'PURCHASE_LIST_COMPLETED' ;
const PURCHASE _LIST _FAILED = 'PURCHASE_LIST_FAILED' ;
2019-04-03 19:12:51 +02:00
2020-06-29 23:02:19 +02:00
// Comments
const COMMENT _LIST _STARTED = 'COMMENT_LIST_STARTED' ;
const COMMENT _LIST _COMPLETED = 'COMMENT_LIST_COMPLETED' ;
const COMMENT _LIST _FAILED = 'COMMENT_LIST_FAILED' ;
const COMMENT _CREATE _STARTED = 'COMMENT_CREATE_STARTED' ;
const COMMENT _CREATE _COMPLETED = 'COMMENT_CREATE_COMPLETED' ;
const COMMENT _CREATE _FAILED = 'COMMENT_CREATE_FAILED' ;
const COMMENT _ABANDON _STARTED = 'COMMENT_ABANDON_STARTED' ;
const COMMENT _ABANDON _COMPLETED = 'COMMENT_ABANDON_COMPLETED' ;
const COMMENT _ABANDON _FAILED = 'COMMENT_ABANDON_FAILED' ;
const COMMENT _UPDATE _STARTED = 'COMMENT_UPDATE_STARTED' ;
const COMMENT _UPDATE _COMPLETED = 'COMMENT_UPDATE_COMPLETED' ;
const COMMENT _UPDATE _FAILED = 'COMMENT_UPDATE_FAILED' ;
const COMMENT _HIDE _STARTED = 'COMMENT_HIDE_STARTED' ;
const COMMENT _HIDE _COMPLETED = 'COMMENT_HIDE_COMPLETED' ;
const COMMENT _HIDE _FAILED = 'COMMENT_HIDE_FAILED' ;
2019-04-03 19:12:51 +02:00
// Files
const FILE _LIST _STARTED = 'FILE_LIST_STARTED' ;
const FILE _LIST _SUCCEEDED = 'FILE_LIST_SUCCEEDED' ;
const FETCH _FILE _INFO _STARTED = 'FETCH_FILE_INFO_STARTED' ;
const FETCH _FILE _INFO _COMPLETED = 'FETCH_FILE_INFO_COMPLETED' ;
2019-08-13 19:33:32 +02:00
const FETCH _FILE _INFO _FAILED = 'FETCH_FILE_INFO_FAILED' ;
2019-04-03 19:12:51 +02:00
const LOADING _VIDEO _STARTED = 'LOADING_VIDEO_STARTED' ;
const LOADING _VIDEO _COMPLETED = 'LOADING_VIDEO_COMPLETED' ;
const LOADING _VIDEO _FAILED = 'LOADING_VIDEO_FAILED' ;
const DOWNLOADING _STARTED = 'DOWNLOADING_STARTED' ;
const DOWNLOADING _PROGRESSED = 'DOWNLOADING_PROGRESSED' ;
const DOWNLOADING _COMPLETED = 'DOWNLOADING_COMPLETED' ;
const DOWNLOADING _CANCELED = 'DOWNLOADING_CANCELED' ;
const PLAY _VIDEO _STARTED = 'PLAY_VIDEO_STARTED' ;
const FETCH _AVAILABILITY _STARTED = 'FETCH_AVAILABILITY_STARTED' ;
const FETCH _AVAILABILITY _COMPLETED = 'FETCH_AVAILABILITY_COMPLETED' ;
const FILE _DELETE = 'FILE_DELETE' ;
const SET _FILE _LIST _SORT = 'SET_FILE_LIST_SORT' ;
2019-05-21 21:18:07 +02:00
const PURCHASE _URI _STARTED = 'PURCHASE_URI_STARTED' ;
const PURCHASE _URI _COMPLETED = 'PURCHASE_URI_COMPLETED' ;
const PURCHASE _URI _FAILED = 'PURCHASE_URI_FAILED' ;
2020-05-19 04:13:18 +02:00
const CLEAR _PURCHASED _URI _SUCCESS = 'CLEAR_PURCHASED_URI_SUCCESS' ;
2019-04-03 19:12:51 +02:00
// Search
const SEARCH _START = 'SEARCH_START' ;
const SEARCH _SUCCESS = 'SEARCH_SUCCESS' ;
const SEARCH _FAIL = 'SEARCH_FAIL' ;
2020-01-22 02:04:50 +01:00
const RESOLVED _SEARCH _START = 'RESOLVED_SEARCH_START' ;
const RESOLVED _SEARCH _SUCCESS = 'RESOLVED_SEARCH_SUCCESS' ;
const RESOLVED _SEARCH _FAIL = 'RESOLVED_SEARCH_FAIL' ;
2019-04-03 19:12:51 +02:00
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' ;
2019-12-12 20:51:07 +01:00
const DAEMON _STATUS _RECEIVED = 'DAEMON_STATUS_RECEIVED' ;
2019-12-11 15:45:18 +01:00
const SHARED _PREFERENCE _SET = 'SHARED_PREFERENCE_SET' ;
2019-12-12 17:47:09 +01:00
const SAVE _CUSTOM _WALLET _SERVERS = 'SAVE_CUSTOM_WALLET_SERVERS' ;
2019-04-03 19:12:51 +02:00
const CLIENT _SETTING _CHANGED = 'CLIENT_SETTING_CHANGED' ;
const UPDATE _IS _NIGHT = 'UPDATE_IS_NIGHT' ;
// User
const AUTHENTICATION _STARTED = 'AUTHENTICATION_STARTED' ;
const AUTHENTICATION _SUCCESS = 'AUTHENTICATION_SUCCESS' ;
const AUTHENTICATION _FAILURE = 'AUTHENTICATION_FAILURE' ;
const USER _EMAIL _DECLINE = 'USER_EMAIL_DECLINE' ;
const USER _EMAIL _NEW _STARTED = 'USER_EMAIL_NEW_STARTED' ;
const USER _EMAIL _NEW _SUCCESS = 'USER_EMAIL_NEW_SUCCESS' ;
const USER _EMAIL _NEW _EXISTS = 'USER_EMAIL_NEW_EXISTS' ;
const USER _EMAIL _NEW _FAILURE = 'USER_EMAIL_NEW_FAILURE' ;
const USER _EMAIL _VERIFY _SET = 'USER_EMAIL_VERIFY_SET' ;
const USER _EMAIL _VERIFY _STARTED = 'USER_EMAIL_VERIFY_STARTED' ;
const USER _EMAIL _VERIFY _SUCCESS = 'USER_EMAIL_VERIFY_SUCCESS' ;
const USER _EMAIL _VERIFY _FAILURE = 'USER_EMAIL_VERIFY_FAILURE' ;
const USER _EMAIL _VERIFY _RETRY = 'USER_EMAIL_VERIFY_RETRY' ;
const USER _PHONE _RESET = 'USER_PHONE_RESET' ;
const USER _PHONE _NEW _STARTED = 'USER_PHONE_NEW_STARTED' ;
const USER _PHONE _NEW _SUCCESS = 'USER_PHONE_NEW_SUCCESS' ;
const USER _PHONE _NEW _FAILURE = 'USER_PHONE_NEW_FAILURE' ;
const USER _PHONE _VERIFY _STARTED = 'USER_PHONE_VERIFY_STARTED' ;
const USER _PHONE _VERIFY _SUCCESS = 'USER_PHONE_VERIFY_SUCCESS' ;
const USER _PHONE _VERIFY _FAILURE = 'USER_PHONE_VERIFY_FAILURE' ;
const USER _IDENTITY _VERIFY _STARTED = 'USER_IDENTITY_VERIFY_STARTED' ;
const USER _IDENTITY _VERIFY _SUCCESS = 'USER_IDENTITY_VERIFY_SUCCESS' ;
const USER _IDENTITY _VERIFY _FAILURE = 'USER_IDENTITY_VERIFY_FAILURE' ;
const USER _FETCH _STARTED = 'USER_FETCH_STARTED' ;
const USER _FETCH _SUCCESS = 'USER_FETCH_SUCCESS' ;
const USER _FETCH _FAILURE = 'USER_FETCH_FAILURE' ;
const USER _INVITE _STATUS _FETCH _STARTED = 'USER_INVITE_STATUS_FETCH_STARTED' ;
const USER _INVITE _STATUS _FETCH _SUCCESS = 'USER_INVITE_STATUS_FETCH_SUCCESS' ;
const USER _INVITE _STATUS _FETCH _FAILURE = 'USER_INVITE_STATUS_FETCH_FAILURE' ;
const USER _INVITE _NEW _STARTED = 'USER_INVITE_NEW_STARTED' ;
const USER _INVITE _NEW _SUCCESS = 'USER_INVITE_NEW_SUCCESS' ;
const USER _INVITE _NEW _FAILURE = 'USER_INVITE_NEW_FAILURE' ;
const FETCH _ACCESS _TOKEN _SUCCESS = 'FETCH_ACCESS_TOKEN_SUCCESS' ;
// Rewards
const FETCH _REWARDS _STARTED = 'FETCH_REWARDS_STARTED' ;
const FETCH _REWARDS _COMPLETED = 'FETCH_REWARDS_COMPLETED' ;
const CLAIM _REWARD _STARTED = 'CLAIM_REWARD_STARTED' ;
const CLAIM _REWARD _SUCCESS = 'CLAIM_REWARD_SUCCESS' ;
const CLAIM _REWARD _FAILURE = 'CLAIM_REWARD_FAILURE' ;
const CLAIM _REWARD _CLEAR _ERROR = 'CLAIM_REWARD_CLEAR_ERROR' ;
const FETCH _REWARD _CONTENT _COMPLETED = 'FETCH_REWARD_CONTENT_COMPLETED' ;
// Language
const DOWNLOAD _LANGUAGE _SUCCEEDED = 'DOWNLOAD_LANGUAGE_SUCCEEDED' ;
const DOWNLOAD _LANGUAGE _FAILED = 'DOWNLOAD_LANGUAGE_FAILED' ;
// Subscriptions
const CHANNEL _SUBSCRIBE = 'CHANNEL_SUBSCRIBE' ;
const CHANNEL _UNSUBSCRIBE = 'CHANNEL_UNSUBSCRIBE' ;
const HAS _FETCHED _SUBSCRIPTIONS = 'HAS_FETCHED_SUBSCRIPTIONS' ;
const SET _SUBSCRIPTION _LATEST = 'SET_SUBSCRIPTION_LATEST' ;
const SET _SUBSCRIPTION _NOTIFICATION = 'SET_SUBSCRIPTION_NOTIFICATION' ;
const SET _SUBSCRIPTION _NOTIFICATIONS = 'SET_SUBSCRIPTION_NOTIFICATIONS' ;
const CHECK _SUBSCRIPTION _STARTED = 'CHECK_SUBSCRIPTION_STARTED' ;
const CHECK _SUBSCRIPTION _COMPLETED = 'CHECK_SUBSCRIPTION_COMPLETED' ;
const CHECK _SUBSCRIPTIONS _SUBSCRIBE = 'CHECK_SUBSCRIPTIONS_SUBSCRIBE' ;
// Publishing
const CLEAR _PUBLISH = 'CLEAR_PUBLISH' ;
const UPDATE _PUBLISH _FORM = 'UPDATE_PUBLISH_FORM' ;
const PUBLISH _START = 'PUBLISH_START' ;
const PUBLISH _SUCCESS = 'PUBLISH_SUCCESS' ;
const PUBLISH _FAIL = 'PUBLISH_FAIL' ;
const CLEAR _PUBLISH _ERROR = 'CLEAR_PUBLISH_ERROR' ;
const REMOVE _PENDING _PUBLISH = 'REMOVE_PENDING_PUBLISH' ;
const DO _PREPARE _EDIT = 'DO_PREPARE_EDIT' ;
// Notifications
const CREATE _NOTIFICATION = 'CREATE_NOTIFICATION' ;
const EDIT _NOTIFICATION = 'EDIT_NOTIFICATION' ;
const DELETE _NOTIFICATION = 'DELETE_NOTIFICATION' ;
2019-04-18 09:56:16 +02:00
const DISMISS _NOTIFICATION = 'DISMISS_NOTIFICATION' ;
2019-04-03 19:12:51 +02:00
const CREATE _TOAST = 'CREATE_TOAST' ;
const DISMISS _TOAST = 'DISMISS_TOAST' ;
const CREATE _ERROR = 'CREATE_ERROR' ;
const DISMISS _ERROR = 'DISMISS_ERROR' ;
const FETCH _DATE = 'FETCH_DATE' ;
2019-05-21 21:18:07 +02:00
// Cost info
const FETCH _COST _INFO _STARTED = 'FETCH_COST_INFO_STARTED' ;
const FETCH _COST _INFO _COMPLETED = 'FETCH_COST_INFO_COMPLETED' ;
const FETCH _COST _INFO _FAILED = 'FETCH_COST_INFO_FAILED' ;
2019-09-10 20:14:40 +02:00
2019-06-10 04:45:47 +02:00
// Tags
const TOGGLE _TAG _FOLLOW = 'TOGGLE_TAG_FOLLOW' ;
const TAG _ADD = 'TAG_ADD' ;
const TAG _DELETE = 'TAG_DELETE' ;
2019-09-10 20:14:40 +02:00
2020-06-29 23:02:19 +02:00
// Blocked Channels
const TOGGLE _BLOCK _CHANNEL = 'TOGGLE_BLOCK_CHANNEL' ;
2019-09-10 20:14:40 +02:00
// Sync
2019-09-13 21:52:52 +02:00
const USER _STATE _POPULATE = 'USER_STATE_POPULATE' ;
2019-09-10 20:14:40 +02:00
2020-01-29 20:18:15 +01:00
var action _types = /*#__PURE__*/ Object . freeze ( {
2019-07-01 21:49:51 +02:00
WINDOW _FOCUSED : WINDOW _FOCUSED ,
DAEMON _READY : DAEMON _READY ,
DAEMON _VERSION _MATCH : DAEMON _VERSION _MATCH ,
DAEMON _VERSION _MISMATCH : DAEMON _VERSION _MISMATCH ,
VOLUME _CHANGED : VOLUME _CHANGED ,
2020-02-20 06:57:55 +01:00
SET _WELCOME _VERSION : SET _WELCOME _VERSION ,
SET _ALLOW _ANALYTICS : SET _ALLOW _ANALYTICS ,
2019-07-01 21:49:51 +02:00
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 ,
2020-04-10 14:16:27 +02:00
FETCH _TXO _PAGE _STARTED : FETCH _TXO _PAGE _STARTED ,
FETCH _TXO _PAGE _COMPLETED : FETCH _TXO _PAGE _COMPLETED ,
FETCH _TXO _PAGE _FAILED : FETCH _TXO _PAGE _FAILED ,
UPDATE _TXO _FETCH _PARAMS : UPDATE _TXO _FETCH _PARAMS ,
2019-07-01 21:49:51 +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 ,
2020-03-25 03:46:35 +01:00
ABANDON _CLAIM _SUPPORT _STARTED : ABANDON _CLAIM _SUPPORT _STARTED ,
ABANDON _CLAIM _SUPPORT _COMPLETED : ABANDON _CLAIM _SUPPORT _COMPLETED ,
ABANDON _CLAIM _SUPPORT _FAILED : ABANDON _CLAIM _SUPPORT _FAILED ,
2020-04-01 20:36:11 +02:00
ABANDON _CLAIM _SUPPORT _PREVIEW : ABANDON _CLAIM _SUPPORT _PREVIEW ,
2020-03-25 03:46:35 +01:00
PENDING _SUPPORTS _UPDATED : PENDING _SUPPORTS _UPDATED ,
2019-07-01 21:49:51 +02:00
UPDATE _BALANCE : UPDATE _BALANCE ,
UPDATE _TOTAL _BALANCE : UPDATE _TOTAL _BALANCE ,
CHECK _ADDRESS _IS _MINE _STARTED : CHECK _ADDRESS _IS _MINE _STARTED ,
CHECK _ADDRESS _IS _MINE _COMPLETED : CHECK _ADDRESS _IS _MINE _COMPLETED ,
SEND _TRANSACTION _STARTED : SEND _TRANSACTION _STARTED ,
SEND _TRANSACTION _COMPLETED : SEND _TRANSACTION _COMPLETED ,
SEND _TRANSACTION _FAILED : SEND _TRANSACTION _FAILED ,
SUPPORT _TRANSACTION _STARTED : SUPPORT _TRANSACTION _STARTED ,
SUPPORT _TRANSACTION _COMPLETED : SUPPORT _TRANSACTION _COMPLETED ,
SUPPORT _TRANSACTION _FAILED : SUPPORT _TRANSACTION _FAILED ,
2019-10-30 08:55:15 +01:00
CLEAR _SUPPORT _TRANSACTION : CLEAR _SUPPORT _TRANSACTION ,
2019-07-01 21:49:51 +02:00
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 ,
2019-12-11 15:45:18 +01:00
WALLET _RESTART : WALLET _RESTART ,
2019-12-11 20:27:52 +01:00
WALLET _RESTART _COMPLETED : WALLET _RESTART _COMPLETED ,
2019-07-01 21:49:51 +02:00
SET _TRANSACTION _LIST _FILTER : SET _TRANSACTION _LIST _FILTER ,
UPDATE _CURRENT _HEIGHT : UPDATE _CURRENT _HEIGHT ,
SET _DRAFT _TRANSACTION _AMOUNT : SET _DRAFT _TRANSACTION _AMOUNT ,
SET _DRAFT _TRANSACTION _ADDRESS : SET _DRAFT _TRANSACTION _ADDRESS ,
RESOLVE _URIS _STARTED : RESOLVE _URIS _STARTED ,
RESOLVE _URIS _COMPLETED : RESOLVE _URIS _COMPLETED ,
FETCH _CHANNEL _CLAIMS _STARTED : FETCH _CHANNEL _CLAIMS _STARTED ,
FETCH _CHANNEL _CLAIMS _COMPLETED : FETCH _CHANNEL _CLAIMS _COMPLETED ,
FETCH _CLAIM _LIST _MINE _STARTED : FETCH _CLAIM _LIST _MINE _STARTED ,
FETCH _CLAIM _LIST _MINE _COMPLETED : FETCH _CLAIM _LIST _MINE _COMPLETED ,
ABANDON _CLAIM _STARTED : ABANDON _CLAIM _STARTED ,
ABANDON _CLAIM _SUCCEEDED : ABANDON _CLAIM _SUCCEEDED ,
FETCH _CHANNEL _LIST _STARTED : FETCH _CHANNEL _LIST _STARTED ,
FETCH _CHANNEL _LIST _COMPLETED : FETCH _CHANNEL _LIST _COMPLETED ,
2020-06-01 20:26:07 +02:00
FETCH _CHANNEL _LIST _FAILED : FETCH _CHANNEL _LIST _FAILED ,
2019-07-01 21:49:51 +02:00
CREATE _CHANNEL _STARTED : CREATE _CHANNEL _STARTED ,
CREATE _CHANNEL _COMPLETED : CREATE _CHANNEL _COMPLETED ,
CREATE _CHANNEL _FAILED : CREATE _CHANNEL _FAILED ,
2019-07-01 03:16:44 +02:00
UPDATE _CHANNEL _STARTED : UPDATE _CHANNEL _STARTED ,
UPDATE _CHANNEL _COMPLETED : UPDATE _CHANNEL _COMPLETED ,
UPDATE _CHANNEL _FAILED : UPDATE _CHANNEL _FAILED ,
2019-09-12 21:06:49 +02:00
IMPORT _CHANNEL _STARTED : IMPORT _CHANNEL _STARTED ,
IMPORT _CHANNEL _COMPLETED : IMPORT _CHANNEL _COMPLETED ,
IMPORT _CHANNEL _FAILED : IMPORT _CHANNEL _FAILED ,
2019-07-01 21:49:51 +02:00
PUBLISH _STARTED : PUBLISH _STARTED ,
PUBLISH _COMPLETED : PUBLISH _COMPLETED ,
PUBLISH _FAILED : PUBLISH _FAILED ,
SET _PLAYING _URI : SET _PLAYING _URI ,
SET _CONTENT _POSITION : SET _CONTENT _POSITION ,
SET _CONTENT _LAST _VIEWED : SET _CONTENT _LAST _VIEWED ,
CLEAR _CONTENT _HISTORY _URI : CLEAR _CONTENT _HISTORY _URI ,
CLEAR _CONTENT _HISTORY _ALL : CLEAR _CONTENT _HISTORY _ALL ,
CLAIM _SEARCH _STARTED : CLAIM _SEARCH _STARTED ,
CLAIM _SEARCH _COMPLETED : CLAIM _SEARCH _COMPLETED ,
CLAIM _SEARCH _FAILED : CLAIM _SEARCH _FAILED ,
2019-07-15 04:44:02 +02:00
CLAIM _SEARCH _BY _TAGS _STARTED : CLAIM _SEARCH _BY _TAGS _STARTED ,
CLAIM _SEARCH _BY _TAGS _COMPLETED : CLAIM _SEARCH _BY _TAGS _COMPLETED ,
CLAIM _SEARCH _BY _TAGS _FAILED : CLAIM _SEARCH _BY _TAGS _FAILED ,
2020-02-10 16:49:45 +01:00
CLAIM _REPOST _STARTED : CLAIM _REPOST _STARTED ,
CLAIM _REPOST _COMPLETED : CLAIM _REPOST _COMPLETED ,
CLAIM _REPOST _FAILED : CLAIM _REPOST _FAILED ,
CLEAR _REPOST _ERROR : CLEAR _REPOST _ERROR ,
2020-04-25 22:31:53 +02:00
CHECK _PUBLISH _NAME _STARTED : CHECK _PUBLISH _NAME _STARTED ,
CHECK _PUBLISH _NAME _COMPLETED : CHECK _PUBLISH _NAME _COMPLETED ,
UPDATE _PENDING _CLAIMS : UPDATE _PENDING _CLAIMS ,
UPDATE _CONFIRMED _CLAIMS : UPDATE _CONFIRMED _CLAIMS ,
2020-05-07 13:41:56 +02:00
ADD _FILES _REFLECTING : ADD _FILES _REFLECTING ,
UPDATE _FILES _REFLECTING : UPDATE _FILES _REFLECTING ,
TOGGLE _CHECKING _REFLECTING : TOGGLE _CHECKING _REFLECTING ,
TOGGLE _CHECKING _PENDING : TOGGLE _CHECKING _PENDING ,
2020-05-08 22:47:33 +02:00
PURCHASE _LIST _STARTED : PURCHASE _LIST _STARTED ,
PURCHASE _LIST _COMPLETED : PURCHASE _LIST _COMPLETED ,
PURCHASE _LIST _FAILED : PURCHASE _LIST _FAILED ,
2020-06-29 23:02:19 +02:00
COMMENT _LIST _STARTED : COMMENT _LIST _STARTED ,
COMMENT _LIST _COMPLETED : COMMENT _LIST _COMPLETED ,
COMMENT _LIST _FAILED : COMMENT _LIST _FAILED ,
COMMENT _CREATE _STARTED : COMMENT _CREATE _STARTED ,
COMMENT _CREATE _COMPLETED : COMMENT _CREATE _COMPLETED ,
COMMENT _CREATE _FAILED : COMMENT _CREATE _FAILED ,
COMMENT _ABANDON _STARTED : COMMENT _ABANDON _STARTED ,
COMMENT _ABANDON _COMPLETED : COMMENT _ABANDON _COMPLETED ,
COMMENT _ABANDON _FAILED : COMMENT _ABANDON _FAILED ,
COMMENT _UPDATE _STARTED : COMMENT _UPDATE _STARTED ,
COMMENT _UPDATE _COMPLETED : COMMENT _UPDATE _COMPLETED ,
COMMENT _UPDATE _FAILED : COMMENT _UPDATE _FAILED ,
COMMENT _HIDE _STARTED : COMMENT _HIDE _STARTED ,
COMMENT _HIDE _COMPLETED : COMMENT _HIDE _COMPLETED ,
COMMENT _HIDE _FAILED : COMMENT _HIDE _FAILED ,
2019-07-01 21:49:51 +02:00
FILE _LIST _STARTED : FILE _LIST _STARTED ,
FILE _LIST _SUCCEEDED : FILE _LIST _SUCCEEDED ,
FETCH _FILE _INFO _STARTED : FETCH _FILE _INFO _STARTED ,
FETCH _FILE _INFO _COMPLETED : FETCH _FILE _INFO _COMPLETED ,
2019-08-13 19:33:32 +02:00
FETCH _FILE _INFO _FAILED : FETCH _FILE _INFO _FAILED ,
2019-07-01 21:49:51 +02:00
LOADING _VIDEO _STARTED : LOADING _VIDEO _STARTED ,
LOADING _VIDEO _COMPLETED : LOADING _VIDEO _COMPLETED ,
LOADING _VIDEO _FAILED : LOADING _VIDEO _FAILED ,
DOWNLOADING _STARTED : DOWNLOADING _STARTED ,
DOWNLOADING _PROGRESSED : DOWNLOADING _PROGRESSED ,
DOWNLOADING _COMPLETED : DOWNLOADING _COMPLETED ,
DOWNLOADING _CANCELED : DOWNLOADING _CANCELED ,
PLAY _VIDEO _STARTED : PLAY _VIDEO _STARTED ,
FETCH _AVAILABILITY _STARTED : FETCH _AVAILABILITY _STARTED ,
FETCH _AVAILABILITY _COMPLETED : FETCH _AVAILABILITY _COMPLETED ,
FILE _DELETE : FILE _DELETE ,
SET _FILE _LIST _SORT : SET _FILE _LIST _SORT ,
PURCHASE _URI _STARTED : PURCHASE _URI _STARTED ,
PURCHASE _URI _COMPLETED : PURCHASE _URI _COMPLETED ,
PURCHASE _URI _FAILED : PURCHASE _URI _FAILED ,
2020-05-19 04:13:18 +02:00
CLEAR _PURCHASED _URI _SUCCESS : CLEAR _PURCHASED _URI _SUCCESS ,
2019-07-01 21:49:51 +02:00
SEARCH _START : SEARCH _START ,
SEARCH _SUCCESS : SEARCH _SUCCESS ,
SEARCH _FAIL : SEARCH _FAIL ,
2020-01-22 02:04:50 +01:00
RESOLVED _SEARCH _START : RESOLVED _SEARCH _START ,
RESOLVED _SEARCH _SUCCESS : RESOLVED _SEARCH _SUCCESS ,
RESOLVED _SEARCH _FAIL : RESOLVED _SEARCH _FAIL ,
2019-07-01 21:49:51 +02:00
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 ,
2019-12-12 20:51:07 +01:00
DAEMON _STATUS _RECEIVED : DAEMON _STATUS _RECEIVED ,
2019-12-11 15:45:18 +01:00
SHARED _PREFERENCE _SET : SHARED _PREFERENCE _SET ,
2019-12-12 17:47:09 +01:00
SAVE _CUSTOM _WALLET _SERVERS : SAVE _CUSTOM _WALLET _SERVERS ,
2019-07-01 21:49:51 +02:00
CLIENT _SETTING _CHANGED : CLIENT _SETTING _CHANGED ,
UPDATE _IS _NIGHT : UPDATE _IS _NIGHT ,
AUTHENTICATION _STARTED : AUTHENTICATION _STARTED ,
AUTHENTICATION _SUCCESS : AUTHENTICATION _SUCCESS ,
AUTHENTICATION _FAILURE : AUTHENTICATION _FAILURE ,
USER _EMAIL _DECLINE : USER _EMAIL _DECLINE ,
USER _EMAIL _NEW _STARTED : USER _EMAIL _NEW _STARTED ,
USER _EMAIL _NEW _SUCCESS : USER _EMAIL _NEW _SUCCESS ,
USER _EMAIL _NEW _EXISTS : USER _EMAIL _NEW _EXISTS ,
USER _EMAIL _NEW _FAILURE : USER _EMAIL _NEW _FAILURE ,
USER _EMAIL _VERIFY _SET : USER _EMAIL _VERIFY _SET ,
USER _EMAIL _VERIFY _STARTED : USER _EMAIL _VERIFY _STARTED ,
USER _EMAIL _VERIFY _SUCCESS : USER _EMAIL _VERIFY _SUCCESS ,
USER _EMAIL _VERIFY _FAILURE : USER _EMAIL _VERIFY _FAILURE ,
USER _EMAIL _VERIFY _RETRY : USER _EMAIL _VERIFY _RETRY ,
USER _PHONE _RESET : USER _PHONE _RESET ,
USER _PHONE _NEW _STARTED : USER _PHONE _NEW _STARTED ,
USER _PHONE _NEW _SUCCESS : USER _PHONE _NEW _SUCCESS ,
USER _PHONE _NEW _FAILURE : USER _PHONE _NEW _FAILURE ,
USER _PHONE _VERIFY _STARTED : USER _PHONE _VERIFY _STARTED ,
USER _PHONE _VERIFY _SUCCESS : USER _PHONE _VERIFY _SUCCESS ,
USER _PHONE _VERIFY _FAILURE : USER _PHONE _VERIFY _FAILURE ,
USER _IDENTITY _VERIFY _STARTED : USER _IDENTITY _VERIFY _STARTED ,
USER _IDENTITY _VERIFY _SUCCESS : USER _IDENTITY _VERIFY _SUCCESS ,
USER _IDENTITY _VERIFY _FAILURE : USER _IDENTITY _VERIFY _FAILURE ,
USER _FETCH _STARTED : USER _FETCH _STARTED ,
USER _FETCH _SUCCESS : USER _FETCH _SUCCESS ,
USER _FETCH _FAILURE : USER _FETCH _FAILURE ,
USER _INVITE _STATUS _FETCH _STARTED : USER _INVITE _STATUS _FETCH _STARTED ,
USER _INVITE _STATUS _FETCH _SUCCESS : USER _INVITE _STATUS _FETCH _SUCCESS ,
USER _INVITE _STATUS _FETCH _FAILURE : USER _INVITE _STATUS _FETCH _FAILURE ,
USER _INVITE _NEW _STARTED : USER _INVITE _NEW _STARTED ,
USER _INVITE _NEW _SUCCESS : USER _INVITE _NEW _SUCCESS ,
USER _INVITE _NEW _FAILURE : USER _INVITE _NEW _FAILURE ,
FETCH _ACCESS _TOKEN _SUCCESS : FETCH _ACCESS _TOKEN _SUCCESS ,
FETCH _REWARDS _STARTED : FETCH _REWARDS _STARTED ,
FETCH _REWARDS _COMPLETED : FETCH _REWARDS _COMPLETED ,
CLAIM _REWARD _STARTED : CLAIM _REWARD _STARTED ,
CLAIM _REWARD _SUCCESS : CLAIM _REWARD _SUCCESS ,
CLAIM _REWARD _FAILURE : CLAIM _REWARD _FAILURE ,
CLAIM _REWARD _CLEAR _ERROR : CLAIM _REWARD _CLEAR _ERROR ,
FETCH _REWARD _CONTENT _COMPLETED : FETCH _REWARD _CONTENT _COMPLETED ,
DOWNLOAD _LANGUAGE _SUCCEEDED : DOWNLOAD _LANGUAGE _SUCCEEDED ,
DOWNLOAD _LANGUAGE _FAILED : DOWNLOAD _LANGUAGE _FAILED ,
CHANNEL _SUBSCRIBE : CHANNEL _SUBSCRIBE ,
CHANNEL _UNSUBSCRIBE : CHANNEL _UNSUBSCRIBE ,
HAS _FETCHED _SUBSCRIPTIONS : HAS _FETCHED _SUBSCRIPTIONS ,
SET _SUBSCRIPTION _LATEST : SET _SUBSCRIPTION _LATEST ,
SET _SUBSCRIPTION _NOTIFICATION : SET _SUBSCRIPTION _NOTIFICATION ,
SET _SUBSCRIPTION _NOTIFICATIONS : SET _SUBSCRIPTION _NOTIFICATIONS ,
CHECK _SUBSCRIPTION _STARTED : CHECK _SUBSCRIPTION _STARTED ,
CHECK _SUBSCRIPTION _COMPLETED : CHECK _SUBSCRIPTION _COMPLETED ,
CHECK _SUBSCRIPTIONS _SUBSCRIBE : CHECK _SUBSCRIPTIONS _SUBSCRIBE ,
CLEAR _PUBLISH : CLEAR _PUBLISH ,
UPDATE _PUBLISH _FORM : UPDATE _PUBLISH _FORM ,
PUBLISH _START : PUBLISH _START ,
PUBLISH _SUCCESS : PUBLISH _SUCCESS ,
PUBLISH _FAIL : PUBLISH _FAIL ,
CLEAR _PUBLISH _ERROR : CLEAR _PUBLISH _ERROR ,
REMOVE _PENDING _PUBLISH : REMOVE _PENDING _PUBLISH ,
DO _PREPARE _EDIT : DO _PREPARE _EDIT ,
CREATE _NOTIFICATION : CREATE _NOTIFICATION ,
EDIT _NOTIFICATION : EDIT _NOTIFICATION ,
DELETE _NOTIFICATION : DELETE _NOTIFICATION ,
DISMISS _NOTIFICATION : DISMISS _NOTIFICATION ,
CREATE _TOAST : CREATE _TOAST ,
DISMISS _TOAST : DISMISS _TOAST ,
CREATE _ERROR : CREATE _ERROR ,
DISMISS _ERROR : DISMISS _ERROR ,
FETCH _DATE : FETCH _DATE ,
FETCH _COST _INFO _STARTED : FETCH _COST _INFO _STARTED ,
FETCH _COST _INFO _COMPLETED : FETCH _COST _INFO _COMPLETED ,
FETCH _COST _INFO _FAILED : FETCH _COST _INFO _FAILED ,
TOGGLE _TAG _FOLLOW : TOGGLE _TAG _FOLLOW ,
TAG _ADD : TAG _ADD ,
2019-08-02 02:57:27 +02:00
TAG _DELETE : TAG _DELETE ,
2020-06-29 23:02:19 +02:00
TOGGLE _BLOCK _CHANNEL : TOGGLE _BLOCK _CHANNEL ,
2019-09-13 21:52:52 +02:00
USER _STATE _POPULATE : USER _STATE _POPULATE
2019-04-03 19:12:51 +02:00
} ) ;
2019-07-01 21:49:51 +02:00
const CC _LICENSES = [ {
value : 'Creative Commons Attribution 4.0 International' ,
url : 'https://creativecommons.org/licenses/by/4.0/legalcode'
} , {
value : 'Creative Commons Attribution-ShareAlike 4.0 International' ,
url : 'https://creativecommons.org/licenses/by-sa/4.0/legalcode'
} , {
value : 'Creative Commons Attribution-NoDerivatives 4.0 International' ,
url : 'https://creativecommons.org/licenses/by-nd/4.0/legalcode'
} , {
value : 'Creative Commons Attribution-NonCommercial 4.0 International' ,
url : 'https://creativecommons.org/licenses/by-nc/4.0/legalcode'
} , {
value : 'Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International' ,
url : 'https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode'
} , {
value : 'Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International' ,
url : 'https://creativecommons.org/licenses/by-nc-nd/4.0/legalcode'
} ] ;
const NONE = 'None' ;
const PUBLIC _DOMAIN = 'Public Domain' ;
const OTHER = 'other' ;
const COPYRIGHT = 'copyright' ;
var licenses = /*#__PURE__*/ Object . freeze ( {
CC _LICENSES : CC _LICENSES ,
NONE : NONE ,
PUBLIC _DOMAIN : PUBLIC _DOMAIN ,
OTHER : OTHER ,
COPYRIGHT : COPYRIGHT
} ) ;
2019-04-03 19:12:51 +02:00
2019-07-01 21:49:51 +02:00
const AUTH = 'auth' ;
const BACKUP = 'backup' ;
const CHANNEL = 'channel' ;
const DISCOVER = 'discover' ;
const FILE = 'file' ;
const DOWNLOADED = 'downloaded' ;
const PUBLISHED = 'published' ;
const GET _CREDITS = 'getcredits' ;
const HELP = 'help' ;
const INVITE = 'invite' ;
const PUBLISH = 'publish' ;
const REPORT = 'report' ;
const REWARDS = 'rewards' ;
const SEARCH = 'search' ;
const SEND _CREDITS = 'send' ;
const SETTINGS = 'settings' ;
const SHOW = 'show' ;
const SUBSCRIPTIONS = 'subscriptions' ;
const TRANSACTION _HISTORY = 'history' ;
const HISTORY = 'user_history' ;
const WALLET = 'wallet' ;
var pages = /*#__PURE__*/ Object . freeze ( {
AUTH : AUTH ,
BACKUP : BACKUP ,
CHANNEL : CHANNEL ,
DISCOVER : DISCOVER ,
FILE : FILE ,
DOWNLOADED : DOWNLOADED ,
PUBLISHED : PUBLISHED ,
GET _CREDITS : GET _CREDITS ,
HELP : HELP ,
INVITE : INVITE ,
PUBLISH : PUBLISH ,
REPORT : REPORT ,
REWARDS : REWARDS ,
SEARCH : SEARCH ,
SEND _CREDITS : SEND _CREDITS ,
SETTINGS : SETTINGS ,
SHOW : SHOW ,
SUBSCRIPTIONS : SUBSCRIPTIONS ,
TRANSACTION _HISTORY : TRANSACTION _HISTORY ,
HISTORY : HISTORY ,
WALLET : WALLET
2019-04-03 19:12:51 +02:00
} ) ;
/* hardcoded names still exist for these in reducers/settings.js - only discovered when debugging */
/ * M a n y S E T T I N G S a r e s t o r e d i n t h e l o c a l S t o r a g e b y t h e i r n a m e -
be careful about changing the value of a SETTINGS constant , as doing so can invalidate existing SETTINGS * /
2020-02-16 20:52:58 +01:00
const SHOW _NSFW = 'showNsfw' ;
2019-04-03 19:12:51 +02:00
const CREDIT _REQUIRED _ACKNOWLEDGED = 'credit_required_acknowledged' ;
const NEW _USER _ACKNOWLEDGED = 'welcome_acknowledged' ;
const EMAIL _COLLECTION _ACKNOWLEDGED = 'email_collection_acknowledged' ;
2020-02-16 20:52:58 +01:00
const INVITE _ACKNOWLEDGED = 'invite_acknowledged' ;
2019-04-03 19:12:51 +02:00
const LANGUAGE = 'language' ;
2020-02-16 20:52:58 +01:00
const SHOW _MATURE = 'show_mature' ;
2020-04-27 15:44:59 +02:00
const HIDE _REPOSTS = 'hide_reposts' ;
2020-02-16 20:52:58 +01:00
const SHOW _ANONYMOUS = 'show_anonymous' ;
const SHOW _UNAVAILABLE = 'show_unavailable' ;
const INSTANT _PURCHASE _ENABLED = 'instant_purchase_enabled' ;
const INSTANT _PURCHASE _MAX = 'instant_purchase_max' ;
2019-04-03 19:12:51 +02:00
const THEME = 'theme' ;
const THEMES = 'themes' ;
2020-02-16 20:52:58 +01:00
const AUTOMATIC _DARK _MODE _ENABLED = 'automatic_dark_mode_enabled' ;
const AUTOPLAY = 'autoplay' ;
const OS _NOTIFICATIONS _ENABLED = 'os_notifications_enabled' ;
const AUTO _DOWNLOAD = 'auto_download' ;
const AUTO _LAUNCH = 'auto_launch' ;
const SUPPORT _OPTION = 'support_option' ;
const HIDE _BALANCE = 'hide_balance' ;
const HIDE _SPLASH _ANIMATION = 'hide_splash_animation' ;
const FLOATING _PLAYER = 'floating_player' ;
const DARK _MODE _TIMES = 'dark_mode_times' ;
const ENABLE _SYNC = 'enable_sync' ;
2019-04-03 19:12:51 +02:00
// mobile settings
const BACKGROUND _PLAY _ENABLED = 'backgroundPlayEnabled' ;
const FOREGROUND _NOTIFICATION _ENABLED = 'foregroundNotificationEnabled' ;
const KEEP _DAEMON _RUNNING = 'keepDaemonRunning' ;
2019-10-15 14:03:07 +02:00
const SHOW _URI _BAR _SUGGESTIONS = 'showUriBarSuggestions' ;
2019-10-24 12:31:59 +02:00
const RECEIVE _SUBSCRIPTION _NOTIFICATIONS = 'receiveSubscriptionNotifications' ;
const RECEIVE _REWARD _NOTIFICATIONS = 'receiveRewardNotifications' ;
const RECEIVE _INTERESTS _NOTIFICATIONS = 'receiveInterestsNotifications' ;
const RECEIVE _CREATOR _NOTIFICATIONS = 'receiveCreatorNotifications' ;
2019-04-03 19:12:51 +02:00
var settings = /*#__PURE__*/ Object . freeze ( {
2020-02-16 20:52:58 +01:00
SHOW _NSFW : SHOW _NSFW ,
2019-07-01 21:49:51 +02:00
CREDIT _REQUIRED _ACKNOWLEDGED : CREDIT _REQUIRED _ACKNOWLEDGED ,
NEW _USER _ACKNOWLEDGED : NEW _USER _ACKNOWLEDGED ,
EMAIL _COLLECTION _ACKNOWLEDGED : EMAIL _COLLECTION _ACKNOWLEDGED ,
2020-02-16 20:52:58 +01:00
INVITE _ACKNOWLEDGED : INVITE _ACKNOWLEDGED ,
2019-07-01 21:49:51 +02:00
LANGUAGE : LANGUAGE ,
2020-02-16 20:52:58 +01:00
SHOW _MATURE : SHOW _MATURE ,
2020-04-27 15:44:59 +02:00
HIDE _REPOSTS : HIDE _REPOSTS ,
2020-02-16 20:52:58 +01:00
SHOW _ANONYMOUS : SHOW _ANONYMOUS ,
2019-07-01 21:49:51 +02:00
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 ,
2020-02-16 20:52:58 +01:00
AUTOPLAY : AUTOPLAY ,
OS _NOTIFICATIONS _ENABLED : OS _NOTIFICATIONS _ENABLED ,
AUTO _DOWNLOAD : AUTO _DOWNLOAD ,
AUTO _LAUNCH : AUTO _LAUNCH ,
SUPPORT _OPTION : SUPPORT _OPTION ,
HIDE _BALANCE : HIDE _BALANCE ,
HIDE _SPLASH _ANIMATION : HIDE _SPLASH _ANIMATION ,
FLOATING _PLAYER : FLOATING _PLAYER ,
DARK _MODE _TIMES : DARK _MODE _TIMES ,
ENABLE _SYNC : ENABLE _SYNC ,
2019-07-01 21:49:51 +02:00
BACKGROUND _PLAY _ENABLED : BACKGROUND _PLAY _ENABLED ,
FOREGROUND _NOTIFICATION _ENABLED : FOREGROUND _NOTIFICATION _ENABLED ,
2019-10-15 14:03:07 +02:00
KEEP _DAEMON _RUNNING : KEEP _DAEMON _RUNNING ,
2019-10-24 12:31:59 +02:00
SHOW _URI _BAR _SUGGESTIONS : SHOW _URI _BAR _SUGGESTIONS ,
RECEIVE _SUBSCRIPTION _NOTIFICATIONS : RECEIVE _SUBSCRIPTION _NOTIFICATIONS ,
RECEIVE _REWARD _NOTIFICATIONS : RECEIVE _REWARD _NOTIFICATIONS ,
RECEIVE _INTERESTS _NOTIFICATIONS : RECEIVE _INTERESTS _NOTIFICATIONS ,
RECEIVE _CREATOR _NOTIFICATIONS : RECEIVE _CREATOR _NOTIFICATIONS
2019-04-03 19:12:51 +02:00
} ) ;
const DATE _NEW = 'dateNew' ;
const DATE _OLD = 'dateOld' ;
const TITLE = 'title' ;
const FILENAME = 'filename' ;
var sort _options = /*#__PURE__*/ Object . freeze ( {
2019-07-01 21:49:51 +02:00
DATE _NEW : DATE _NEW ,
DATE _OLD : DATE _OLD ,
TITLE : TITLE ,
FILENAME : FILENAME
2019-04-03 19:12:51 +02:00
} ) ;
2019-07-01 21:49:51 +02:00
const API _DOWN = 'apiDown' ;
const READY = 'ready' ;
const IN _PROGRESS = 'inProgress' ;
const COMPLETE = 'complete' ;
const MANUAL = 'manual' ;
var thumbnail _upload _statuses = /*#__PURE__*/ Object . freeze ( {
API _DOWN : API _DOWN ,
READY : READY ,
IN _PROGRESS : IN _PROGRESS ,
COMPLETE : COMPLETE ,
MANUAL : MANUAL
} ) ;
// eslint-disable-next-line import/prefer-default-export
const ALL = 'all' ;
const SPEND = 'spend' ;
const RECEIVE = 'receive' ;
2019-04-03 19:12:51 +02:00
const PUBLISH$1 = 'publish' ;
2019-07-01 21:49:51 +02:00
const CHANNEL$1 = 'channel' ;
const TIP = 'tip' ;
const SUPPORT = 'support' ;
const UPDATE = 'update' ;
const ABANDON = 'abandon' ;
2019-04-03 19:12:51 +02:00
2019-07-01 21:49:51 +02:00
var transaction _types = /*#__PURE__*/ Object . freeze ( {
ALL : ALL ,
SPEND : SPEND ,
RECEIVE : RECEIVE ,
PUBLISH : PUBLISH$1 ,
CHANNEL : CHANNEL$1 ,
TIP : TIP ,
SUPPORT : SUPPORT ,
UPDATE : UPDATE ,
ABANDON : ABANDON
2019-04-03 19:12:51 +02:00
} ) ;
2019-09-25 18:30:26 +02:00
// PAGE SIZE
const PAGE _SIZE$1 = 50 ;
2019-11-01 18:17:55 +01:00
const LATEST _PAGE _SIZE = 20 ;
2019-09-25 18:30:26 +02:00
var transaction _list = /*#__PURE__*/ Object . freeze ( {
2019-11-01 18:17:55 +01:00
PAGE _SIZE : PAGE _SIZE$1 ,
LATEST _PAGE _SIZE : LATEST _PAGE _SIZE
2019-09-25 18:30:26 +02:00
} ) ;
2020-04-14 22:26:15 +02:00
const PENDING = 'pending' ;
const DONE = 'done' ;
const READY$1 = 'ready' ;
const ERROR = 'error' ;
2020-04-25 22:31:53 +02:00
var abandon _states = /*#__PURE__*/ Object . freeze ( {
2020-04-14 22:26:15 +02:00
PENDING : PENDING ,
DONE : DONE ,
READY : READY$1 ,
ERROR : ERROR
} ) ;
2020-04-10 14:16:27 +02:00
const ACTIVE = 'active' ; // spent, active, all
const TYPE = 'type' ; // all, payment, support, channel, stream, repost
const SUB _TYPE = 'subtype' ; // other, purchase, tip
const PAGE _SIZE$2 = 'page_size' ;
const PAGE = 'page' ;
const ALL$1 = 'all' ;
// dropdown types
const SENT = 'sent' ;
const RECEIVED = 'received' ;
const SUPPORT$1 = 'support' ;
const CHANNEL$2 = 'channel' ;
const PUBLISH$2 = 'publish' ;
const REPOST = 'repost' ;
const DROPDOWN _TYPES = [ ALL$1 , SENT , RECEIVED , SUPPORT$1 , CHANNEL$2 , PUBLISH$2 , REPOST ] ;
// dropdown subtypes
const TIP$1 = 'tip' ;
const PURCHASE = 'purchase' ;
const PAYMENT = 'payment' ;
const DROPDOWN _SUBTYPES = [ ALL$1 , TIP$1 , PURCHASE , PAYMENT ] ;
// rpc params
const TX _TYPE = 'type' ; // = other, stream, repost, channel, support, purchase
const IS _SPENT = 'is_spent' ;
const IS _NOT _SPENT = 'is_not_spent' ;
const IS _MY _INPUT = 'is_my_input' ;
const IS _MY _OUTPUT = 'is_my_output' ;
const IS _NOT _MY _INPUT = 'is_not_my_input' ;
const IS _NOT _MY _OUTPUT = 'is_not_my_output' ; // use to further distinguish payments to self / from self.
2020-04-17 03:08:11 +02:00
const IS _MY _INPUT _OR _OUTPUT = 'is_my_input_or_output' ;
2020-04-15 19:36:29 +02:00
const EXCLUDE _INTERNAL _TRANSFERS = 'exclude_internal_transfers' ;
2020-04-10 14:16:27 +02:00
// sdk unique types
const OTHER$1 = 'other' ;
const STREAM = 'stream' ;
const PAGE _SIZE _DEFAULT = 20 ;
var txo _list = /*#__PURE__*/ Object . freeze ( {
ACTIVE : ACTIVE ,
TYPE : TYPE ,
SUB _TYPE : SUB _TYPE ,
PAGE _SIZE : PAGE _SIZE$2 ,
PAGE : PAGE ,
ALL : ALL$1 ,
SENT : SENT ,
RECEIVED : RECEIVED ,
SUPPORT : SUPPORT$1 ,
CHANNEL : CHANNEL$2 ,
PUBLISH : PUBLISH$2 ,
REPOST : REPOST ,
DROPDOWN _TYPES : DROPDOWN _TYPES ,
TIP : TIP$1 ,
PURCHASE : PURCHASE ,
PAYMENT : PAYMENT ,
DROPDOWN _SUBTYPES : DROPDOWN _SUBTYPES ,
TX _TYPE : TX _TYPE ,
IS _SPENT : IS _SPENT ,
IS _NOT _SPENT : IS _NOT _SPENT ,
IS _MY _INPUT : IS _MY _INPUT ,
IS _MY _OUTPUT : IS _MY _OUTPUT ,
IS _NOT _MY _INPUT : IS _NOT _MY _INPUT ,
IS _NOT _MY _OUTPUT : IS _NOT _MY _OUTPUT ,
2020-04-17 03:08:11 +02:00
IS _MY _INPUT _OR _OUTPUT : IS _MY _INPUT _OR _OUTPUT ,
2020-04-15 19:36:29 +02:00
EXCLUDE _INTERNAL _TRANSFERS : EXCLUDE _INTERNAL _TRANSFERS ,
2020-04-10 14:16:27 +02:00
OTHER : OTHER$1 ,
STREAM : STREAM ,
PAGE _SIZE _DEFAULT : PAGE _SIZE _DEFAULT
} ) ;
2019-10-07 18:33:06 +02:00
const SPEECH _STATUS = 'https://spee.ch/api/config/site/publishing' ;
const SPEECH _PUBLISH = 'https://spee.ch/api/claim/publish' ;
2019-09-30 21:16:38 +02:00
2019-10-07 18:33:06 +02:00
var speech _urls = /*#__PURE__*/ Object . freeze ( {
SPEECH _STATUS : SPEECH _STATUS ,
SPEECH _PUBLISH : SPEECH _PUBLISH
2019-09-30 21:16:38 +02:00
} ) ;
2019-12-11 15:45:18 +01:00
const ANNOUNCE _HEAD _AND _SD _ONLY = 'announce_head_and_sd_only' ;
const API = 'api' ;
const BLOB _DOWNLOAD _TIMEOUT = 'blob_download_timeout' ;
const BLOB _LRU _CACHE _SIZE = 'blob_lru_cache_size' ;
const BLOCKCHAIN _NAME = 'blockchain_name' ;
const CACHE _TIME = 'cache_time' ;
const COIN _SELECTION _STRATEGY = 'coin_selection_strategy' ;
const COMMENT _SERVER = 'comment_server' ;
const COMPONENTS _TO _SKIP = 'components_to_skip' ;
const CONCURRENT _BLOB _ANNOUNCERS = 'concurrent_blob_announcers' ;
const CONCURRENT _REFLECTOR _UPLOADS = 'concurrent_reflector_uploads' ;
const CONFIG = 'config' ;
const DATA _DIR = 'data_dir' ;
const DOWNLOAD _DIR = 'download_dir' ;
const DOWNLOAD _TIMEOUT = 'download_timeout' ;
const FIXED _PEER _DELAY = 'fixed_peer_delay' ;
const KNOWN _DHT _NODES = 'known_dht_nodes' ;
const LBRYUM _SERVERS = 'lbryum_servers' ;
const MAX _CONNECTIONS _PER _DOWNLOAD = 'max_connections_per_download' ;
const MAX _KEY _FEE = 'max_key_fee' ;
const DEFAULT _WALLET = 'default_wallet' ;
const NETWORK _INTERFACE = 'network_interface' ;
const NODE _RPC _TIMEOUT = 'node_rpc_timeout' ;
const PEER _CONNECT _TIMEOUT = 'peer_connect_timeout' ;
const REFLECT _STREAMS = 'reflect_streams' ;
const REFLECTOR _SERVERS = 'reflector_servers' ;
const S3 _HEADERS _DEPTH = 's3_headers_depth' ;
const SAVE _BLOBS = 'save_blobs' ;
const SAVE _FILES = 'save_files' ;
const SHARE _USAGE _DATA = 'share_usage_data' ;
const SPLIT _BUCKETS _UNDER _INDEX = 'split_buckets_under_index' ;
const STREAMING _GET = 'streaming_get' ;
const STREAMING _SERVER = 'streaming_server' ;
const TCP _PORT = 'tcp_port' ;
const TRACK _BANDWIDTH = 'track_bandwidth' ;
const UDP _PORT = 'udp_port' ;
const USE _UPNP = 'use_upnp' ;
const WALLET _DIR = 'wallet_dir' ;
const WALLETS = 'wallets' ;
var daemon _settings = /*#__PURE__*/ Object . freeze ( {
ANNOUNCE _HEAD _AND _SD _ONLY : ANNOUNCE _HEAD _AND _SD _ONLY ,
API : API ,
BLOB _DOWNLOAD _TIMEOUT : BLOB _DOWNLOAD _TIMEOUT ,
BLOB _LRU _CACHE _SIZE : BLOB _LRU _CACHE _SIZE ,
BLOCKCHAIN _NAME : BLOCKCHAIN _NAME ,
CACHE _TIME : CACHE _TIME ,
COIN _SELECTION _STRATEGY : COIN _SELECTION _STRATEGY ,
COMMENT _SERVER : COMMENT _SERVER ,
COMPONENTS _TO _SKIP : COMPONENTS _TO _SKIP ,
CONCURRENT _BLOB _ANNOUNCERS : CONCURRENT _BLOB _ANNOUNCERS ,
CONCURRENT _REFLECTOR _UPLOADS : CONCURRENT _REFLECTOR _UPLOADS ,
CONFIG : CONFIG ,
DATA _DIR : DATA _DIR ,
DOWNLOAD _DIR : DOWNLOAD _DIR ,
DOWNLOAD _TIMEOUT : DOWNLOAD _TIMEOUT ,
FIXED _PEER _DELAY : FIXED _PEER _DELAY ,
KNOWN _DHT _NODES : KNOWN _DHT _NODES ,
LBRYUM _SERVERS : LBRYUM _SERVERS ,
MAX _CONNECTIONS _PER _DOWNLOAD : MAX _CONNECTIONS _PER _DOWNLOAD ,
MAX _KEY _FEE : MAX _KEY _FEE ,
DEFAULT _WALLET : DEFAULT _WALLET ,
NETWORK _INTERFACE : NETWORK _INTERFACE ,
NODE _RPC _TIMEOUT : NODE _RPC _TIMEOUT ,
PEER _CONNECT _TIMEOUT : PEER _CONNECT _TIMEOUT ,
REFLECT _STREAMS : REFLECT _STREAMS ,
REFLECTOR _SERVERS : REFLECTOR _SERVERS ,
S3 _HEADERS _DEPTH : S3 _HEADERS _DEPTH ,
SAVE _BLOBS : SAVE _BLOBS ,
SAVE _FILES : SAVE _FILES ,
SHARE _USAGE _DATA : SHARE _USAGE _DATA ,
SPLIT _BUCKETS _UNDER _INDEX : SPLIT _BUCKETS _UNDER _INDEX ,
STREAMING _GET : STREAMING _GET ,
STREAMING _SERVER : STREAMING _SERVER ,
TCP _PORT : TCP _PORT ,
TRACK _BANDWIDTH : TRACK _BANDWIDTH ,
UDP _PORT : UDP _PORT ,
USE _UPNP : USE _UPNP ,
WALLET _DIR : WALLET _DIR ,
WALLETS : WALLETS
} ) ;
2019-12-12 17:47:09 +01:00
/ *
2020-01-13 23:00:04 +01:00
* How to use this file :
* Settings exported from here will trigger the setting to be
* sent to the preference middleware when set using the
* usual setDaemonSettings and clearDaemonSettings methods .
*
* See redux / settings / actions in the app for where this is used .
2019-12-12 17:47:09 +01:00
* /
2019-12-11 15:45:18 +01:00
const WALLET _SERVERS = LBRYUM _SERVERS ;
2020-02-20 06:57:55 +01:00
const SHARE _USAGE _DATA$1 = SHARE _USAGE _DATA ;
2019-12-11 15:45:18 +01:00
2019-12-12 20:51:07 +01:00
var shared _preferences = /*#__PURE__*/ Object . freeze ( {
2020-02-20 06:57:55 +01:00
WALLET _SERVERS : WALLET _SERVERS ,
SHARE _USAGE _DATA : SHARE _USAGE _DATA$1
2019-12-11 15:45:18 +01:00
} ) ;
2019-04-03 19:12:51 +02:00
const SEARCH _TYPES = {
FILE : 'file' ,
CHANNEL : 'channel' ,
2019-07-10 18:48:50 +02:00
SEARCH : 'search' ,
TAG : 'tag'
2019-04-03 19:12:51 +02:00
} ;
const SEARCH _OPTIONS = {
RESULT _COUNT : 'size' ,
CLAIM _TYPE : 'claimType' ,
INCLUDE _FILES : 'file' ,
INCLUDE _CHANNELS : 'channel' ,
INCLUDE _FILES _AND _CHANNELS : 'file,channel' ,
MEDIA _AUDIO : 'audio' ,
MEDIA _VIDEO : 'video' ,
MEDIA _TEXT : 'text' ,
MEDIA _IMAGE : 'image' ,
MEDIA _APPLICATION : 'application'
} ;
2019-07-23 21:39:45 +02:00
const DEFAULT _FOLLOWED _TAGS = [ 'art' , 'automotive' , 'blockchain' , 'comedy' , 'economics' , 'education' , 'gaming' , 'music' , 'news' , 'science' , 'sports' , 'technology' ] ;
2019-07-02 22:33:57 +02:00
2020-06-04 17:40:52 +02:00
const MATURE _TAGS = [ 'porn' , 'porno' , 'nsfw' , 'mature' , 'xxx' , 'sex' , 'creampie' , 'blowjob' , 'handjob' , 'vagina' , 'boobs' , 'big boobs' , 'big dick' , 'pussy' , 'cumshot' , 'anal' , 'hard fucking' , 'ass' , 'fuck' , 'hentai' ] ;
2019-07-02 22:33:57 +02:00
2020-06-05 17:11:03 +02:00
const DEFAULT _ENGLISH _KNOWN _TAGS = [ 'free speech' , 'censorship' , 'gaming' , 'pop culture' , 'entertainment' , 'technology' , 'music' , 'funny' , 'education' , 'learning' , 'news' , 'gameplay' , 'nature' , 'beliefs' , 'comedy' , 'games' , 'film & animation' , 'game' , 'weapons' , 'blockchain' , 'video game' , 'sports' , 'walkthrough' , 'lbrytvpaidbeta' , 'art' , 'pc' , 'minecraft' , 'playthrough' , 'economics' , 'automotive' , 'play' , 'tutorial' , 'twitch' , 'how to' , 'ps4' , 'bitcoin' , 'fortnite' , 'commentary' , 'lets play' , 'fun' , 'politics' , 'travel' , 'food' , 'science' , 'xbox' , 'liberal' , 'democrat' , 'progressive' , 'survival' , 'non-profits' , 'activism' , 'cryptocurrency' , 'playstation' , 'nintendo' , 'government' , 'steam' , 'podcast' , 'gamer' , 'horror' , 'conservative' , 'reaction' , 'trailer' , 'love' , 'cnn' , 'republican' , 'political' , 'hangoutsonair' , 'hoa' , 'msnbc' , 'cbs' , 'anime' , 'donald trump' , 'fiction' , 'fox news' , 'crypto' , 'ethereum' , 'call of duty' , 'android' , 'multiplayer' , 'epic' , 'rpg' , 'adventure' , 'secular talk' , 'btc' , 'atheist' , 'atheism' , 'video games' , 'ps3' , 'cod' , 'online' , 'agnostic' , 'movie' , 'fps' , 'lets' , 'mod' , 'world' , 'reviews' , 'sharefactory' , 'space' , 'pokemon' , 'stream' , 'hilarious' , 'lol' , 'sony' , 'god' , 'dance' , 'pvp' , 'tech' , 'strategy' , 'zombies' , 'fail' , 'film' , 'xbox360' , 'animation' , 'unboxing' , 'money' , 'wwe' , 'mods' , 'indie' , 'pubg' , 'ios' , 'history' , 'rap' , 'mobile' , 'trump' , 'hack' , 'flat earth' , 'trap' , 'humor' , 'vlogging' , 'fox' , 'news radio' , 'facebook' , 'edm' , 'fitness' , 'vaping' , 'hip hop' , 'secular' , 'jesus' , 'song' , 'vape' , 'guitar' , 'remix' , 'mining' , 'daily' , 'diy' , 'pets' , 'videogame' , 'death' , 'funny moments' , 'religion' , 'media' , 'viral' , 'war' , 'nbc' , 'freedom' , 'gold' , 'family' , 'meme' , 'zombie' , 'photography' , 'chill' , 'sniper' , 'computer' , 'iphone' , 'dragon' , 'bible' , 'pro' , 'overwatch' , 'litecoin' , 'gta' , 'house' , 'fire' , 'bass' , 'truth' , 'crash' , 'mario' , 'league of legends' , 'wii' , 'mmorpg' , 'health' , 'marvel' , 'racing' , 'apple' , 'instrumental' , 'earth' , 'destiny' , 'satire' , 'race' , 'training' , 'electronic' , 'boss' , 'roblox' , 'family friendly' , 'california' , 'react' , 'christian' , 'mmo' , 'twitter' , 'help' , 'star' , 'cars' , 'random' , 'top 10' , 'ninja' , 'guns' , 'linux' , 'lessons' , 'vegan' , 'future' , 'dota 2' , 'studio' , 'star wars' , 'shooting' , 'nasa' , 'rock' , 'league' , 'subscribe' , 'water' , 'gta v' , 'car' , 'samsung' , 'music video' , 'skyrim' , 'dog' , 'comics' , 'shooter game' , 'bo3' , 'halloween' , 'liberty' , 'eth' , 'conspiracy' , 'knife' , 'fashion' , 'stories' , 'vapor' , 'nvidia' , 'cute' , 'beat' , 'nintendo switch' , 'fantasy' , 'christmas' , 'world of warcraft' , 'industry' , 'cartoon' , 'garden' , 'animals' , 'windows' , 'happy' , 'magic' , 'memes' , 'design' , 'tactical' , 'fallout 4' , 'puzzle' , 'parody' , 'rv' , 'beats' , 'building' , 'disney' , 'drone' , 'ps2' , 'beach' , 'metal' , 'christianity' , 'business' , 'mix' , 'bo2' , 'cover' , 'senate' , '4k' , 'united states' , 'final' , 'hero' , 'playing' , 'dlc' , 'ubisoft' , 'halo' , 'pc gaming' , 'raw' , 'investing' , 'online learning' , 'software' , 'ark' , 'mojang' , 'console' , 'battle royale' , 'canon' , 'microsoft' , 'camping' , 'ufo' , 'progressive talk' , 'switch' , 'fpv' , 'arcade' , 'school' , 'driving' , 'bodybuilding' , 'drama' , 'retro' , 'science fiction' , 'eggs' , 'australia' , 'modded' , 'rainbow' , 'gamers' , 'resident evil' , 'drawing' , 'brasil' , 'england' , 'hillary clinton' , 'singing' , 'final fantasy' , 'hiphop' , 'video blog' , 'mature' , 'quad' , 'noob' , 'simulation' , 'illuminati' , 'poetry' , 'dayz' , 'manga' , 'howto' , 'insane' , 'press' , 'special' , 'church' , 'ico' , 'weird' , 'libertarian' , 'crafting' , 'level' , 'comic' , 'sandbox' , 'daily vlog' , 'outdoor' , 'black ops' , 'sound' , 'christ' , 'duty' , 'juvenile fiction' , 'pc game' , 'how-to' , 'ww2' , 'creepy' , 'artist' , 'galaxy' , 'destiny 2' , 'new music' , 'quest' , 'lee' , 'pacman' , 'super smash bros' , 'day' , 'survival horror' , 'patreon' , 'bitcoin price' , 'trending' , 'open world' , 'wii u' , 'dope' , 'reaper' , 'sniping' , 'dubstep' , 'truck' , 'planet' , 'dc' , 'amazon' , 'spirituality' , 'universe' , 'video game culture' , 'community' , 'cat' , 'aliens' , 'tourism' , 'altcoins' , ' sty
const DEFAULT _SPANISH _KNOWN _TAGS = [ 'español' , 'tecnología' , 'criptomonedas' , 'economía' , 'bitcoin' , 'educación' , 'videojuegos' , 'música' , 'noticias' , 'ciencia' , 'deportes' , 'latinoamérica' , 'latam' , 'conspiración' , 'humor' , 'política' , 'tutoriales' ] ;
const DEFAULT _KNOWN _TAGS = [ ... DEFAULT _ENGLISH _KNOWN _TAGS , ... DEFAULT _SPANISH _KNOWN _TAGS ] ;
2019-07-02 22:33:57 +02:00
2019-04-03 19:12:51 +02:00
//
const CHECK _DAEMON _STARTED _TRY _NUMBER = 200 ;
2019-04-23 19:22:14 +02:00
//
// Basic LBRY sdk connection config
// Offers a proxy to call LBRY sdk methods
2019-04-03 19:12:51 +02:00
2019-04-23 19:22:14 +02:00
//
2019-04-03 19:12:51 +02:00
const Lbry = {
isConnected : false ,
2019-04-23 19:22:14 +02:00
connectPromise : null ,
2019-04-03 19:12:51 +02:00
daemonConnectionString : 'http://localhost:5279' ,
2020-03-18 18:11:03 +01:00
alternateConnectionString : '' ,
methodsUsingAlternateConnectionString : [ ] ,
2019-09-10 20:14:40 +02:00
apiRequestHeaders : { 'Content-Type' : 'application/json-rpc' } ,
2019-04-23 19:22:14 +02:00
// Allow overriding daemon connection string (e.g. to `/api/proxy` for lbryweb)
setDaemonConnectionString : value => {
Lbry . daemonConnectionString = value ;
} ,
2019-05-30 17:24:46 +02:00
setApiHeader : ( key , value ) => {
Lbry . apiRequestHeaders = Object . assign ( Lbry . apiRequestHeaders , { [ key ] : value } ) ;
} ,
unsetApiHeader : key => {
Object . keys ( Lbry . apiRequestHeaders ) . includes ( key ) && delete Lbry . apiRequestHeaders [ 'key' ] ;
} ,
2019-04-23 19:22:14 +02:00
// Allow overriding Lbry methods
overrides : { } ,
setOverride : ( methodName , newMethod ) => {
Lbry . overrides [ methodName ] = newMethod ;
} ,
2019-09-30 21:16:38 +02:00
getApiRequestHeaders : ( ) => Lbry . apiRequestHeaders ,
2019-04-23 19:22:14 +02:00
// Returns a human readable media type based on the content type or extension of a file that is returned by the sdk
2019-08-02 08:21:28 +02:00
getMediaType : ( contentType , fileName ) => {
2019-08-16 07:16:04 +02:00
if ( fileName ) {
2020-05-11 16:09:38 +02:00
const formats = [ [ /\.(mp4|m4v|webm|flv|f4v|ogv)$/i , 'video' ] , [ /\.(mp3|m4a|aac|wav|flac|ogg|opus)$/i , 'audio' ] , [ /\.(jpeg|jpg|png|gif|svg|webp)$/i , 'image' ] , [ /\.(h|go|ja|java|js|jsx|c|cpp|cs|css|rb|scss|sh|php|py)$/i , 'script' ] , [ /\.(html|json|csv|txt|log|md|markdown|docx|pdf|xml|yml|yaml)$/i , 'document' ] , [ /\.(pdf|odf|doc|docx|epub|org|rtf)$/i , 'e-book' ] , [ /\.(stl|obj|fbx|gcode)$/i , '3D-file' ] , [ /\.(cbr|cbt|cbz)$/i , 'comic-book' ] , [ /\.(lbry)$/i , 'application' ] ] ;
2019-08-02 08:21:28 +02:00
2019-04-23 19:22:14 +02:00
const res = formats . reduce ( ( ret , testpair ) => {
2019-08-16 07:16:04 +02:00
switch ( testpair [ 0 ] . test ( ret ) ) {
case true :
return testpair [ 1 ] ;
default :
return ret ;
}
} , fileName ) ;
return res === fileName ? 'unknown' : res ;
} else if ( contentType ) {
// $FlowFixMe
return ( /^[^/]+/ . exec ( contentType ) [ 0 ]
) ;
2019-04-23 19:22:14 +02:00
}
2019-08-02 08:21:28 +02:00
2019-04-23 19:22:14 +02:00
return 'unknown' ;
} ,
//
// Lbry SDK Methods
// https://lbry.tech/api/sdk
//
status : ( params = { } ) => daemonCallWithResult ( 'status' , params ) ,
stop : ( ) => daemonCallWithResult ( 'stop' , { } ) ,
version : ( ) => daemonCallWithResult ( 'version' , { } ) ,
// Claim fetching and manipulation
2020-03-18 18:11:03 +01:00
resolve : params => daemonCallWithResult ( 'resolve' , params ) ,
2019-04-23 19:22:14 +02:00
get : params => daemonCallWithResult ( 'get' , params ) ,
2020-03-18 18:11:03 +01:00
claim _search : params => daemonCallWithResult ( 'claim_search' , params ) ,
2019-04-23 19:22:14 +02:00
claim _list : params => daemonCallWithResult ( 'claim_list' , params ) ,
channel _create : params => daemonCallWithResult ( 'channel_create' , params ) ,
2019-07-01 03:16:44 +02:00
channel _update : params => daemonCallWithResult ( 'channel_update' , params ) ,
2019-09-12 21:06:49 +02:00
channel _import : params => daemonCallWithResult ( 'channel_import' , params ) ,
2019-04-23 19:22:14 +02:00
channel _list : params => daemonCallWithResult ( 'channel_list' , params ) ,
stream _abandon : params => daemonCallWithResult ( 'stream_abandon' , params ) ,
2019-11-01 20:08:42 +01:00
stream _list : params => daemonCallWithResult ( 'stream_list' , params ) ,
2019-04-23 19:22:14 +02:00
channel _abandon : params => daemonCallWithResult ( 'channel_abandon' , params ) ,
support _create : params => daemonCallWithResult ( 'support_create' , params ) ,
2019-11-05 19:24:41 +01:00
support _list : params => daemonCallWithResult ( 'support_list' , params ) ,
2020-02-10 16:49:45 +01:00
stream _repost : params => daemonCallWithResult ( 'stream_repost' , params ) ,
2019-04-23 19:22:14 +02:00
// File fetching and manipulation
file _list : ( params = { } ) => daemonCallWithResult ( 'file_list' , params ) ,
file _delete : ( params = { } ) => daemonCallWithResult ( 'file_delete' , params ) ,
file _set _status : ( params = { } ) => daemonCallWithResult ( 'file_set_status' , params ) ,
blob _delete : ( params = { } ) => daemonCallWithResult ( 'blob_delete' , params ) ,
blob _list : ( params = { } ) => daemonCallWithResult ( 'blob_list' , params ) ,
// Wallet utilities
2019-10-15 05:35:38 +02:00
wallet _balance : ( params = { } ) => daemonCallWithResult ( 'wallet_balance' , params ) ,
2019-10-16 00:11:03 +02:00
wallet _decrypt : ( ) => daemonCallWithResult ( 'wallet_decrypt' , { } ) ,
wallet _encrypt : ( params = { } ) => daemonCallWithResult ( 'wallet_encrypt' , params ) ,
wallet _unlock : ( params = { } ) => daemonCallWithResult ( 'wallet_unlock' , params ) ,
wallet _list : ( params = { } ) => daemonCallWithResult ( 'wallet_list' , params ) ,
2019-10-15 05:35:38 +02:00
wallet _send : ( params = { } ) => daemonCallWithResult ( 'wallet_send' , params ) ,
2019-10-16 00:11:03 +02:00
wallet _status : ( params = { } ) => daemonCallWithResult ( 'wallet_status' , params ) ,
2019-04-23 19:22:14 +02:00
address _is _mine : ( params = { } ) => daemonCallWithResult ( 'address_is_mine' , params ) ,
address _unused : ( params = { } ) => daemonCallWithResult ( 'address_unused' , params ) ,
2019-09-17 19:48:41 +02:00
address _list : ( params = { } ) => daemonCallWithResult ( 'address_list' , params ) ,
2019-04-23 19:22:14 +02:00
transaction _list : ( params = { } ) => daemonCallWithResult ( 'transaction_list' , params ) ,
utxo _release : ( params = { } ) => daemonCallWithResult ( 'utxo_release' , params ) ,
2019-05-10 07:02:03 +02:00
support _abandon : ( params = { } ) => daemonCallWithResult ( 'support_abandon' , params ) ,
2020-05-08 22:47:33 +02:00
purchase _list : ( params = { } ) => daemonCallWithResult ( 'purchase_list' , params ) ,
2019-04-23 19:22:14 +02:00
sync _hash : ( params = { } ) => daemonCallWithResult ( 'sync_hash' , params ) ,
sync _apply : ( params = { } ) => daemonCallWithResult ( 'sync_apply' , params ) ,
2019-09-30 23:52:41 +02:00
// Preferences
preference _get : ( params = { } ) => daemonCallWithResult ( 'preference_get' , params ) ,
preference _set : ( params = { } ) => daemonCallWithResult ( 'preference_set' , params ) ,
2019-06-12 03:14:37 +02:00
// Comments
comment _list : ( params = { } ) => daemonCallWithResult ( 'comment_list' , params ) ,
comment _create : ( params = { } ) => daemonCallWithResult ( 'comment_create' , params ) ,
2020-01-10 03:29:54 +01:00
comment _hide : ( params = { } ) => daemonCallWithResult ( 'comment_hide' , params ) ,
comment _abandon : ( params = { } ) => daemonCallWithResult ( 'comment_abandon' , params ) ,
2020-01-13 23:00:04 +01:00
comment _update : ( params = { } ) => daemonCallWithResult ( 'comment_update' , params ) ,
2020-01-10 03:29:54 +01:00
2019-04-23 19:22:14 +02:00
// Connect to the sdk
connect : ( ) => {
if ( Lbry . connectPromise === null ) {
Lbry . connectPromise = new Promise ( ( resolve , reject ) => {
let tryNum = 0 ;
// Check every half second to see if the daemon is accepting connections
function checkDaemonStarted ( ) {
tryNum += 1 ;
Lbry . status ( ) . then ( resolve ) . catch ( ( ) => {
if ( tryNum <= CHECK _DAEMON _STARTED _TRY _NUMBER ) {
setTimeout ( checkDaemonStarted , tryNum < 50 ? 400 : 1000 ) ;
} else {
reject ( new Error ( 'Unable to connect to LBRY' ) ) ;
}
} ) ;
}
checkDaemonStarted ( ) ;
} ) ;
}
// Flow thinks this could be empty, but it will always reuturn a promise
// $FlowFixMe
return Lbry . connectPromise ;
2019-11-01 20:08:42 +01:00
} ,
2019-04-03 19:12:51 +02:00
2019-11-01 20:08:42 +01:00
publish : ( params = { } ) => new Promise ( ( resolve , reject ) => {
if ( Lbry . overrides . publish ) {
Lbry . overrides . publish ( params ) . then ( resolve , reject ) ;
} else {
apiCall ( 'publish' , params , resolve , reject ) ;
}
} )
} ;
2019-09-30 21:16:38 +02:00
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 ) ;
} ) ;
}
2020-03-18 18:11:03 +01:00
function apiCall ( method , params , resolve , reject ) {
2019-04-03 19:12:51 +02:00
const counter = new Date ( ) . getTime ( ) ;
const options = {
method : 'POST' ,
2019-05-30 17:24:46 +02:00
headers : Lbry . apiRequestHeaders ,
2019-04-03 19:12:51 +02:00
body : JSON . stringify ( {
jsonrpc : '2.0' ,
method ,
params ,
id : counter
} )
} ;
2020-03-18 18:11:03 +01:00
const connectionString = Lbry . methodsUsingAlternateConnectionString . includes ( method ) ? Lbry . alternateConnectionString : Lbry . daemonConnectionString ;
2020-03-17 22:57:27 +01:00
return fetch ( connectionString + '?m=' + method , options ) . then ( checkAndParse ) . then ( response => {
2019-04-03 19:12:51 +02:00
const error = response . error || response . result && response . result . error ;
if ( error ) {
return reject ( error ) ;
}
return resolve ( response . result ) ;
} ) . catch ( reject ) ;
}
2020-03-18 18:11:03 +01:00
function daemonCallWithResult ( name , params = { } ) {
2019-04-23 19:22:14 +02:00
return new Promise ( ( resolve , reject ) => {
apiCall ( name , params , result => {
resolve ( result ) ;
2020-03-18 18:11:03 +01:00
} , reject ) ;
2019-04-23 19:22:14 +02:00
} ) ;
}
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 ) ;
} ) ;
}
} ) ;
//
2020-06-23 20:48:30 +02:00
const CHECK _LBRYFIRST _STARTED _TRY _NUMBER = 200 ;
//
// Basic LBRYFIRST connection config
// Offers a proxy to call LBRYFIRST methods
//
const LbryFirst = {
isConnected : false ,
connectPromise : null ,
lbryFirstConnectionString : 'http://localhost:1337/rpc' ,
apiRequestHeaders : { 'Content-Type' : 'application/json' } ,
// Allow overriding lbryFirst connection string (e.g. to `/api/proxy` for lbryweb)
setLbryFirstConnectionString : value => {
LbryFirst . lbryFirstConnectionString = value ;
} ,
setApiHeader : ( key , value ) => {
LbryFirst . apiRequestHeaders = Object . assign ( LbryFirst . apiRequestHeaders , { [ key ] : value } ) ;
} ,
unsetApiHeader : key => {
Object . keys ( LbryFirst . apiRequestHeaders ) . includes ( key ) && delete LbryFirst . apiRequestHeaders [ 'key' ] ;
} ,
// Allow overriding Lbry methods
overrides : { } ,
setOverride : ( methodName , newMethod ) => {
LbryFirst . overrides [ methodName ] = newMethod ;
} ,
getApiRequestHeaders : ( ) => LbryFirst . apiRequestHeaders ,
//
// LbryFirst Methods
//
status : ( params = { } ) => lbryFirstCallWithResult ( 'server.Status' , params ) ,
stop : ( ) => lbryFirstCallWithResult ( 'stop' , { } ) ,
version : ( ) => lbryFirstCallWithResult ( 'version' , { } ) ,
// Upload to youtube
upload : ( params = { } ) => {
// Only upload when originally publishing for now
if ( ! params . file _path ) {
return { } ;
}
const uploadParams = { } ;
uploadParams . Title = params . title ;
uploadParams . Description = params . description ;
uploadParams . FilePath = params . file _path ;
uploadParams . Category = '' ;
uploadParams . ThumbnailURL = params . thumbnail _url ;
uploadParams . Keywords = params . tags . join ( ',' ) ;
// Needs to be configurable?
uploadParams . PublishType = 'private' ;
uploadParams . PublishAt = '' ; // Premiere Date
uploadParams . MonetizationOff = false ;
uploadParams . ClaimName = params . name ;
uploadParams . URI = params . permanent _url ;
return lbryFirstCallWithResult ( 'youtube.Upload' , uploadParams ) ;
} ,
hasYTAuth : token => {
const hasYTAuthParams = { } ;
hasYTAuthParams . AuthToken = token ;
return lbryFirstCallWithResult ( 'youtube.HasAuth' , hasYTAuthParams ) ;
} ,
ytSignup : ( ) => {
const emptyParams = { } ;
return lbryFirstCallWithResult ( 'youtube.Signup' , emptyParams ) ;
} ,
remove : ( ) => {
const emptyParams = { } ;
return lbryFirstCallWithResult ( 'youtube.Remove' , emptyParams ) ;
} ,
// Connect to lbry-first
connect : ( ) => {
if ( LbryFirst . connectPromise === null ) {
LbryFirst . connectPromise = new Promise ( ( resolve , reject ) => {
let tryNum = 0 ;
// Check every half second to see if the lbryFirst is accepting connections
function checkLbryFirstStarted ( ) {
tryNum += 1 ;
LbryFirst . status ( ) . then ( resolve ) . catch ( ( ) => {
if ( tryNum <= CHECK _LBRYFIRST _STARTED _TRY _NUMBER ) {
setTimeout ( checkLbryFirstStarted , tryNum < 50 ? 400 : 1000 ) ;
} else {
reject ( new Error ( 'Unable to connect to LBRY' ) ) ;
}
} ) ;
}
checkLbryFirstStarted ( ) ;
} ) ;
}
// Flow thinks this could be empty, but it will always return a promise
// $FlowFixMe
return LbryFirst . connectPromise ;
}
} ;
function checkAndParse$1 ( 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$1 ( method , params , resolve , reject ) {
const counter = new Date ( ) . getTime ( ) ;
params = [ params ] ;
const options = {
method : 'POST' ,
headers : LbryFirst . apiRequestHeaders ,
body : JSON . stringify ( {
jsonrpc : '2.0' ,
method ,
params ,
id : counter
} )
} ;
return fetch ( LbryFirst . lbryFirstConnectionString , options ) . then ( checkAndParse$1 ) . then ( response => {
const error = response . error || response . result && response . result . error ;
if ( error ) {
return reject ( error ) ;
}
return resolve ( response . result ) ;
} ) . catch ( reject ) ;
}
function lbryFirstCallWithResult ( name , params = { } ) {
console . log ( ` LbryFirst: calling ${ name } ` ) ;
return new Promise ( ( resolve , reject ) => {
apiCall$1 ( name , params , result => {
resolve ( result ) ;
} , reject ) ;
} ) ;
}
// This is only for a fallback
// If there is a LbryFirst method that is being called by an app, it should be added to /flow-typed/LbryFirst.js
const lbryFirstProxy = new Proxy ( LbryFirst , {
get ( target , name ) {
if ( name in target ) {
return target [ name ] ;
}
return ( params = { } ) => new Promise ( ( resolve , reject ) => {
apiCall$1 ( name , params , resolve , reject ) ;
} ) ;
}
} ) ;
//
2019-04-03 19:12:51 +02:00
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 ( '&' ) ;
}
2020-01-30 07:30:27 +01:00
const getSearchQueryString = ( query , options = { } ) => {
2019-04-03 19:12:51 +02:00
const encodedQuery = encodeURIComponent ( query ) ;
const queryParams = [ ` s= ${ encodedQuery } ` , ` size= ${ options . size || DEFAULT _SEARCH _SIZE } ` , ` from= ${ options . from || DEFAULT _SEARCH _RESULT _FROM } ` ] ;
2020-01-30 07:30:27 +01:00
const { isBackgroundSearch } = options ;
const includeUserOptions = typeof isBackgroundSearch === 'undefined' ? false : ! isBackgroundSearch ;
2019-04-03 19:12:51 +02:00
if ( includeUserOptions ) {
2019-05-07 06:18:22 +02:00
const claimType = options [ SEARCH _OPTIONS . CLAIM _TYPE ] ;
2020-02-21 17:12:45 +01:00
if ( claimType ) {
queryParams . push ( ` claimType= ${ claimType } ` ) ;
2019-04-03 19:12:51 +02:00
2020-02-21 17:12:45 +01:00
// If they are only searching for channels, strip out the media info
if ( ! claimType . includes ( SEARCH _OPTIONS . INCLUDE _CHANNELS ) ) {
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 , '' ) } ` ) ;
}
2019-04-03 19:12:51 +02:00
}
}
2020-01-30 07:30:27 +01:00
const additionalOptions = { } ;
const { related _to } = options ;
const { nsfw } = options ;
if ( related _to ) additionalOptions [ 'related_to' ] = related _to ;
if ( typeof nsfw !== 'undefined' ) additionalOptions [ 'nsfw' ] = nsfw ;
2019-12-18 23:20:08 +01:00
if ( additionalOptions ) {
Object . keys ( additionalOptions ) . forEach ( key => {
const option = additionalOptions [ key ] ;
queryParams . push ( ` ${ key } = ${ option } ` ) ;
} ) ;
}
2019-04-03 19:12:51 +02:00
return queryParams . join ( '&' ) ;
} ;
var _extends = Object . assign || function ( target ) { for ( var i = 1 ; i < arguments . length ; i ++ ) { var source = arguments [ i ] ; for ( var key in source ) { if ( Object . prototype . hasOwnProperty . call ( source , key ) ) { target [ key ] = source [ key ] ; } } } return target ; } ;
2019-08-20 22:00:26 +02:00
function _objectWithoutProperties ( obj , keys ) { var target = { } ; for ( var i in obj ) { if ( keys . indexOf ( i ) >= 0 ) continue ; if ( ! Object . prototype . hasOwnProperty . call ( obj , i ) ) continue ; target [ i ] = obj [ i ] ; } return target ; }
2019-08-29 18:38:00 +02:00
const channelNameMinLength = 1 ;
2019-04-03 19:12:51 +02:00
const claimIdMaxLength = 40 ;
2019-06-03 04:55:52 +02:00
// see https://spec.lbry.com/#urls
2020-02-26 19:11:36 +01:00
const regexInvalidURI = /[ =&#:$@%?;/\\"<>%\{\}|^~[\]`\u{0000}-\u{0008}\u{000b}-\u{000c}\u{000e}-\u{001F}\u{D800}-\u{DFFF}\u{FFFE}-\u{FFFF}]/u ;
2019-04-03 19:12:51 +02:00
const regexAddress = /^(b|r)(?=[^0OIl]{32,33})[0-9A-Za-z]{32,33}$/ ;
2019-08-20 22:00:26 +02:00
const regexPartProtocol = '^((?:lbry://)?)' ;
const regexPartStreamOrChannelName = '([^:$#/]*)' ;
const regexPartModifierSeparator = '([:$#]?)([^/]*)' ;
2019-08-24 04:43:49 +02:00
const queryStringBreaker = '^([\\S]+)([?][\\S]*)' ;
const separateQuerystring = new RegExp ( queryStringBreaker ) ;
2019-04-03 19:12:51 +02:00
/ * *
* Parses a LBRY name into its component parts . Throws errors with user - friendly
* messages for invalid names .
*
* Returns a dictionary with keys :
2019-08-20 22:00:26 +02:00
* - path ( string )
2019-04-03 19:12:51 +02:00
* - isChannel ( boolean )
2019-08-20 22:00:26 +02:00
* - streamName ( string , if present )
* - streamClaimId ( string , if present )
* - channelName ( string , if present )
* - channelClaimId ( string , if present )
* - primaryClaimSequence ( int , if present )
* - secondaryClaimSequence ( int , if present )
* - primaryBidPosition ( int , if present )
* - secondaryBidPosition ( int , if present )
2019-04-03 19:12:51 +02:00
* /
2019-08-20 22:00:26 +02:00
function parseURI ( URL , requireProto = false ) {
2019-04-03 19:12:51 +02:00
// Break into components. Empty sub-matches are converted to null
2019-08-24 04:43:49 +02:00
2019-08-20 22:00:26 +02:00
const componentsRegex = new RegExp ( regexPartProtocol + // protocol
regexPartStreamOrChannelName + // stream or channel name (stops at the first separator or end)
regexPartModifierSeparator + // modifier separator, modifier (stops at the first path separator or end)
'(/?)' + // path separator, there should only be one (optional) slash to separate the stream and channel parts
regexPartStreamOrChannelName + regexPartModifierSeparator ) ;
2019-08-24 04:43:49 +02:00
// chop off the querystring first
let QSStrippedURL , qs ;
const qsRegexResult = separateQuerystring . exec ( URL ) ;
if ( qsRegexResult ) {
[ QSStrippedURL , qs ] = qsRegexResult . slice ( 1 ) . map ( match => match || null ) ;
}
2019-04-03 19:12:51 +02:00
2019-08-24 04:43:49 +02:00
const cleanURL = QSStrippedURL || URL ;
const regexMatch = componentsRegex . exec ( cleanURL ) || [ ] ;
2019-08-20 22:00:26 +02:00
const [ proto , ... rest ] = regexMatch . slice ( 1 ) . map ( match => match || null ) ;
const path = rest . join ( '' ) ;
const [ streamNameOrChannelName , primaryModSeparator , primaryModValue , pathSep , possibleStreamName , secondaryModSeparator , secondaryModValue ] = rest ;
2020-05-11 16:09:38 +02:00
const searchParams = new URLSearchParams ( qs || '' ) ;
const startTime = searchParams . get ( 't' ) ;
2019-04-03 19:12:51 +02:00
// Validate protocol
if ( requireProto && ! proto ) {
2019-10-08 16:14:50 +02:00
throw new Error ( _ _ ( 'LBRY URLs must include a protocol prefix (lbry://).' ) ) ;
2019-04-03 19:12:51 +02:00
}
// Validate and process name
2019-08-20 22:00:26 +02:00
if ( ! streamNameOrChannelName ) {
2019-10-08 16:14:50 +02:00
throw new Error ( _ _ ( 'URL does not include name.' ) ) ;
2019-04-03 19:12:51 +02:00
}
2019-10-08 16:14:50 +02:00
rest . forEach ( urlPiece => {
if ( urlPiece && urlPiece . includes ( ' ' ) ) {
2019-12-21 20:23:50 +01:00
console . error ( 'URL can not include a space' ) ;
2019-10-08 16:14:50 +02:00
}
} ) ;
2019-08-20 22:00:26 +02:00
const includesChannel = streamNameOrChannelName . startsWith ( '@' ) ;
const isChannel = streamNameOrChannelName . startsWith ( '@' ) && ! possibleStreamName ;
2019-08-29 18:38:00 +02:00
const channelName = includesChannel && streamNameOrChannelName . slice ( 1 ) ;
2019-04-03 19:12:51 +02:00
2019-08-20 22:00:26 +02:00
if ( includesChannel ) {
2019-04-03 19:12:51 +02:00
if ( ! channelName ) {
2019-07-02 05:04:27 +02:00
throw new Error ( _ _ ( 'No channel name after @.' ) ) ;
2019-04-03 19:12:51 +02:00
}
if ( channelName . length < channelNameMinLength ) {
2019-10-08 21:03:09 +02:00
throw new Error ( _ _ ( ` Channel names must be at least %channelNameMinLength% characters. ` , {
channelNameMinLength
} ) ) ;
2019-04-03 19:12:51 +02:00
}
}
2019-08-20 22:00:26 +02:00
// Validate and process modifier
const [ primaryClaimId , primaryClaimSequence , primaryBidPosition ] = parseURIModifier ( primaryModSeparator , primaryModValue ) ;
const [ secondaryClaimId , secondaryClaimSequence , secondaryBidPosition ] = parseURIModifier ( secondaryModSeparator , secondaryModValue ) ;
const streamName = includesChannel ? possibleStreamName : streamNameOrChannelName ;
const streamClaimId = includesChannel ? secondaryClaimId : primaryClaimId ;
const channelClaimId = includesChannel && primaryClaimId ;
2019-04-03 19:12:51 +02:00
2019-08-20 22:00:26 +02:00
return _extends ( {
isChannel ,
path
2020-05-11 16:09:38 +02:00
} , streamName ? { streamName } : { } , streamClaimId ? { streamClaimId } : { } , channelName ? { channelName } : { } , channelClaimId ? { channelClaimId } : { } , primaryClaimSequence ? { primaryClaimSequence : parseInt ( primaryClaimSequence , 10 ) } : { } , secondaryClaimSequence ? { secondaryClaimSequence : parseInt ( secondaryClaimSequence , 10 ) } : { } , primaryBidPosition ? { primaryBidPosition : parseInt ( primaryBidPosition , 10 ) } : { } , secondaryBidPosition ? { secondaryBidPosition : parseInt ( secondaryBidPosition , 10 ) } : { } , startTime ? { startTime : parseInt ( startTime , 10 ) } : { } , {
2019-08-20 22:00:26 +02:00
// The values below should not be used for new uses of parseURI
// They will not work properly with canonical_urls
claimName : streamNameOrChannelName ,
claimId : primaryClaimId
2019-08-28 19:19:12 +02:00
} , streamName ? { contentName : streamName } : { } , qs ? { queryString : qs } : { } ) ;
2019-08-20 22:00:26 +02:00
}
2019-04-03 19:12:51 +02:00
2019-08-20 22:00:26 +02:00
function parseURIModifier ( modSeperator , modValue ) {
2019-04-03 19:12:51 +02:00
let claimId ;
let claimSequence ;
let bidPosition ;
2019-08-24 04:43:49 +02:00
2019-08-20 22:00:26 +02:00
if ( modSeperator ) {
if ( ! modValue ) {
2019-12-21 21:32:55 +01:00
throw new Error ( _ _ ( ` No modifier provided after separator %modSeperator%. ` , { modSeperator } ) ) ;
2019-04-03 19:12:51 +02:00
}
2019-08-20 22:00:26 +02:00
if ( modSeperator === '#' ) {
claimId = modValue ;
} else if ( modSeperator === ':' ) {
claimSequence = modValue ;
} else if ( modSeperator === '$' ) {
bidPosition = modValue ;
2019-04-03 19:12:51 +02:00
}
}
if ( claimId && ( claimId . length > claimIdMaxLength || ! claimId . match ( /^[0-9a-f]+$/ ) ) ) {
2019-12-21 21:32:55 +01:00
throw new Error ( _ _ ( ` Invalid claim ID %claimId%. ` , { claimId } ) ) ;
2019-04-03 19:12:51 +02:00
}
if ( claimSequence && ! claimSequence . match ( /^-?[1-9][0-9]*$/ ) ) {
2019-12-21 21:32:55 +01:00
throw new Error ( _ _ ( 'Claim sequence must be a number.' ) ) ;
2019-04-03 19:12:51 +02:00
}
if ( bidPosition && ! bidPosition . match ( /^-?[1-9][0-9]*$/ ) ) {
2019-12-21 21:32:55 +01:00
throw new Error ( _ _ ( 'Bid position must be a number.' ) ) ;
2019-04-03 19:12:51 +02:00
}
2019-08-20 22:00:26 +02:00
return [ claimId , claimSequence , bidPosition ] ;
2019-04-03 19:12:51 +02:00
}
/ * *
* Takes an object in the same format returned by parse ( ) and builds a URI .
*
* The channelName key will accept names with or without the @ prefix .
* /
2019-08-20 22:00:26 +02:00
function buildURI ( UrlObj , includeProto = true , protoDefault = 'lbry://' ) {
const {
streamName ,
streamClaimId ,
channelName ,
channelClaimId ,
primaryClaimSequence ,
primaryBidPosition ,
secondaryClaimSequence ,
2020-05-11 16:09:38 +02:00
secondaryBidPosition ,
startTime
2019-08-20 22:00:26 +02:00
} = UrlObj ,
2020-05-11 16:09:38 +02:00
deprecatedParts = _objectWithoutProperties ( UrlObj , [ 'streamName' , 'streamClaimId' , 'channelName' , 'channelClaimId' , 'primaryClaimSequence' , 'primaryBidPosition' , 'secondaryClaimSequence' , 'secondaryBidPosition' , 'startTime' ] ) ;
2019-08-20 22:00:26 +02:00
const { claimId , claimName , contentName } = deprecatedParts ;
if ( ! claimName && ! channelName && ! streamName ) {
2019-08-30 18:28:36 +02:00
console . error ( _ _ ( "'claimName', 'channelName', and 'streamName' are all empty. One must be present to build a url." ) ) ;
2019-04-03 19:12:51 +02:00
}
2019-08-20 22:00:26 +02:00
const formattedChannelName = channelName && ( channelName . startsWith ( '@' ) ? channelName : ` @ ${ channelName } ` ) ;
2019-08-22 17:03:13 +02:00
const primaryClaimName = claimName || contentName || formattedChannelName || streamName ;
2019-08-20 22:00:26 +02:00
const primaryClaimId = claimId || ( formattedChannelName ? channelClaimId : streamClaimId ) ;
2019-08-22 17:03:13 +02:00
const secondaryClaimName = ! claimName && contentName || ( formattedChannelName ? streamName : null ) ;
2019-08-20 22:00:26 +02:00
const secondaryClaimId = secondaryClaimName && streamClaimId ;
2019-04-03 19:12:51 +02:00
2019-08-20 22:00:26 +02:00
return ( includeProto ? protoDefault : '' ) +
// primaryClaimName will always exist here because we throw above if there is no "name" value passed in
// $FlowFixMe
2020-05-11 16:09:38 +02:00
primaryClaimName + ( primaryClaimId ? ` # ${ primaryClaimId } ` : '' ) + ( primaryClaimSequence ? ` : ${ primaryClaimSequence } ` : '' ) + ( primaryBidPosition ? ` ${ primaryBidPosition } ` : '' ) + ( secondaryClaimName ? ` / ${ secondaryClaimName } ` : '' ) + ( secondaryClaimId ? ` # ${ secondaryClaimId } ` : '' ) + ( secondaryClaimSequence ? ` : ${ secondaryClaimSequence } ` : '' ) + ( secondaryBidPosition ? ` ${ secondaryBidPosition } ` : '' ) + ( startTime ? ` ?t= ${ startTime } ` : '' ) ;
2019-04-03 19:12:51 +02:00
}
2019-08-20 22:00:26 +02:00
/* Takes a parseable LBRY URL and converts it to standard, canonical format */
function normalizeURI ( URL ) {
const {
streamName ,
streamClaimId ,
channelName ,
channelClaimId ,
primaryClaimSequence ,
primaryBidPosition ,
secondaryClaimSequence ,
2020-05-11 16:09:38 +02:00
secondaryBidPosition ,
startTime
2019-08-20 22:00:26 +02:00
} = parseURI ( URL ) ;
return buildURI ( {
streamName ,
streamClaimId ,
channelName ,
channelClaimId ,
primaryClaimSequence ,
primaryBidPosition ,
secondaryClaimSequence ,
2020-05-11 16:09:38 +02:00
secondaryBidPosition ,
startTime
2019-08-20 22:00:26 +02:00
} ) ;
2019-04-03 19:12:51 +02:00
}
2019-08-20 22:00:26 +02:00
function isURIValid ( URL ) {
2019-04-03 19:12:51 +02:00
try {
2019-10-08 21:03:09 +02:00
parseURI ( normalizeURI ( URL ) ) ;
2019-04-03 19:12:51 +02:00
} catch ( error ) {
return false ;
}
2019-08-20 22:00:26 +02:00
return true ;
2019-04-03 19:12:51 +02:00
}
2019-06-03 04:55:52 +02:00
function isNameValid ( claimName ) {
return ! regexInvalidURI . test ( claimName ) ;
2019-04-03 19:12:51 +02:00
}
2019-08-20 22:00:26 +02:00
function isURIClaimable ( URL ) {
2019-04-03 19:12:51 +02:00
let parts ;
try {
2019-08-20 22:00:26 +02:00
parts = parseURI ( normalizeURI ( URL ) ) ;
2019-04-03 19:12:51 +02:00
} catch ( error ) {
return false ;
}
2019-08-20 22:00:26 +02:00
return parts && parts . streamName && ! parts . streamClaimId && ! parts . isChannel ;
2019-04-03 19:12:51 +02:00
}
2019-08-20 22:00:26 +02:00
function convertToShareLink ( URL ) {
const {
streamName ,
streamClaimId ,
channelName ,
channelClaimId ,
primaryBidPosition ,
primaryClaimSequence ,
secondaryBidPosition ,
secondaryClaimSequence
} = parseURI ( URL ) ;
return buildURI ( {
streamName ,
streamClaimId ,
channelName ,
channelClaimId ,
primaryBidPosition ,
primaryClaimSequence ,
secondaryBidPosition ,
secondaryClaimSequence
} , true , 'https://open.lbry.com/' ) ;
2019-04-03 19:12:51 +02:00
}
var _extends$1 = Object . assign || function ( target ) { for ( var i = 1 ; i < arguments . length ; i ++ ) { var source = arguments [ i ] ; for ( var key in source ) { if ( Object . prototype . hasOwnProperty . call ( source , key ) ) { target [ key ] = source [ key ] ; } } } return target ; } ;
const selectState = state => state . search ;
const selectSearchValue = reselect . createSelector ( selectState , state => state . searchQuery ) ;
const selectSearchOptions = reselect . createSelector ( selectState , state => state . options ) ;
const selectSuggestions = reselect . createSelector ( selectState , state => state . suggestions ) ;
const selectIsSearching = reselect . createSelector ( selectState , state => state . searching ) ;
const selectSearchUrisByQuery = reselect . createSelector ( selectState , state => state . urisByQuery ) ;
const makeSelectSearchUris = query =>
// replace statement below is kind of ugly, and repeated in doSearch action
reselect . createSelector ( selectSearchUrisByQuery , byQuery => byQuery [ query ? query . replace ( /^lbry:\/\//i , '' ) . replace ( /\// , ' ' ) : query ] ) ;
2020-01-22 02:04:50 +01:00
const selectResolvedSearchResultsByQuery = reselect . createSelector ( selectState , state => state . resolvedResultsByQuery ) ;
const selectResolvedSearchResultsByQueryLastPageReached = reselect . createSelector ( selectState , state => state . resolvedResultsByQueryLastPageReached ) ;
const makeSelectResolvedSearchResults = query =>
// replace statement below is kind of ugly, and repeated in doSearch action
reselect . createSelector ( selectResolvedSearchResultsByQuery , byQuery => byQuery [ query ? query . replace ( /^lbry:\/\//i , '' ) . replace ( /\// , ' ' ) : query ] ) ;
const makeSelectResolvedSearchResultsLastPageReached = query =>
// replace statement below is kind of ugly, and repeated in doSearch action
reselect . createSelector ( selectResolvedSearchResultsByQueryLastPageReached , byQuery => byQuery [ query ? query . replace ( /^lbry:\/\//i , '' ) . replace ( /\// , ' ' ) : query ] ) ;
2019-04-03 19:12:51 +02:00
const selectSearchBarFocused = reselect . createSelector ( selectState , state => state . focused ) ;
const selectSearchSuggestions = reselect . createSelector ( selectSearchValue , selectSuggestions , ( query , suggestions ) => {
if ( ! query ) {
return [ ] ;
}
2019-06-18 18:59:04 +02:00
const queryIsPrefix = query === 'lbry:' || query === 'lbry:/' || query === 'lbry://' || query === 'lbry://@' ;
2019-04-03 19:12:51 +02:00
2019-06-18 18:59:04 +02:00
if ( queryIsPrefix ) {
// If it is a prefix, wait until something else comes to figure out what to do
return [ ] ;
} else if ( query . startsWith ( 'lbry://' ) ) {
2019-04-03 19:12:51 +02:00
// If it starts with a prefix, don't show any autocomplete results
// They are probably typing/pasting in a lbry uri
return [ {
value : query ,
2019-06-18 18:59:04 +02:00
type : query [ 7 ] === '@' ? SEARCH _TYPES . CHANNEL : SEARCH _TYPES . FILE
2019-04-03 19:12:51 +02:00
} ] ;
}
let searchSuggestions = [ ] ;
try {
const uri = normalizeURI ( query ) ;
2019-08-20 22:00:26 +02:00
const { channelName , streamName , isChannel } = parseURI ( uri ) ;
2019-04-03 19:12:51 +02:00
searchSuggestions . push ( {
2019-08-28 01:14:19 +02:00
value : query ,
2019-04-03 19:12:51 +02:00
type : SEARCH _TYPES . SEARCH
} , {
value : uri ,
2019-08-20 22:00:26 +02:00
shorthand : isChannel ? channelName : streamName ,
2019-04-03 19:12:51 +02:00
type : isChannel ? SEARCH _TYPES . CHANNEL : SEARCH _TYPES . FILE
} ) ;
} catch ( e ) {
searchSuggestions . push ( {
value : query ,
type : SEARCH _TYPES . SEARCH
} ) ;
}
2019-07-10 18:48:50 +02:00
searchSuggestions . push ( {
value : query ,
type : SEARCH _TYPES . TAG
} ) ;
2019-04-03 19:12:51 +02:00
const apiSuggestions = suggestions [ query ] || [ ] ;
if ( apiSuggestions . length ) {
searchSuggestions = searchSuggestions . concat ( apiSuggestions . filter ( suggestion => suggestion !== query ) . map ( suggestion => {
// determine if it's a channel
try {
const uri = normalizeURI ( suggestion ) ;
2019-08-20 22:00:26 +02:00
const { channelName , streamName , isChannel } = parseURI ( uri ) ;
2019-04-03 19:12:51 +02:00
return {
value : uri ,
2019-08-20 22:00:26 +02:00
shorthand : isChannel ? channelName : streamName ,
2019-04-03 19:12:51 +02:00
type : isChannel ? SEARCH _TYPES . CHANNEL : SEARCH _TYPES . FILE
} ;
} catch ( e ) {
// search result includes some character that isn't valid in claim names
return {
value : suggestion ,
type : SEARCH _TYPES . SEARCH
} ;
}
} ) ) ;
}
return searchSuggestions ;
} ) ;
// Creates a query string based on the state in the search reducer
// Can be overrided by passing in custom sizes/from values for other areas pagination
2020-01-30 07:30:27 +01:00
const makeSelectQueryWithOptions = ( customQuery , options ) => reselect . createSelector ( selectSearchValue , selectSearchOptions , ( query , defaultOptions ) => {
const searchOptions = _extends$1 ( { } , defaultOptions , options ) ;
const queryString = getSearchQueryString ( customQuery || query , searchOptions ) ;
2019-04-03 19:12:51 +02:00
return queryString ;
} ) ;
2019-10-15 05:35:38 +02:00
/* eslint-disable */
// underscore's deep equal function
// https://github.com/jashkenas/underscore/blob/master/underscore.js#L1189
function isEqual ( a , b , aStack , bStack ) {
// Identical objects are equal. `0 === -0`, but they aren't identical.
// See the [Harmony `egal` proposal](http://wiki.ecmascript.org/doku.php?id=harmony:egal).
if ( a === b ) return a !== 0 || 1 / a === 1 / b ;
// `null` or `undefined` only equal to itself (strict comparison).
if ( a == null || b == null ) return false ;
// `NaN`s are equivalent, but non-reflexive.
if ( a !== a ) return b !== b ;
// Exhaust primitive checks
var type = typeof a ;
if ( type !== 'function' && type !== 'object' && typeof b != 'object' ) return false ;
return deepEq ( a , b , aStack , bStack ) ;
}
function deepEq ( a , b , aStack , bStack ) {
// Compare `[[Class]]` names.
var className = toString . call ( a ) ;
if ( className !== toString . call ( b ) ) return false ;
switch ( className ) {
// Strings, numbers, regular expressions, dates, and booleans are compared by value.
case '[object RegExp]' :
// RegExps are coerced to strings for comparison (Note: '' + /a/i === '/a/i')
case '[object String]' :
// Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is
// equivalent to `new String("5")`.
return '' + a === '' + b ;
case '[object Number]' :
// `NaN`s are equivalent, but non-reflexive.
// Object(NaN) is equivalent to NaN.
if ( + a !== + a ) return + b !== + b ;
// An `egal` comparison is performed for other numeric values.
return + a === 0 ? 1 / + a === 1 / b : + a === + b ;
case '[object Date]' :
case '[object Boolean]' :
// Coerce dates and booleans to numeric primitive values. Dates are compared by their
// millisecond representations. Note that invalid dates with millisecond representations
// of `NaN` are not equivalent.
return + a === + b ;
case '[object Symbol]' :
return SymbolProto . valueOf . call ( a ) === SymbolProto . valueOf . call ( b ) ;
}
var areArrays = className === '[object Array]' ;
if ( ! areArrays ) {
if ( typeof a != 'object' || typeof b != 'object' ) return false ;
// Objects with different constructors are not equivalent, but `Object`s or `Array`s
// from different frames are.
var aCtor = a . constructor ,
bCtor = b . constructor ;
if ( aCtor !== bCtor && ! ( typeof aCtor === 'function' && aCtor instanceof aCtor && typeof bCtor === 'function' && bCtor instanceof bCtor ) && 'constructor' in a && 'constructor' in b ) {
return false ;
}
}
// Assume equality for cyclic structures. The algorithm for detecting cyclic
// structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`.
// Initializing stack of traversed objects.
// It's done here since we only need them for objects and arrays comparison.
aStack = aStack || [ ] ;
bStack = bStack || [ ] ;
var length = aStack . length ;
while ( length -- ) {
// Linear search. Performance is inversely proportional to the number of
// unique nested structures.
if ( aStack [ length ] === a ) return bStack [ length ] === b ;
}
// Add the first object to the stack of traversed objects.
aStack . push ( a ) ;
bStack . push ( b ) ;
// Recursively compare objects and arrays.
if ( areArrays ) {
// Compare array lengths to determine if a deep comparison is necessary.
length = a . length ;
if ( length !== b . length ) return false ;
// Deep compare the contents, ignoring non-numeric properties.
while ( length -- ) {
if ( ! isEqual ( a [ length ] , b [ length ] , aStack , bStack ) ) return false ;
}
} else {
// Deep compare objects.
var keys = Object . keys ( a ) ,
key ;
length = keys . length ;
// Ensure that both objects contain the same number of properties before comparing deep equality.
if ( Object . keys ( b ) . length !== length ) return false ;
while ( length -- ) {
// Deep compare each member
key = keys [ length ] ;
if ( ! ( has ( b , key ) && isEqual ( a [ key ] , b [ key ] , aStack , bStack ) ) ) return false ;
}
}
// Remove the first object from the stack of traversed objects.
aStack . pop ( ) ;
bStack . pop ( ) ;
return true ;
}
function has ( obj , path ) {
return obj != null && hasOwnProperty . call ( obj , path ) ;
}
/* eslint-enable */
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 ; } ;
function extractUserState ( rawObj ) {
if ( rawObj && rawObj . version === '0.1' && rawObj . value ) {
2020-02-25 14:52:39 +01:00
const {
subscriptions ,
tags ,
blocked ,
settings ,
app _welcome _version ,
sharing _3P
} = rawObj . value ;
2019-10-15 05:35:38 +02:00
2020-02-21 18:20:18 +01:00
return _extends$2 ( { } , subscriptions ? { subscriptions } : { } , tags ? { tags } : { } , blocked ? { blocked } : { } , settings ? { settings } : { } , app _welcome _version ? { app _welcome _version } : { } , sharing _3P ? { sharing _3P } : { } ) ;
2019-10-15 05:35:38 +02:00
}
return { } ;
}
2019-12-11 15:45:18 +01:00
function doPopulateSharedUserState ( sharedSettings ) {
2019-10-15 05:35:38 +02:00
return dispatch => {
2020-02-25 14:52:39 +01:00
const {
subscriptions ,
tags ,
blocked ,
settings ,
app _welcome _version ,
sharing _3P
} = extractUserState ( sharedSettings ) ;
2020-01-13 23:00:04 +01:00
dispatch ( {
type : USER _STATE _POPULATE ,
2020-02-25 14:52:39 +01:00
data : {
subscriptions ,
tags ,
blocked ,
settings ,
welcomeVersion : app _welcome _version ,
allowAnalytics : sharing _3P
}
2020-01-13 23:00:04 +01:00
} ) ;
2019-10-15 05:35:38 +02:00
} ;
}
function doPreferenceSet ( key , value , version , success , fail ) {
const preference = {
type : typeof value ,
version ,
value
} ;
const options = {
key ,
value : JSON . stringify ( preference )
} ;
lbryProxy . preference _set ( options ) . then ( ( ) => {
success ( preference ) ;
} ) . catch ( ( ) => {
if ( fail ) {
fail ( ) ;
}
} ) ;
}
function doPreferenceGet ( key , success , fail ) {
const options = {
key
} ;
lbryProxy . preference _get ( options ) . then ( result => {
if ( result ) {
const preference = result [ key ] ;
return success ( preference ) ;
}
return success ( null ) ;
} ) . catch ( err => {
if ( fail ) {
fail ( err ) ;
}
} ) ;
}
//
const SHARED _PREFERENCE _KEY = 'shared' ;
const SHARED _PREFERENCE _VERSION = '0.1' ;
let oldShared = { } ;
const buildSharedStateMiddleware = ( actions , sharedStateFilters , sharedStateCb ) => ( { getState , dispatch } ) => next => action => {
const currentState = getState ( ) ;
// We don't care if sync is disabled here, we always want to backup preferences to the wallet
if ( ! actions . includes ( action . type ) ) {
return next ( action ) ;
}
const actionResult = next ( action ) ;
2020-02-26 19:11:36 +01:00
// Call `getState` after calling `next` to ensure the state has updated in response to the action
2019-10-15 05:35:38 +02:00
const nextState = getState ( ) ;
const shared = { } ;
Object . keys ( sharedStateFilters ) . forEach ( key => {
const filter = sharedStateFilters [ key ] ;
const { source , property , transform } = filter ;
let value = nextState [ source ] [ property ] ;
if ( transform ) {
value = transform ( value ) ;
}
shared [ key ] = value ;
} ) ;
if ( ! isEqual ( oldShared , shared ) ) {
// only update if the preference changed from last call in the same session
oldShared = shared ;
doPreferenceSet ( SHARED _PREFERENCE _KEY , shared , SHARED _PREFERENCE _VERSION ) ;
2019-10-15 17:20:00 +02:00
}
2019-10-15 05:35:38 +02:00
2019-10-15 17:20:00 +02:00
if ( sharedStateCb ) {
// Pass dispatch to the callback to consumers can dispatch actions in response to preference set
sharedStateCb ( { dispatch , getState } ) ;
2019-10-15 05:35:38 +02:00
}
return actionResult ;
} ;
2019-04-03 19:12:51 +02:00
//
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-08-15 08:13:50 +02:00
const selectState$1 = state => state . wallet || { } ;
const selectWalletState = selectState$1 ;
const selectWalletIsEncrypted = reselect . createSelector ( selectState$1 , state => state . walletIsEncrypted ) ;
const selectWalletEncryptPending = reselect . createSelector ( selectState$1 , state => state . walletEncryptPending ) ;
const selectWalletEncryptSucceeded = reselect . createSelector ( selectState$1 , state => state . walletEncryptSucceded ) ;
2020-03-25 03:46:35 +01:00
const selectPendingSupportTransactions = reselect . createSelector ( selectState$1 , state => state . pendingSupportTransactions ) ;
2020-04-01 20:26:38 +02:00
const selectAbandonClaimSupportError = reselect . createSelector ( selectState$1 , state => state . abandonClaimSupportError ) ;
2020-03-25 03:46:35 +01:00
const makeSelectPendingAmountByUri = uri => reselect . createSelector ( selectClaimIdsByUri , selectPendingSupportTransactions , ( claimIdsByUri , pendingSupports ) => {
const uriEntry = Object . entries ( claimIdsByUri ) . find ( ( [ u , cid ] ) => u === uri ) ;
const claimId = uriEntry && uriEntry [ 1 ] ;
const pendingSupport = claimId && pendingSupports [ claimId ] ;
return pendingSupport ? pendingSupport . effective : undefined ;
} ) ;
2019-08-15 08:13:50 +02:00
const selectWalletEncryptResult = reselect . createSelector ( selectState$1 , state => state . walletEncryptResult ) ;
const selectWalletDecryptPending = reselect . createSelector ( selectState$1 , state => state . walletDecryptPending ) ;
const selectWalletDecryptSucceeded = reselect . createSelector ( selectState$1 , state => state . walletDecryptSucceded ) ;
const selectWalletDecryptResult = reselect . createSelector ( selectState$1 , state => state . walletDecryptResult ) ;
const selectWalletUnlockPending = reselect . createSelector ( selectState$1 , state => state . walletUnlockPending ) ;
const selectWalletUnlockSucceeded = reselect . createSelector ( selectState$1 , state => state . walletUnlockSucceded ) ;
const selectWalletUnlockResult = reselect . createSelector ( selectState$1 , state => state . walletUnlockResult ) ;
const selectWalletLockPending = reselect . createSelector ( selectState$1 , state => state . walletLockPending ) ;
const selectWalletLockSucceeded = reselect . createSelector ( selectState$1 , state => state . walletLockSucceded ) ;
const selectWalletLockResult = reselect . createSelector ( selectState$1 , state => state . walletLockResult ) ;
const selectBalance = reselect . createSelector ( selectState$1 , state => state . balance ) ;
const selectTotalBalance = reselect . createSelector ( selectState$1 , state => state . totalBalance ) ;
2019-09-24 00:56:53 +02:00
const selectReservedBalance = reselect . createSelector ( selectState$1 , state => state . reservedBalance ) ;
const selectClaimsBalance = reselect . createSelector ( selectState$1 , state => state . claimsBalance ) ;
const selectSupportsBalance = reselect . createSelector ( selectState$1 , state => state . supportsBalance ) ;
const selectTipsBalance = reselect . createSelector ( selectState$1 , state => state . tipsBalance ) ;
2019-08-15 08:13:50 +02:00
const selectTransactionsById = reselect . createSelector ( selectState$1 , state => state . transactions || { } ) ;
const selectSupportsByOutpoint = reselect . createSelector ( selectState$1 , state => state . supports || { } ) ;
const selectTotalSupports = reselect . createSelector ( selectSupportsByOutpoint , byOutpoint => {
2019-09-30 23:58:15 +02:00
let total = parseFloat ( '0.0' ) ;
2019-08-15 08:13:50 +02:00
Object . values ( byOutpoint ) . forEach ( support => {
const { amount } = support ;
total = amount ? total + parseFloat ( amount ) : total ;
} ) ;
return total ;
} ) ;
const selectTransactionItems = reselect . createSelector ( selectTransactionsById , byId => {
const items = [ ] ;
Object . keys ( byId ) . forEach ( txid => {
const tx = byId [ txid ] ;
// ignore dust/fees
// it is fee only txn if all infos are also empty
if ( Math . abs ( tx . value ) === Math . abs ( tx . fee ) && tx . claim _info . length === 0 && tx . support _info . length === 0 && tx . update _info . length === 0 && tx . abandon _info . length === 0 ) {
return ;
}
const append = [ ] ;
append . push ( ... tx . claim _info . map ( item => Object . assign ( { } , tx , item , {
type : item . claim _name [ 0 ] === '@' ? CHANNEL$1 : PUBLISH$1
} ) ) ) ;
append . push ( ... tx . support _info . map ( item => Object . assign ( { } , tx , item , {
type : ! item . is _tip ? SUPPORT : TIP
} ) ) ) ;
append . push ( ... tx . update _info . map ( item => Object . assign ( { } , tx , item , { type : UPDATE } ) ) ) ;
append . push ( ... tx . abandon _info . map ( item => Object . assign ( { } , tx , item , { type : ABANDON } ) ) ) ;
if ( ! append . length ) {
append . push ( Object . assign ( { } , tx , {
type : tx . value < 0 ? SPEND : RECEIVE
} ) ) ;
}
items . push ( ... append . map ( item => {
// value on transaction, amount on outpoint
// amount is always positive, but should match sign of value
const balanceDelta = parseFloat ( item . balance _delta ) ;
const value = parseFloat ( item . value ) ;
const amount = balanceDelta || value ;
const fee = parseFloat ( tx . fee ) ;
return {
txid ,
timestamp : tx . timestamp ,
date : tx . timestamp ? new Date ( Number ( tx . timestamp ) * 1000 ) : null ,
amount ,
fee ,
claim _id : item . claim _id ,
claim _name : item . claim _name ,
type : item . type || SPEND ,
nout : item . nout ,
confirmations : tx . confirmations
} ;
} ) ) ;
} ) ;
return items . sort ( ( tx1 , tx2 ) => {
if ( ! tx1 . timestamp && ! tx2 . timestamp ) {
return 0 ;
} else if ( ! tx1 . timestamp && tx2 . timestamp ) {
return - 1 ;
} else if ( tx1 . timestamp && ! tx2 . timestamp ) {
return 1 ;
}
return tx2 . timestamp - tx1 . timestamp ;
} ) ;
} ) ;
const selectRecentTransactions = reselect . createSelector ( selectTransactionItems , transactions => {
const threshold = new Date ( ) ;
threshold . setDate ( threshold . getDate ( ) - 7 ) ;
return transactions . filter ( transaction => {
if ( ! transaction . date ) {
return true ; // pending transaction
}
return transaction . date > threshold ;
} ) ;
} ) ;
const selectHasTransactions = reselect . createSelector ( selectTransactionItems , transactions => transactions && transactions . length > 0 ) ;
const selectIsFetchingTransactions = reselect . createSelector ( selectState$1 , state => state . fetchingTransactions ) ;
const selectIsSendingSupport = reselect . createSelector ( selectState$1 , state => state . sendingSupport ) ;
const selectReceiveAddress = reselect . createSelector ( selectState$1 , state => state . receiveAddress ) ;
const selectGettingNewAddress = reselect . createSelector ( selectState$1 , state => state . gettingNewAddress ) ;
const selectDraftTransaction = reselect . createSelector ( selectState$1 , state => state . draftTransaction || { } ) ;
const selectDraftTransactionAmount = reselect . createSelector ( selectDraftTransaction , draft => draft . amount ) ;
const selectDraftTransactionAddress = reselect . createSelector ( selectDraftTransaction , draft => draft . address ) ;
const selectDraftTransactionError = reselect . createSelector ( selectDraftTransaction , draft => draft . error ) ;
const selectBlocks = reselect . createSelector ( selectState$1 , state => state . blocks ) ;
const selectCurrentHeight = reselect . createSelector ( selectState$1 , state => state . latestBlock ) ;
const selectTransactionListFilter = reselect . createSelector ( selectState$1 , state => state . transactionListFilter || '' ) ;
2019-09-23 04:25:12 +02:00
const selectFilteredTransactions = reselect . createSelector ( selectTransactionItems , selectTransactionListFilter , ( transactions , filter ) => {
return transactions . filter ( transaction => {
return filter === ALL || filter === transaction . type ;
} ) ;
} ) ;
2020-04-10 14:16:27 +02:00
const selectTxoPageParams = reselect . createSelector ( selectState$1 , state => state . txoFetchParams ) ;
const selectTxoPage = reselect . createSelector ( selectState$1 , state => state . txoPage && state . txoPage . items || [ ] ) ;
const selectTxoPageNumber = reselect . createSelector ( selectState$1 , state => state . txoPage && state . txoPage . page || 1 ) ;
const selectTxoItemCount = reselect . createSelector ( selectState$1 , state => state . txoPage && state . txoPage . total _items || 1 ) ;
const selectFetchingTxosError = reselect . createSelector ( selectState$1 , state => state . fetchingTxosError ) ;
const selectIsFetchingTxos = reselect . createSelector ( selectState$1 , state => state . fetchingTxos ) ;
2019-09-23 04:25:12 +02:00
const makeSelectFilteredTransactionsForPage = ( page = 1 ) => reselect . createSelector ( selectFilteredTransactions , filteredTransactions => {
2019-09-25 18:30:26 +02:00
const start = ( Number ( page ) - 1 ) * Number ( PAGE _SIZE$1 ) ;
const end = Number ( page ) * Number ( PAGE _SIZE$1 ) ;
2019-09-23 04:25:12 +02:00
return filteredTransactions && filteredTransactions . length ? filteredTransactions . slice ( start , end ) : [ ] ;
} ) ;
2019-11-01 18:17:55 +01:00
const makeSelectLatestTransactions = reselect . createSelector ( selectTransactionItems , transactions => {
2019-11-01 20:08:42 +01:00
return transactions && transactions . length ? transactions . slice ( 0 , LATEST _PAGE _SIZE ) : [ ] ;
2019-11-01 18:17:55 +01:00
} ) ;
2019-09-23 04:25:12 +02:00
const selectFilteredTransactionCount = reselect . createSelector ( selectFilteredTransactions , filteredTransactions => filteredTransactions . length ) ;
2019-12-18 17:47:18 +01:00
const selectIsWalletReconnecting = reselect . createSelector ( selectState$1 , state => state . walletReconnecting ) ;
2019-10-15 05:35:38 +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-23 19:22:14 +02:00
2019-08-20 22:00:26 +02:00
function _objectWithoutProperties$1 ( obj , keys ) { var target = { } ; for ( var i in obj ) { if ( keys . indexOf ( i ) >= 0 ) continue ; if ( ! Object . prototype . hasOwnProperty . call ( obj , i ) ) continue ; target [ i ] = obj [ i ] ; } return target ; }
2019-07-30 17:48:45 +02:00
2019-10-15 05:35:38 +02:00
const matureTagMap = MATURE _TAGS . reduce ( ( acc , tag ) => _extends$3 ( { } , acc , { [ tag ] : true } ) , { } ) ;
2019-04-23 19:22:14 +02:00
const isClaimNsfw = claim => {
if ( ! claim ) {
throw new Error ( 'No claim passed to isClaimNsfw()' ) ;
}
if ( ! claim . value ) {
return false ;
}
const tags = claim . value . tags || [ ] ;
for ( let i = 0 ; i < tags . length ; i += 1 ) {
2019-04-23 21:02:32 +02:00
const tag = tags [ i ] . toLowerCase ( ) ;
2019-07-02 22:33:57 +02:00
if ( matureTagMap [ tag ] ) {
2019-04-23 19:22:14 +02:00
return true ;
}
}
return false ;
} ;
2019-07-30 17:48:45 +02:00
function createNormalizedClaimSearchKey ( options ) {
// Ignore page because we don't care what the last page searched was, we want everything
// Ignore release_time because that will change depending on when you call claim_search ex: release_time: ">12344567"
2019-08-20 22:00:26 +02:00
const rest = _objectWithoutProperties$1 ( options , [ 'page' , 'release_time' ] ) ;
2019-07-30 17:48:45 +02:00
const query = JSON . stringify ( rest ) ;
return query ;
}
2019-07-26 08:27:09 +02:00
2020-05-08 22:47:33 +02:00
function filterClaims ( claims , query ) {
if ( query ) {
const queryMatchRegExp = new RegExp ( query , 'i' ) ;
return claims . filter ( claim => {
const { value } = claim ;
return value . title && value . title . match ( queryMatchRegExp ) || claim . signing _channel && claim . signing _channel . name . match ( queryMatchRegExp ) || claim . name && claim . name . match ( queryMatchRegExp ) ;
} ) ;
}
return claims ;
}
2020-01-30 23:13:40 +01: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 ; } ;
2020-05-08 22:47:33 +02:00
2019-08-15 08:13:50 +02:00
const selectState$2 = state => state . claims || { } ;
2019-04-03 19:12:51 +02:00
2019-08-15 08:13:50 +02:00
const selectClaimsById = reselect . createSelector ( selectState$2 , state => state . byId || { } ) ;
2019-04-03 19:12:51 +02:00
2020-03-25 03:46:35 +01:00
const selectClaimIdsByUri = reselect . createSelector ( selectState$2 , state => state . claimsByUri || { } ) ;
2019-08-15 08:13:50 +02:00
const selectCurrentChannelPage = reselect . createSelector ( selectState$2 , state => state . currentChannelPage || 1 ) ;
2019-04-03 19:12:51 +02:00
2019-08-27 06:42:52 +02:00
const selectCreatingChannel = reselect . createSelector ( selectState$2 , state => state . creatingChannel ) ;
2019-09-13 21:52:52 +02:00
const selectCreateChannelError = reselect . createSelector ( selectState$2 , state => state . createChannelError ) ;
2019-09-10 20:14:40 +02:00
2020-02-10 16:49:45 +01:00
const selectRepostLoading = reselect . createSelector ( selectState$2 , state => state . repostLoading ) ;
const selectRepostError = reselect . createSelector ( selectState$2 , state => state . repostError ) ;
2020-06-17 03:56:51 +02:00
const selectClaimsByUri = reselect . createSelector ( selectClaimIdsByUri , selectClaimsById , ( byUri , byId ) => {
2019-04-03 19:12:51 +02:00
const claims = { } ;
Object . keys ( byUri ) . forEach ( uri => {
const claimId = byUri [ uri ] ;
// NOTE returning a null claim allows us to differentiate between an
// undefined (never fetched claim) and one which just doesn't exist. Not
// the cleanest solution but couldn't think of anything better right now
if ( claimId === null ) {
claims [ uri ] = null ;
} else {
claims [ uri ] = byId [ claimId ] ;
}
} ) ;
return claims ;
} ) ;
2019-11-22 02:36:06 +01:00
const selectAllClaimsByChannel = reselect . createSelector ( selectState$2 , state => state . paginatedClaimsByChannel || { } ) ;
2019-04-03 19:12:51 +02:00
2020-06-17 03:56:51 +02:00
const selectPendingIds = reselect . createSelector ( selectState$2 , state => state . pendingIds || [ ] ) ;
2019-04-03 19:12:51 +02:00
2020-06-17 03:56:51 +02:00
const makeSelectClaimIsPending = uri => reselect . createSelector ( selectClaimIdsByUri , selectPendingIds , ( idsByUri , pendingIds ) => {
const claimId = idsByUri [ normalizeURI ( uri ) ] ;
2019-07-11 21:00:45 +02:00
if ( claimId ) {
2020-06-17 03:56:51 +02:00
return pendingIds . some ( i => i === claimId ) ;
2019-07-11 21:00:45 +02:00
}
2020-06-17 03:56:51 +02:00
return false ;
2019-04-03 19:12:51 +02:00
} ) ;
2020-05-07 13:41:56 +02:00
const selectReflectingById = reselect . createSelector ( selectState$2 , state => state . reflectingById ) ;
2019-04-03 19:12:51 +02:00
2020-06-17 03:56:51 +02:00
const makeSelectClaimForUri = ( uri , returnRepost = true ) => reselect . createSelector ( selectClaimIdsByUri , selectClaimsById , ( byUri , byId ) => {
let validUri ;
2019-08-20 22:00:26 +02:00
let channelClaimId ;
let streamClaimId ;
let isChannel ;
2019-07-11 21:00:45 +02:00
try {
2019-08-20 22:00:26 +02:00
( { isChannel , channelClaimId , streamClaimId } = parseURI ( uri ) ) ;
2020-06-17 03:56:51 +02:00
validUri = true ;
2019-07-11 21:00:45 +02:00
} catch ( e ) { }
2020-06-17 03:56:51 +02:00
if ( validUri && byUri ) {
const claimId = uri && byUri [ normalizeURI ( uri ) ] ;
const claim = byId [ claimId ] ;
2020-06-23 17:15:17 +02:00
// Make sure to return the claim as is so apps can check if it's been resolved before (null) or still needs to be resolved (undefined)
if ( claimId === null ) {
return null ;
} else if ( claimId === undefined ) {
return undefined ;
2020-01-30 23:13:40 +01:00
}
const repostedClaim = claim . reposted _claim ;
2020-02-12 15:43:41 +01:00
if ( repostedClaim && returnRepost ) {
2020-01-30 23:44:08 +01:00
const channelUrl = claim . signing _channel && claim . signing _channel . canonical _url ;
2020-01-30 23:13:40 +01:00
return _extends$4 ( { } , repostedClaim , {
2020-02-12 15:43:41 +01:00
repost _url : uri ,
2020-01-30 23:44:08 +01:00
repost _channel _url : channelUrl
2020-01-30 23:13:40 +01:00
} ) ;
} else {
return claim ;
}
2019-07-11 21:00:45 +02:00
}
2019-04-03 19:12:51 +02:00
} ) ;
2020-03-25 03:46:35 +01:00
const selectMyClaimsRaw = reselect . createSelector ( selectState$2 , selectClaimsById , ( state , byId ) => {
const ids = state . myClaims ;
if ( ! ids ) {
return ids ;
}
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 ;
} ) ;
2019-04-03 19:12:51 +02:00
2019-08-15 08:13:50 +02:00
const selectAbandoningIds = reselect . createSelector ( selectState$2 , state => Object . keys ( state . abandoningById || { } ) ) ;
2019-04-03 19:12:51 +02:00
const selectMyActiveClaims = reselect . createSelector ( selectMyClaimsRaw , selectAbandoningIds , ( claims , abandoningIds ) => new Set ( claims && claims . map ( claim => claim . claim _id ) . filter ( claimId => Object . keys ( abandoningIds ) . indexOf ( claimId ) === - 1 ) ) ) ;
const makeSelectClaimIsMine = rawUri => {
2019-07-11 21:00:45 +02:00
let uri ;
try {
uri = normalizeURI ( rawUri ) ;
} catch ( e ) { }
return reselect . createSelector ( selectClaimsByUri , selectMyActiveClaims , ( claims , myClaims ) => {
try {
parseURI ( uri ) ;
} catch ( e ) {
return false ;
}
2020-04-25 22:31:53 +02:00
return claims && claims [ uri ] && ( claims [ uri ] . is _my _output || claims [ uri ] . claim _id && myClaims . has ( claims [ uri ] . claim _id ) ) ;
2019-07-11 21:00:45 +02:00
} ) ;
2019-04-03 19:12:51 +02:00
} ;
2020-05-08 22:47:33 +02:00
const selectMyPurchases = reselect . createSelector ( selectState$2 , state => state . myPurchases ) ;
2020-05-18 22:40:33 +02:00
const selectPurchaseUriSuccess = reselect . createSelector ( selectState$2 , state => state . purchaseUriSuccess ) ;
2020-05-08 22:47:33 +02:00
const selectMyPurchasesCount = reselect . createSelector ( selectState$2 , state => state . myPurchasesPageTotalResults ) ;
const selectIsFetchingMyPurchases = reselect . createSelector ( selectState$2 , state => state . fetchingMyPurchases ) ;
const selectFetchingMyPurchasesError = reselect . createSelector ( selectState$2 , state => state . fetchingMyPurchasesError ) ;
const makeSelectMyPurchasesForPage = ( query , page = 1 ) => reselect . createSelector ( selectMyPurchases , selectClaimsByUri , ( myPurchases , claimsByUri ) => {
if ( ! myPurchases ) {
return undefined ;
}
2020-05-21 15:38:30 +02:00
if ( ! query ) {
// ensure no duplicates from double purchase bugs
return [ ... new Set ( myPurchases ) ] ;
}
2020-05-08 22:47:33 +02:00
const fileInfos = myPurchases . map ( uri => claimsByUri [ uri ] ) ;
const matchingFileInfos = filterClaims ( fileInfos , query ) ;
const start = ( Number ( page ) - 1 ) * Number ( PAGE _SIZE ) ;
const end = Number ( page ) * Number ( PAGE _SIZE ) ;
return matchingFileInfos && matchingFileInfos . length ? matchingFileInfos . slice ( start , end ) . map ( fileInfo => fileInfo . canonical _url || fileInfo . permanent _url ) : [ ] ;
} ) ;
const makeSelectClaimWasPurchased = uri => reselect . createSelector ( makeSelectClaimForUri ( uri ) , claim => {
return claim && claim . purchase _receipt !== undefined ;
} ) ;
2019-08-15 08:13:50 +02:00
const selectAllFetchingChannelClaims = reselect . createSelector ( selectState$2 , state => state . fetchingChannelClaims || { } ) ;
2019-04-03 19:12:51 +02:00
const makeSelectFetchingChannelClaims = uri => reselect . createSelector ( selectAllFetchingChannelClaims , fetching => fetching && fetching [ uri ] ) ;
2019-11-22 02:36:06 +01:00
2019-04-03 19:12:51 +02:00
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 ] ) ;
} ) ;
2019-11-22 02:36:06 +01:00
const makeSelectTotalClaimsInChannelSearch = uri => reselect . createSelector ( selectClaimsById , selectAllClaimsByChannel , ( byId , allClaims ) => {
2019-11-22 00:52:37 +01:00
const byChannel = allClaims [ uri ] || { } ;
return byChannel [ 'itemCount' ] ;
} ) ;
2019-11-22 02:36:06 +01:00
const makeSelectTotalPagesInChannelSearch = uri => reselect . createSelector ( selectClaimsById , selectAllClaimsByChannel , ( byId , allClaims ) => {
2019-11-22 00:52:37 +01:00
const byChannel = allClaims [ uri ] || { } ;
return byChannel [ 'pageCount' ] ;
} ) ;
2019-04-03 19:12:51 +02:00
const makeSelectClaimsInChannelForCurrentPageState = uri => reselect . createSelector ( selectClaimsById , selectAllClaimsByChannel , selectCurrentChannelPage , ( byId , allClaims , page ) => {
const byChannel = allClaims [ uri ] || { } ;
const claimIds = byChannel [ page || 1 ] ;
if ( ! claimIds ) return claimIds ;
return claimIds . map ( claimId => byId [ claimId ] ) ;
} ) ;
const makeSelectMetadataForUri = uri => reselect . createSelector ( makeSelectClaimForUri ( uri ) , claim => {
2019-04-23 19:22:14 +02:00
const metadata = claim && claim . value ;
2019-04-03 19:12:51 +02:00
return metadata || ( claim === undefined ? undefined : null ) ;
} ) ;
2019-05-06 19:57:07 +02:00
const makeSelectMetadataItemForUri = ( uri , key ) => reselect . createSelector ( makeSelectMetadataForUri ( uri ) , metadata => {
return metadata ? metadata [ key ] : undefined ;
} ) ;
2019-04-03 19:12:51 +02:00
const makeSelectTitleForUri = uri => reselect . createSelector ( makeSelectMetadataForUri ( uri ) , metadata => metadata && metadata . title ) ;
2019-05-06 04:00:45 +02:00
const makeSelectDateForUri = uri => reselect . createSelector ( makeSelectClaimForUri ( uri ) , claim => {
2019-08-13 17:27:32 +02:00
const timestamp = claim && claim . value && ( claim . value . release _time ? claim . value . release _time * 1000 : claim . meta && claim . meta . creation _timestamp ? claim . meta . creation _timestamp * 1000 : null ) ;
2019-05-06 04:00:45 +02:00
if ( ! timestamp ) {
return undefined ;
}
const dateObj = new Date ( timestamp ) ;
return dateObj ;
} ) ;
2019-07-01 03:16:44 +02:00
const makeSelectAmountForUri = uri => reselect . createSelector ( makeSelectClaimForUri ( uri ) , claim => {
return claim && claim . amount ;
} ) ;
2019-04-03 19:12:51 +02:00
const makeSelectContentTypeForUri = uri => reselect . createSelector ( makeSelectClaimForUri ( uri ) , claim => {
2019-04-23 19:22:14 +02:00
const source = claim && claim . value && claim . value . source ;
return source ? source . media _type : undefined ;
} ) ;
const makeSelectThumbnailForUri = uri => reselect . createSelector ( makeSelectClaimForUri ( uri ) , claim => {
const thumbnail = claim && claim . value && claim . value . thumbnail ;
2020-05-02 02:50:24 +02:00
return thumbnail && thumbnail . url ? thumbnail . url . trim ( ) . replace ( /^http:\/\//i , 'https://' ) : 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 ;
2020-05-02 02:50:24 +02:00
return cover && cover . url ? cover . url . trim ( ) . replace ( /^http:\/\//i , 'https://' ) : undefined ;
2019-05-01 16:21:51 +02:00
} ) ;
2019-08-15 08:13:50 +02:00
const selectIsFetchingClaimListMine = reselect . createSelector ( selectState$2 , state => state . isFetchingClaimListMine ) ;
2019-04-03 19:12:51 +02:00
2020-04-25 22:31:53 +02:00
const selectMyClaimsPage = reselect . createSelector ( selectState$2 , state => state . myClaimsPageResults || [ ] ) ;
const selectMyClaimsPageNumber = reselect . createSelector ( selectState$2 , state => state . claimListMinePage && state . claimListMinePage . items || [ ] , state => state . txoPage && state . txoPage . page || 1 ) ;
const selectMyClaimsPageItemCount = reselect . createSelector ( selectState$2 , state => state . myClaimsPageTotalResults || 1 ) ;
const selectFetchingMyClaimsPageError = reselect . createSelector ( selectState$2 , state => state . fetchingClaimListMinePageError ) ;
2020-06-17 03:56:51 +02:00
const selectMyClaims = reselect . createSelector ( selectMyActiveClaims , selectClaimsById , selectAbandoningIds , ( myClaimIds , byId , abandoningIds ) => {
2019-04-03 19:12:51 +02:00
const claims = [ ] ;
myClaimIds . forEach ( id => {
const claim = byId [ id ] ;
if ( claim && abandoningIds . indexOf ( id ) === - 1 ) claims . push ( claim ) ;
} ) ;
2020-06-17 03:56:51 +02:00
return [ ... claims ] ;
2019-04-03 19:12:51 +02:00
} ) ;
2019-06-27 00:01:49 +02:00
const selectMyClaimsWithoutChannels = reselect . createSelector ( selectMyClaims , myClaims => myClaims . filter ( claim => ! claim . name . match ( /^@/ ) ) . sort ( ( a , b ) => a . timestamp - b . timestamp ) ) ;
2019-04-03 19:12:51 +02:00
2020-04-01 16:37:50 +02:00
const selectMyClaimUrisWithoutChannels = reselect . createSelector ( selectMyClaimsWithoutChannels , myClaims => {
return myClaims . sort ( ( a , b ) => {
if ( a . height < 1 ) {
return - 1 ;
} else if ( b . height < 1 ) {
return 1 ;
} else {
return b . timestamp - a . timestamp ;
}
} ) . map ( claim => {
return claim . canonical _url || claim . permanent _url ;
} ) ;
} ) ;
2019-06-11 20:36:01 +02:00
2019-04-03 19:12:51 +02:00
const selectAllMyClaimsByOutpoint = reselect . createSelector ( selectMyClaimsRaw , claims => new Set ( claims && claims . length ? claims . map ( claim => ` ${ claim . txid } : ${ claim . nout } ` ) : null ) ) ;
const selectMyClaimsOutpoints = reselect . createSelector ( selectMyClaims , myClaims => {
const outpoints = [ ] ;
myClaims . forEach ( claim => outpoints . push ( ` ${ claim . txid } : ${ claim . nout } ` ) ) ;
return outpoints ;
} ) ;
2019-08-15 08:13:50 +02:00
const selectFetchingMyChannels = reselect . createSelector ( selectState$2 , state => state . fetchingMyChannels ) ;
2019-04-03 19:12:51 +02:00
2019-08-15 08:13:50 +02:00
const selectMyChannelClaims = reselect . createSelector ( selectState$2 , selectClaimsById , ( state , byId ) => {
2019-09-13 21:52:52 +02:00
const ids = state . myChannelClaims ;
if ( ! ids ) {
return ids ;
}
2019-04-03 19:12:51 +02:00
2019-09-13 21:52:52 +02:00
const claims = [ ] ;
2019-04-03 19:12:51 +02:00
ids . forEach ( id => {
if ( byId [ id ] ) {
// I'm not sure why this check is necessary, but it ought to be a quick fix for https://github.com/lbryio/lbry-desktop/issues/544
claims . push ( byId [ id ] ) ;
}
} ) ;
return claims ;
} ) ;
2020-06-17 03:56:51 +02:00
const selectMyChannelUrls = reselect . createSelector ( selectMyChannelClaims , claims => claims ? claims . map ( claim => claim . canonical _url || claim . permanent _url ) : undefined ) ;
2019-08-15 08:13:50 +02:00
const selectResolvingUris = reselect . createSelector ( selectState$2 , state => state . resolvingUris || [ ] ) ;
2019-04-03 19:12:51 +02:00
2019-09-12 21:06:49 +02:00
const selectChannelImportPending = reselect . createSelector ( selectState$2 , state => state . pendingChannelImport ) ;
2019-04-03 19:12:51 +02:00
const makeSelectIsUriResolving = uri => reselect . createSelector ( selectResolvingUris , resolvingUris => resolvingUris && resolvingUris . indexOf ( uri ) !== - 1 ) ;
2019-08-15 08:13:50 +02:00
const selectPlayingUri = reselect . createSelector ( selectState$2 , state => state . playingUri ) ;
2019-04-03 19:12:51 +02:00
2019-08-15 08:13:50 +02:00
const selectChannelClaimCounts = reselect . createSelector ( selectState$2 , state => state . channelClaimCounts || { } ) ;
2019-04-03 19:12:51 +02:00
const makeSelectTotalItemsForChannel = uri => reselect . createSelector ( selectChannelClaimCounts , byUri => byUri && byUri [ uri ] ) ;
const makeSelectTotalPagesForChannel = ( uri , pageSize = 10 ) => reselect . createSelector ( selectChannelClaimCounts , byUri => byUri && byUri [ uri ] && Math . ceil ( byUri [ uri ] / pageSize ) ) ;
const makeSelectNsfwCountFromUris = uris => reselect . createSelector ( selectClaimsByUri , claims => uris . reduce ( ( acc , uri ) => {
const claim = claims [ uri ] ;
2019-04-23 19:22:14 +02:00
if ( claim && isClaimNsfw ( claim ) ) {
2019-04-03 19:12:51 +02:00
return acc + 1 ;
}
return acc ;
} , 0 ) ) ;
const makeSelectNsfwCountForChannel = uri => reselect . createSelector ( selectClaimsById , selectAllClaimsByChannel , selectCurrentChannelPage , ( byId , allClaims , page ) => {
const byChannel = allClaims [ uri ] || { } ;
const claimIds = byChannel [ page || 1 ] ;
if ( ! claimIds ) return 0 ;
return claimIds . reduce ( ( acc , claimId ) => {
const claim = byId [ claimId ] ;
if ( isClaimNsfw ( claim ) ) {
return acc + 1 ;
}
return acc ;
} , 0 ) ;
} ) ;
2019-11-25 21:11:32 +01:00
const makeSelectOmittedCountForChannel = uri => reselect . createSelector ( makeSelectTotalItemsForChannel ( uri ) , makeSelectTotalClaimsInChannelSearch ( uri ) , ( claimsInChannel , claimsInSearch ) => {
2019-12-13 02:31:37 +01:00
if ( claimsInChannel && typeof claimsInSearch === 'number' && claimsInSearch >= 0 ) {
2019-11-25 21:11:32 +01:00
return claimsInChannel - claimsInSearch ;
} else return 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 ) ;
} ) ;
2020-01-29 20:20:59 +01:00
const makeSelectRecommendedContentForUri = uri => reselect . createSelector ( makeSelectClaimForUri ( uri ) , selectSearchUrisByQuery , makeSelectClaimIsNsfw ( uri ) , ( claim , searchUrisByQuery , isMature ) => {
2019-04-03 19:12:51 +02:00
const atVanityURI = ! uri . includes ( '#' ) ;
let recommendedContent ;
if ( claim ) {
2019-08-30 18:28:36 +02:00
// always grab full URL - this can change once search returns canonical
const currentUri = buildURI ( { streamClaimId : claim . claim _id , streamName : claim . name } ) ;
2019-04-03 19:12:51 +02:00
2019-04-23 19:22:14 +02:00
const { title } = claim . value ;
2019-04-03 19:12:51 +02:00
2019-12-18 23:20:08 +01:00
if ( ! title ) {
return ;
}
2020-01-30 07:30:27 +01:00
const options = { related _to : claim . claim _id , isBackgroundSearch : true } ;
2020-01-31 00:01:27 +01:00
2020-01-29 20:20:59 +01:00
if ( ! isMature ) {
options [ 'nsfw' ] = false ;
}
2020-01-30 07:30:27 +01:00
const searchQuery = getSearchQueryString ( title . replace ( /\// , ' ' ) , options ) ;
2019-04-03 19:12:51 +02:00
let searchUris = searchUrisByQuery [ searchQuery ] ;
if ( searchUris ) {
searchUris = searchUris . filter ( searchUri => searchUri !== currentUri ) ;
recommendedContent = searchUris ;
}
}
return recommendedContent ;
} ) ;
const makeSelectFirstRecommendedFileForUri = uri => reselect . createSelector ( makeSelectRecommendedContentForUri ( uri ) , recommendedContent => recommendedContent ? recommendedContent [ 0 ] : null ) ;
// Returns the associated channel uri for a given claim uri
2019-04-23 19:22:14 +02:00
// accepts a regular claim uri lbry://something
// returns the channel uri that created this claim lbry://@channel
2019-04-03 19:12:51 +02:00
const makeSelectChannelForClaimUri = ( uri , includePrefix = false ) => reselect . createSelector ( makeSelectClaimForUri ( uri ) , claim => {
2020-03-27 16:52:35 +01:00
if ( ! claim || ! claim . signing _channel || ! claim . is _channel _signature _valid ) {
2019-04-03 19:12:51 +02:00
return null ;
}
2020-03-26 21:17:19 +01:00
const { canonical _url : canonicalUrl , permanent _url : permanentUrl } = claim . signing _channel ;
if ( canonicalUrl ) {
return includePrefix ? canonicalUrl : canonicalUrl . slice ( 'lbry://' . length ) ;
} else {
return includePrefix ? permanentUrl : permanentUrl . slice ( 'lbry://' . length ) ;
}
2019-04-03 19:12:51 +02:00
} ) ;
2019-06-10 04:45:47 +02:00
const makeSelectTagsForUri = uri => reselect . createSelector ( makeSelectMetadataForUri ( uri ) , metadata => {
return metadata && metadata . tags || [ ] ;
} ) ;
2019-08-15 08:13:50 +02:00
const selectFetchingClaimSearchByQuery = reselect . createSelector ( selectState$2 , state => state . fetchingClaimSearchByQuery || { } ) ;
2019-06-11 20:11:18 +02:00
2019-07-31 21:14:51 +02:00
const selectFetchingClaimSearch = reselect . createSelector ( selectFetchingClaimSearchByQuery , fetchingClaimSearchByQuery => Boolean ( Object . keys ( fetchingClaimSearchByQuery ) . length ) ) ;
2019-06-11 20:11:18 +02:00
2019-08-15 08:13:50 +02:00
const selectClaimSearchByQuery = reselect . createSelector ( selectState$2 , state => state . claimSearchByQuery || { } ) ;
2019-07-08 20:28:14 +02:00
2019-08-16 16:54:38 +02:00
const selectClaimSearchByQueryLastPageReached = reselect . createSelector ( selectState$2 , state => state . claimSearchByQueryLastPageReached || { } ) ;
2019-08-13 17:27:32 +02:00
2019-07-30 17:48:45 +02:00
const makeSelectShortUrlForUri = uri => reselect . createSelector ( makeSelectClaimForUri ( uri ) , claim => claim && claim . short _url ) ;
2019-07-15 04:44:02 +02:00
2019-08-20 22:00:26 +02:00
const makeSelectCanonicalUrlForUri = uri => reselect . createSelector ( makeSelectClaimForUri ( uri ) , claim => claim && claim . canonical _url ) ;
2019-09-04 17:57:48 +02:00
const makeSelectPermanentUrlForUri = uri => reselect . createSelector ( makeSelectClaimForUri ( uri ) , claim => claim && claim . permanent _url ) ;
2019-08-15 08:13:50 +02:00
const makeSelectSupportsForUri = uri => reselect . createSelector ( selectSupportsByOutpoint , makeSelectClaimForUri ( uri ) , ( byOutpoint , claim ) => {
2020-05-08 22:47:33 +02:00
if ( ! claim || ! claim . is _my _output ) {
2019-08-15 08:13:50 +02:00
return null ;
}
2019-04-03 19:12:51 +02:00
2019-08-15 08:13:50 +02:00
const { claim _id : claimId } = claim ;
2019-08-20 22:00:26 +02:00
let total = 0 ;
2019-04-03 19:12:51 +02:00
2019-08-15 08:13:50 +02:00
Object . values ( byOutpoint ) . forEach ( support => {
2019-08-20 22:00:26 +02:00
// $FlowFixMe
2019-08-15 08:13:50 +02:00
const { claim _id , amount } = support ;
total = claim _id === claimId && amount ? total + parseFloat ( amount ) : total ;
2019-04-03 19:12:51 +02:00
} ) ;
2019-08-15 08:13:50 +02:00
return total ;
2019-04-03 19:12:51 +02:00
} ) ;
2019-09-15 13:00:14 +02:00
const selectUpdatingChannel = reselect . createSelector ( selectState$2 , state => state . updatingChannel ) ;
const selectUpdateChannelError = reselect . createSelector ( selectState$2 , state => state . updateChannelError ) ;
2020-05-26 23:11:27 +02:00
const makeSelectReflectingClaimForUri = uri => reselect . createSelector ( selectClaimIdsByUri , selectReflectingById , ( claimIdsByUri , reflectingById ) => {
const claimId = claimIdsByUri [ normalizeURI ( uri ) ] ;
2020-05-07 13:41:56 +02:00
return reflectingById [ claimId ] ;
} ) ;
2019-09-25 23:37:21 +02:00
const makeSelectMyStreamUrlsForPage = ( page = 1 ) => reselect . createSelector ( selectMyClaimUrisWithoutChannels , urls => {
2019-09-25 23:16:27 +02:00
const start = ( Number ( page ) - 1 ) * Number ( PAGE _SIZE ) ;
const end = Number ( page ) * Number ( PAGE _SIZE ) ;
2020-04-01 16:37:50 +02:00
2019-09-25 23:37:21 +02:00
return urls && urls . length ? urls . slice ( start , end ) : [ ] ;
2019-09-23 19:00:12 +02:00
} ) ;
2019-09-25 23:37:21 +02:00
const selectMyStreamUrlsCount = reselect . createSelector ( selectMyClaimUrisWithoutChannels , channels => channels . length ) ;
2019-09-23 19:00:12 +02:00
2020-03-17 21:54:34 +01:00
const makeSelectResolvedRecommendedContentForUri = ( uri , size , claimId , claimName , claimTitle ) => reselect . createSelector ( makeSelectClaimForUri ( uri ) , selectResolvedSearchResultsByQuery , makeSelectClaimIsNsfw ( uri ) , ( claim , resolvedResultsByQuery , isMature ) => {
2020-01-22 02:04:50 +01:00
const atVanityURI = ! uri . includes ( '#' ) ;
2020-03-17 21:54:34 +01:00
let currentUri ;
2020-01-22 02:04:50 +01:00
let recommendedContent ;
2020-03-17 21:54:34 +01:00
let title ;
2020-01-22 02:04:50 +01:00
if ( claim ) {
// always grab full URL - this can change once search returns canonical
2020-03-17 21:54:34 +01:00
currentUri = buildURI ( { streamClaimId : claim . claim _id , streamName : claim . name } ) ;
title = claim . value ? claim . value . title : null ;
} else {
// for cases on mobile where the claim may not have been resolved ()
currentUri = buildURI ( { streamClaimId : claimId , streamName : claimName } ) ;
title = claimTitle ;
}
2020-01-22 02:04:50 +01:00
2020-03-17 21:54:34 +01:00
if ( ! title ) {
return ;
}
2020-01-22 02:04:50 +01:00
2020-03-17 21:54:34 +01:00
const options = { related _to : claim ? claim . claim _id : claimId , size , isBackgroundSearch : false } ;
2020-01-30 07:30:27 +01:00
2020-03-17 21:54:34 +01:00
const searchQuery = getSearchQueryString ( title . replace ( /\// , ' ' ) , options ) ;
let results = resolvedResultsByQuery [ searchQuery ] ;
if ( results ) {
results = results . filter ( result => buildURI ( { streamClaimId : result . claimId , streamName : result . name } ) !== currentUri ) ;
recommendedContent = results ;
2020-01-22 02:04:50 +01:00
}
return recommendedContent ;
} ) ;
2019-10-16 16:05:31 +02:00
function numberWithCommas ( x ) {
var parts = x . toString ( ) . split ( '.' ) ;
parts [ 0 ] = parts [ 0 ] . replace ( /\B(?=(\d{3})+(?!\d))/g , ',' ) ;
return parts . join ( '.' ) ;
}
2019-08-16 16:54:38 +02:00
function formatCredits ( amount , precision , shortFormat = false ) {
2019-10-02 06:10:19 +02:00
let actualAmount = parseFloat ( amount ) ;
let actualPrecision = parseFloat ( precision ) ;
let suffix = '' ;
2019-10-16 16:05:31 +02:00
if ( Number . isNaN ( actualAmount ) || actualAmount === 0 ) return '0' ;
2019-08-16 16:54:38 +02:00
2019-10-02 06:10:19 +02:00
if ( actualAmount >= 1000000 ) {
if ( precision <= 7 ) {
if ( shortFormat ) {
actualAmount = actualAmount / 1000000 ;
suffix = 'M' ;
} else {
actualPrecision -= 7 ;
}
}
} else if ( actualAmount >= 1000 ) {
if ( precision <= 4 ) {
if ( shortFormat ) {
actualAmount = actualAmount / 1000 ;
suffix = 'K' ;
} else {
actualPrecision -= 4 ;
}
2019-08-16 16:54:38 +02:00
}
}
2019-10-16 16:05:31 +02:00
return numberWithCommas ( actualAmount . toFixed ( actualPrecision >= 0 ? actualPrecision : 1 ) . replace ( /\.*0+$/ , '' ) ) + suffix ;
2019-07-29 20:48:44 +02:00
}
function formatFullPrice ( amount , precision = 1 ) {
let formated = '' ;
const quantity = amount . toString ( ) . split ( '.' ) ;
const fraction = quantity [ 1 ] ;
if ( fraction ) {
const decimals = fraction . split ( '' ) ;
const first = decimals . filter ( number => number !== '0' ) [ 0 ] ;
const index = decimals . indexOf ( first ) ;
// Set format fraction
formated = ` . ${ fraction . substring ( 0 , index + precision ) } ` ;
}
return parseFloat ( quantity [ 0 ] + formated ) ;
}
function creditsToString ( amount ) {
const creditString = parseFloat ( amount ) . toFixed ( 8 ) ;
return creditString ;
}
2020-06-11 00:06:12 +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-11-01 20:08:42 +01:00
let walletBalancePromise = null ;
2019-04-03 19:12:51 +02:00
function doUpdateBalance ( ) {
return ( dispatch , getState ) => {
const {
2019-09-25 07:37:02 +02:00
wallet : { totalBalance : totalInStore }
2019-04-03 19:12:51 +02:00
} = getState ( ) ;
2019-10-03 05:36:45 +02:00
2019-11-01 20:08:42 +01:00
if ( walletBalancePromise === null ) {
2019-11-05 19:24:41 +01:00
walletBalancePromise = lbryProxy . wallet _balance ( ) . then ( response => {
2019-11-01 20:08:42 +01:00
walletBalancePromise = null ;
const { available , reserved , reserved _subtotals , total } = response ;
const { claims , supports , tips } = reserved _subtotals ;
const totalFloat = parseFloat ( total ) ;
if ( totalInStore !== totalFloat ) {
dispatch ( {
type : UPDATE _BALANCE ,
data : {
totalBalance : totalFloat ,
balance : parseFloat ( available ) ,
reservedBalance : parseFloat ( reserved ) ,
claimsBalance : parseFloat ( claims ) ,
supportsBalance : parseFloat ( supports ) ,
tipsBalance : parseFloat ( tips )
}
} ) ;
}
2019-12-20 17:40:29 +01:00
} ) . catch ( ( ) => {
walletBalancePromise = null ;
2019-11-01 20:08:42 +01:00
} ) ;
}
return walletBalancePromise ;
2019-04-18 09:56:16 +02:00
} ;
}
2019-04-03 19:12:51 +02:00
function doBalanceSubscribe ( ) {
return dispatch => {
dispatch ( doUpdateBalance ( ) ) ;
setInterval ( ( ) => dispatch ( doUpdateBalance ( ) ) , 5000 ) ;
} ;
}
2019-11-01 20:08:42 +01:00
function doFetchTransactions ( page = 1 , pageSize = 99999 ) {
2019-04-03 19:12:51 +02:00
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
} ) ;
2019-11-01 20:08:42 +01:00
lbryProxy . utxo _release ( ) . then ( ( ) => lbryProxy . transaction _list ( { page , page _size : pageSize } ) ) . then ( result => {
2019-04-03 19:12:51 +02:00
dispatch ( {
type : FETCH _TRANSACTIONS _COMPLETED ,
data : {
2019-11-01 20:08:42 +01:00
transactions : result . items
2019-04-03 19:12:51 +02:00
}
} ) ;
} ) ;
} ;
}
2020-04-10 14:16:27 +02:00
function doFetchTxoPage ( ) {
return ( dispatch , getState ) => {
dispatch ( {
type : FETCH _TXO _PAGE _STARTED
} ) ;
const state = getState ( ) ;
const queryParams = selectTxoPageParams ( state ) ;
2020-04-20 20:22:15 +02:00
lbryProxy . utxo _release ( ) . then ( ( ) => lbryProxy . txo _list ( queryParams ) ) . then ( res => {
2020-04-10 14:16:27 +02:00
dispatch ( {
type : FETCH _TXO _PAGE _COMPLETED ,
data : res
} ) ;
} ) . catch ( e => {
dispatch ( {
type : FETCH _TXO _PAGE _COMPLETED ,
data : e . message
} ) ;
} ) ;
} ;
}
function doUpdateTxoPageParams ( params ) {
return dispatch => {
dispatch ( {
type : UPDATE _TXO _FETCH _PARAMS ,
data : params
} ) ;
dispatch ( doFetchTxoPage ( ) ) ;
} ;
}
2019-11-05 19:24:41 +01:00
function doFetchSupports ( page = 1 , pageSize = 99999 ) {
2019-05-10 07:02:03 +02:00
return dispatch => {
dispatch ( {
type : FETCH _SUPPORTS _STARTED
} ) ;
2019-11-05 19:24:41 +01:00
lbryProxy . support _list ( { page , page _size : pageSize } ) . then ( result => {
2019-05-10 07:02:03 +02:00
dispatch ( {
type : FETCH _SUPPORTS _COMPLETED ,
data : {
2019-11-05 19:24:41 +01:00
supports : result . items
2019-05-10 07:02:03 +02:00
}
} ) ;
} ) ;
} ;
}
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 ( {
2020-06-17 03:56:51 +02:00
title : _ _ ( 'Insufficient credits' ) ,
message : _ _ ( 'Insufficient credits' )
2019-04-03 19:12:51 +02:00
} ) ) ;
return ;
}
dispatch ( {
type : SEND _TRANSACTION _STARTED
} ) ;
const successCallback = response => {
if ( response . txid ) {
dispatch ( {
type : SEND _TRANSACTION _COMPLETED
} ) ;
dispatch ( doToast ( {
2020-06-29 23:02:39 +02:00
message : _ _ ( ` You sent ${ amount } LBC ` ) ,
2020-06-17 03:56:51 +02:00
linkText : _ _ ( 'History' ) ,
2019-04-03 19:12:51 +02:00
linkTarget : '/wallet'
} ) ) ;
} else {
dispatch ( {
type : SEND _TRANSACTION _FAILED ,
data : { error : response }
} ) ;
dispatch ( doToast ( {
2020-06-17 03:56:51 +02:00
message : _ _ ( 'Transaction failed' ) ,
2019-04-03 19:12:51 +02:00
isError : true
} ) ) ;
}
} ;
const errorCallback = error => {
dispatch ( {
type : SEND _TRANSACTION _FAILED ,
data : { error : error . message }
} ) ;
dispatch ( doToast ( {
2020-06-17 03:56:51 +02:00
message : _ _ ( 'Transaction failed' ) ,
2019-04-03 19:12:51 +02:00
isError : true
} ) ) ;
} ;
2019-10-15 05:35:38 +02:00
lbryProxy . wallet _send ( {
2019-04-23 19:22:14 +02:00
addresses : [ address ] ,
2019-07-29 20:48:44 +02:00
amount : creditsToString ( amount )
2019-04-03 19:12:51 +02:00
} ) . then ( successCallback , errorCallback ) ;
} ;
}
function doSetDraftTransactionAmount ( amount ) {
return {
type : SET _DRAFT _TRANSACTION _AMOUNT ,
data : { amount }
} ;
}
function doSetDraftTransactionAddress ( address ) {
return {
type : SET _DRAFT _TRANSACTION _ADDRESS ,
data : { address }
} ;
}
2020-06-11 00:06:12 +02:00
function doSendTip ( params , isSupport , successCallback , errorCallback ) {
2019-04-03 19:12:51 +02:00
return ( dispatch , getState ) => {
const state = getState ( ) ;
const balance = selectBalance ( state ) ;
2019-07-19 21:20:24 +02:00
const myClaims = selectMyClaimsRaw ( state ) ;
2020-06-11 00:06:12 +02:00
const shouldSupport = isSupport || ( myClaims ? myClaims . find ( claim => claim . claim _id === params . claim _id ) : false ) ;
2019-04-03 19:12:51 +02:00
2020-06-11 00:06:12 +02:00
if ( balance - params . amount <= 0 ) {
2019-04-03 19:12:51 +02:00
dispatch ( doToast ( {
2019-12-18 15:14:24 +01:00
message : _ _ ( 'Insufficient credits' ) ,
2019-04-03 19:12:51 +02:00
isError : true
} ) ) ;
return ;
}
const success = ( ) => {
dispatch ( doToast ( {
2020-06-11 00:06:12 +02:00
message : shouldSupport ? _ _ ( 'You deposited %amount% LBC as a support!' , { amount : params . amount } ) : _ _ ( 'You sent %amount% LBC as a tip, Mahalo!' , { amount : params . amount } ) ,
2019-04-03 19:12:51 +02:00
linkText : _ _ ( 'History' ) ,
2020-06-17 03:56:51 +02:00
linkTarget : '/wallet'
2019-04-03 19:12:51 +02:00
} ) ) ;
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
} ) ;
2020-06-11 00:06:12 +02:00
lbryProxy . support _create ( _extends$5 ( { } , params , {
2019-10-02 01:00:59 +02:00
tip : ! shouldSupport ,
2020-06-11 00:06:12 +02:00
blocking : true ,
amount : creditsToString ( params . amount )
} ) ) . then ( success , error ) ;
2019-04-03 19:12:51 +02:00
} ;
}
2019-10-30 08:55:15 +01:00
function doClearSupport ( ) {
return {
type : CLEAR _SUPPORT _TRANSACTION
} ;
}
2019-04-03 19:12:51 +02:00
function doWalletEncrypt ( newPassword ) {
return dispatch => {
dispatch ( {
type : WALLET _ENCRYPT _START
} ) ;
2019-10-16 00:11:03 +02:00
lbryProxy . wallet _encrypt ( { new _password : newPassword } ) . then ( result => {
2019-04-03 19:12:51 +02:00
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
} ) ;
2019-10-16 00:11:03 +02:00
lbryProxy . wallet _unlock ( { password } ) . then ( result => {
2019-04-03 19:12:51 +02:00
if ( result === true ) {
dispatch ( {
type : WALLET _UNLOCK _COMPLETED ,
result
} ) ;
} else {
dispatch ( {
type : WALLET _UNLOCK _FAILED ,
result
} ) ;
}
} ) ;
} ;
}
2020-03-25 03:46:35 +01:00
function doSupportAbandonForClaim ( claimId , claimType , keep , preview ) {
return dispatch => {
2020-04-01 20:36:11 +02:00
if ( preview ) {
dispatch ( {
type : ABANDON _CLAIM _SUPPORT _PREVIEW
} ) ;
} else {
dispatch ( {
type : ABANDON _CLAIM _SUPPORT _STARTED
} ) ;
}
2020-04-01 20:26:38 +02:00
2020-03-25 03:46:35 +01:00
const params = { claim _id : claimId } ;
if ( preview ) params [ 'preview' ] = true ;
if ( keep ) params [ 'keep' ] = keep ;
return lbryProxy . support _abandon ( params ) . then ( res => {
if ( ! preview ) {
dispatch ( {
type : ABANDON _CLAIM _SUPPORT _COMPLETED ,
data : { claimId , txid : res . txid , effective : res . outputs [ 0 ] . amount , type : claimType } // add to pendingSupportTransactions,
} ) ;
dispatch ( doCheckPendingTxs ( ) ) ;
}
return res ;
} ) . catch ( e => {
dispatch ( {
type : ABANDON _CLAIM _SUPPORT _FAILED ,
data : e . message
} ) ;
} ) ;
} ;
}
2019-12-11 20:27:52 +01:00
function doWalletReconnect ( ) {
2019-12-11 15:45:18 +01:00
return dispatch => {
dispatch ( {
type : WALLET _RESTART
} ) ;
// this basically returns null when it's done. :(
// might be good to dispatch ACTIONS.WALLET_RESTARTED
2019-12-12 17:47:09 +01:00
lbryProxy . wallet _reconnect ( ) . then ( ( ) => dispatch ( {
2019-12-11 20:27:52 +01:00
type : WALLET _RESTART _COMPLETED
} ) ) ;
2019-12-11 15:45:18 +01:00
} ;
}
2019-04-03 19:12:51 +02:00
function doWalletDecrypt ( ) {
return dispatch => {
dispatch ( {
type : WALLET _DECRYPT _START
} ) ;
2019-10-16 00:11:03 +02:00
lbryProxy . wallet _decrypt ( ) . then ( result => {
2019-04-03 19:12:51 +02:00
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
} ) ;
2019-10-17 17:36:39 +02:00
lbryProxy . wallet _status ( ) . then ( status => {
if ( status ) {
2019-04-03 19:12:51 +02:00
dispatch ( {
type : WALLET _STATUS _COMPLETED ,
2019-10-17 17:36:39 +02:00
result : status . is _encrypted
2019-04-03 19:12:51 +02:00
} ) ;
}
} ) ;
} ;
}
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
} ) ;
}
} ) ;
}
2020-03-25 03:46:35 +01:00
// Calls transaction_show on txes until any pending txes are confirmed
const doCheckPendingTxs = ( ) => ( dispatch , getState ) => {
const state = getState ( ) ;
const pendingTxsById = selectPendingSupportTransactions ( state ) ; // {}
if ( ! Object . keys ( pendingTxsById ) . length ) {
return ;
}
let txCheckInterval ;
const checkTxList = ( ) => {
const state = getState ( ) ;
const pendingTxs = selectPendingSupportTransactions ( state ) ; // {}
const promises = [ ] ;
const newPendingTxes = { } ;
const types = new Set ( [ ] ) ;
let changed = false ;
Object . entries ( pendingTxs ) . forEach ( ( [ claim , data ] ) => {
promises . push ( lbryProxy . transaction _show ( { txid : data . txid } ) ) ;
types . add ( data . type ) ;
} ) ;
Promise . all ( promises ) . then ( txShows => {
txShows . forEach ( result => {
if ( result . height <= 0 ) {
const entries = Object . entries ( pendingTxs ) ;
const match = entries . find ( entry => entry [ 1 ] . txid === result . txid ) ;
newPendingTxes [ match [ 0 ] ] = match [ 1 ] ;
} else {
changed = true ;
}
} ) ;
} ) . then ( ( ) => {
if ( changed ) {
dispatch ( {
type : PENDING _SUPPORTS _UPDATED ,
data : newPendingTxes
} ) ;
if ( types . has ( 'channel' ) ) {
dispatch ( doFetchChannelListMine ( ) ) ;
}
if ( types . has ( 'stream' ) ) {
dispatch ( doFetchClaimListMine ( ) ) ;
}
}
if ( Object . keys ( newPendingTxes ) . length === 0 ) clearInterval ( txCheckInterval ) ;
} ) ;
if ( ! Object . keys ( pendingTxsById ) . length ) {
clearInterval ( txCheckInterval ) ;
}
} ;
txCheckInterval = setInterval ( ( ) => {
checkTxList ( ) ;
} , 30000 ) ;
} ;
2019-07-29 20:48:44 +02:00
// https://github.com/reactjs/redux/issues/911
function batchActions ( ... actions ) {
return {
type : 'BATCH_ACTIONS' ,
actions
} ;
}
2020-06-11 00:06:12 +02:00
var _extends$6 = Object . assign || function ( target ) { for ( var i = 1 ; i < arguments . length ; i ++ ) { var source = arguments [ i ] ; for ( var key in source ) { if ( Object . prototype . hasOwnProperty . call ( source , key ) ) { target [ key ] = source [ key ] ; } } } return target ; } ;
2019-04-23 19:22:14 +02:00
2020-03-18 18:11:03 +01:00
function doResolveUris ( uris , returnCachedClaims = false ) {
2019-04-03 19:12:51 +02:00
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 ;
}
2020-05-08 22:47:33 +02:00
const options = {
include _purchase _receipt : true
} ;
2020-04-25 22:31:53 +02:00
if ( urisToResolve . length === 1 ) {
options . include _is _my _output = true ;
}
2019-04-03 19:12:51 +02:00
dispatch ( {
type : RESOLVE _URIS _STARTED ,
data : { uris : normalizedUris }
} ) ;
const resolveInfo = { } ;
2019-04-23 19:22:14 +02:00
2020-06-11 00:06:12 +02:00
return lbryProxy . resolve ( _extends$6 ( { urls : urisToResolve } , options ) ) . then ( result => {
2019-04-03 19:12:51 +02:00
Object . entries ( result ) . forEach ( ( [ uri , uriResolveInfo ] ) => {
const fallbackResolveInfo = {
2019-06-06 23:37:36 +02:00
stream : null ,
2019-04-03 19:12:51 +02:00
claimsInChannel : null ,
2019-06-06 23:37:36 +02:00
channel : null
2019-04-03 19:12:51 +02:00
} ;
2019-04-23 19:22:14 +02:00
// Flow has terrible Object.entries support
// https://github.com/facebook/flow/issues/2221
2019-06-04 18:06:19 +02:00
if ( uriResolveInfo ) {
if ( uriResolveInfo . error ) {
2020-06-11 00:06:12 +02:00
resolveInfo [ uri ] = _extends$6 ( { } , fallbackResolveInfo ) ;
2019-06-04 18:06:19 +02:00
} else {
let result = { } ;
if ( uriResolveInfo . value _type === 'channel' ) {
2019-06-06 23:37:36 +02:00
result . channel = uriResolveInfo ;
2019-06-04 18:06:19 +02:00
// $FlowFixMe
result . claimsInChannel = uriResolveInfo . meta . claims _in _channel ;
} else {
2019-06-06 23:37:36 +02:00
result . stream = uriResolveInfo ;
if ( uriResolveInfo . signing _channel ) {
result . channel = uriResolveInfo . signing _channel ;
2019-06-11 18:22:44 +02:00
result . claimsInChannel = uriResolveInfo . signing _channel . meta && uriResolveInfo . signing _channel . meta . claims _in _channel || 0 ;
2019-06-06 23:37:36 +02:00
}
2019-06-04 18:06:19 +02:00
}
// $FlowFixMe
resolveInfo [ uri ] = result ;
}
2019-04-23 19:22:14 +02:00
}
2019-04-03 19:12:51 +02:00
} ) ;
dispatch ( {
type : RESOLVE _URIS _COMPLETED ,
data : { resolveInfo }
} ) ;
2020-04-25 22:31:53 +02:00
return result ;
2019-04-03 19:12:51 +02:00
} ) ;
} ;
}
2020-03-18 18:11:03 +01:00
function doResolveUri ( uri ) {
return doResolveUris ( [ uri ] ) ;
2019-04-03 19:12:51 +02:00
}
2020-02-12 22:45:30 +01:00
function doFetchClaimListMine ( page = 1 , pageSize = 99999 , resolve = true ) {
2019-04-03 19:12:51 +02:00
return dispatch => {
dispatch ( {
type : FETCH _CLAIM _LIST _MINE _STARTED
} ) ;
2020-03-09 15:29:13 +01:00
// $FlowFixMe
2020-04-25 22:31:53 +02:00
lbryProxy . claim _list ( {
page : page ,
page _size : pageSize ,
claim _type : [ 'stream' , 'repost' ] ,
resolve
} ) . then ( result => {
2019-04-03 19:12:51 +02:00
dispatch ( {
type : FETCH _CLAIM _LIST _MINE _COMPLETED ,
data : {
2020-04-25 22:31:53 +02:00
result ,
resolve
2019-04-03 19:12:51 +02:00
}
} ) ;
} ) ;
} ;
}
2020-04-10 14:16:27 +02:00
function doAbandonTxo ( txo , cb ) {
return dispatch => {
2020-04-14 22:26:15 +02:00
if ( cb ) cb ( PENDING ) ;
2020-04-10 14:16:27 +02:00
const isClaim = txo . type === 'claim' ;
const isSupport = txo . type === 'support' && txo . is _my _input === true ;
const isTip = txo . type === 'support' && txo . is _my _input === false ;
const data = isClaim ? { claimId : txo . claim _id } : { outpoint : ` ${ txo . txid } : ${ txo . nout } ` } ;
const startedActionType = isClaim ? ABANDON _CLAIM _STARTED : ABANDON _SUPPORT _STARTED ;
const completedActionType = isClaim ? ABANDON _CLAIM _SUCCEEDED : ABANDON _SUPPORT _COMPLETED ;
dispatch ( {
type : startedActionType ,
data
} ) ;
const errorCallback = ( ) => {
2020-04-14 22:26:15 +02:00
if ( cb ) cb ( ERROR ) ;
2020-04-10 14:16:27 +02:00
dispatch ( doToast ( {
message : isClaim ? 'Error abandoning your claim/support' : 'Error unlocking your tip' ,
isError : true
} ) ) ;
} ;
const successCallback = ( ) => {
dispatch ( {
type : completedActionType ,
data
} ) ;
let abandonMessage ;
if ( isClaim ) {
2020-04-15 16:15:52 +02:00
abandonMessage = _ _ ( 'Successfully abandoned your claim.' ) ;
2020-04-10 14:16:27 +02:00
} else if ( isSupport ) {
2020-04-15 16:15:52 +02:00
abandonMessage = _ _ ( 'Successfully abandoned your support.' ) ;
2020-04-10 14:16:27 +02:00
} else {
2020-04-15 16:15:52 +02:00
abandonMessage = _ _ ( 'Successfully unlocked your tip!' ) ;
2020-04-10 14:16:27 +02:00
}
2020-04-14 22:26:15 +02:00
if ( cb ) cb ( DONE ) ;
2020-04-10 14:16:27 +02:00
dispatch ( doToast ( {
message : abandonMessage
} ) ) ;
} ;
const abandonParams = {
blocking : true
} ;
if ( isClaim ) {
abandonParams [ 'claim_id' ] = txo . claim _id ;
} else {
abandonParams [ 'txid' ] = txo . txid ;
abandonParams [ 'nout' ] = txo . nout ;
}
let method ;
if ( isSupport || isTip ) {
method = 'support_abandon' ;
} else if ( isClaim ) {
const { normalized _name : claimName } = txo ;
method = claimName . startsWith ( '@' ) ? 'channel_abandon' : 'stream_abandon' ;
}
if ( ! method ) {
console . error ( 'No "method" chosen for claim or support abandon' ) ;
return ;
}
lbryProxy [ method ] ( abandonParams ) . then ( successCallback , errorCallback ) ;
} ;
}
2020-04-25 22:31:53 +02:00
function doAbandonClaim ( txid , nout , cb ) {
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 ;
2019-10-16 19:32:50 +02:00
const completedActionType = isClaim ? ABANDON _CLAIM _SUCCEEDED : ABANDON _SUPPORT _COMPLETED ;
2019-04-03 19:12:51 +02:00
dispatch ( {
2019-05-10 07:02:03 +02:00
type : startedActionType ,
data
2019-04-03 19:12:51 +02:00
} ) ;
const errorCallback = ( ) => {
dispatch ( doToast ( {
2019-07-19 21:20:24 +02:00
message : isClaim ? 'Error abandoning your claim/support' : 'Error unlocking your tip' ,
2019-04-03 19:12:51 +02:00
isError : true
} ) ) ;
2020-04-25 22:31:53 +02:00
if ( cb ) cb ( ERROR ) ;
2019-04-03 19:12:51 +02:00
} ;
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
} ) ;
2020-04-25 22:31:53 +02:00
if ( cb ) cb ( DONE ) ;
2019-04-03 19:12:51 +02:00
2019-07-19 21:20:24 +02:00
let abandonMessage ;
if ( isClaim ) {
2020-04-15 16:15:52 +02:00
abandonMessage = _ _ ( 'Successfully abandoned your claim.' ) ;
2019-07-19 21:20:24 +02:00
} else if ( supportToAbandon ) {
2020-04-15 16:15:52 +02:00
abandonMessage = _ _ ( 'Successfully abandoned your support.' ) ;
2019-07-19 21:20:24 +02:00
} else {
2020-04-15 16:15:52 +02:00
abandonMessage = _ _ ( 'Successfully unlocked your tip!' ) ;
2019-07-19 21:20:24 +02:00
}
2019-04-23 19:22:14 +02:00
dispatch ( doToast ( {
2019-07-19 21:20:24 +02:00
message : abandonMessage
2019-04-23 19:22:14 +02:00
} ) ) ;
2020-04-10 14:16:27 +02:00
dispatch ( doFetchTxoPage ( ) ) ;
2019-04-03 19:12:51 +02:00
} ;
2019-04-23 19:22:14 +02:00
const abandonParams = {
2019-04-03 19:12:51 +02:00
txid ,
2019-04-23 19:22:14 +02:00
nout ,
blocking : true
} ;
2019-05-10 07:02:03 +02:00
let method ;
if ( supportToAbandon ) {
method = 'support_abandon' ;
} else if ( claimToAbandon ) {
const { name : claimName } = claimToAbandon ;
method = claimName . startsWith ( '@' ) ? 'channel_abandon' : 'stream_abandon' ;
}
if ( ! method ) {
console . error ( 'No "method" chosen for claim or support abandon' ) ;
return ;
}
2019-04-23 19:22:14 +02:00
lbryProxy [ method ] ( abandonParams ) . then ( successCallback , errorCallback ) ;
2019-04-03 19:12:51 +02:00
} ;
}
2019-04-23 19:22:14 +02:00
function doFetchClaimsByChannel ( uri , page = 1 ) {
2019-04-03 19:12:51 +02:00
return dispatch => {
dispatch ( {
type : FETCH _CHANNEL _CLAIMS _STARTED ,
data : { uri , page }
} ) ;
2019-06-11 18:22:44 +02:00
lbryProxy . claim _search ( {
channel : uri ,
2019-06-25 08:37:31 +02:00
valid _channel _signature : true ,
2019-06-11 18:22:44 +02:00
page : page || 1 ,
2020-04-25 22:31:53 +02:00
order _by : [ 'release_time' ] ,
2020-05-08 22:47:33 +02:00
include _is _my _output : true ,
include _purchase _receipt : true
2019-06-11 18:22:44 +02:00
} ) . then ( result => {
2019-11-19 21:29:32 +01:00
const { items : claims , total _items : claimsInChannel , page : returnedPage } = result ;
2019-04-03 19:12:51 +02:00
dispatch ( {
type : FETCH _CHANNEL _CLAIMS _COMPLETED ,
data : {
uri ,
2019-11-19 21:29:32 +01:00
claimsInChannel ,
claims : claims || [ ] ,
2019-04-03 19:12:51 +02:00
page : returnedPage || undefined
}
} ) ;
} ) ;
} ;
}
2020-06-17 03:56:51 +02:00
function doCreateChannel ( name , amount , optionalParams , cb ) {
2019-04-03 19:12:51 +02:00
return dispatch => {
dispatch ( {
2019-04-23 19:22:14 +02:00
type : CREATE _CHANNEL _STARTED
2019-04-03 19:12:51 +02:00
} ) ;
2019-09-15 13:00:14 +02:00
const createParams = {
2019-04-23 19:22:14 +02:00
name ,
2019-10-02 01:00:59 +02:00
bid : creditsToString ( amount ) ,
blocking : true
2019-09-15 13:00:14 +02:00
} ;
if ( optionalParams ) {
if ( optionalParams . title ) {
createParams . title = optionalParams . title ;
}
if ( optionalParams . coverUrl ) {
createParams . cover _url = optionalParams . coverUrl ;
}
if ( optionalParams . thumbnailUrl ) {
createParams . thumbnail _url = optionalParams . thumbnailUrl ;
}
if ( optionalParams . description ) {
createParams . description = optionalParams . description ;
}
if ( optionalParams . website ) {
createParams . website _url = optionalParams . website ;
}
if ( optionalParams . email ) {
createParams . email = optionalParams . email ;
}
if ( optionalParams . tags ) {
createParams . tags = optionalParams . tags . map ( tag => tag . name ) ;
}
}
return lbryProxy . channel _create ( createParams )
2019-04-23 19:22:14 +02:00
// outputs[0] is the certificate
// outputs[1] is the change from the tx, not in the app currently
. then ( result => {
const channelClaim = result . outputs [ 0 ] ;
2019-04-03 19:12:51 +02:00
dispatch ( {
2019-04-23 19:22:14 +02:00
type : CREATE _CHANNEL _COMPLETED ,
data : { channelClaim }
} ) ;
2020-06-17 03:56:51 +02:00
dispatch ( {
type : UPDATE _PENDING _CLAIMS ,
data : {
claims : [ channelClaim ]
}
} ) ;
dispatch ( doCheckPendingClaims ( cb ) ) ;
2019-10-12 19:11:23 +02:00
return channelClaim ;
2019-04-23 19:22:14 +02:00
} ) . catch ( error => {
dispatch ( {
type : CREATE _CHANNEL _FAILED ,
2019-09-13 21:52:52 +02:00
data : error . message
2019-04-03 19:12:51 +02:00
} ) ;
2019-10-12 19:11:23 +02:00
return error ;
2019-04-03 19:12:51 +02:00
} ) ;
} ;
}
2020-06-17 03:56:51 +02:00
function doUpdateChannel ( params , cb ) {
2019-10-02 01:00:59 +02:00
return ( dispatch , getState ) => {
2019-07-01 03:16:44 +02:00
dispatch ( {
type : UPDATE _CHANNEL _STARTED
} ) ;
2019-10-02 01:00:59 +02:00
const state = getState ( ) ;
const myChannels = selectMyChannelClaims ( state ) ;
const channelClaim = myChannels . find ( myChannel => myChannel . claim _id === params . claim _id ) ;
2019-07-01 03:16:44 +02:00
const updateParams = {
claim _id : params . claim _id ,
2019-07-29 20:48:44 +02:00
bid : creditsToString ( params . amount ) ,
2019-07-01 03:16:44 +02:00
title : params . title ,
2019-09-15 13:00:14 +02:00
cover _url : params . coverUrl ,
thumbnail _url : params . thumbnailUrl ,
2019-07-01 03:16:44 +02:00
description : params . description ,
website _url : params . website ,
email : params . email ,
2019-10-02 01:00:59 +02:00
tags : [ ] ,
2019-07-18 16:27:35 +02:00
replace : true ,
2019-10-02 01:00:59 +02:00
languages : [ ] ,
locations : [ ] ,
blocking : true
2019-07-01 03:16:44 +02:00
} ;
2019-07-18 16:27:35 +02:00
if ( params . tags ) {
updateParams . tags = params . tags . map ( tag => tag . name ) ;
}
2019-10-11 18:42:06 +02:00
// we'll need to remove these once we add locations/channels to channel page edit/create options
2019-10-02 01:00:59 +02:00
if ( channelClaim && channelClaim . value && channelClaim . value . locations ) {
updateParams . locations = channelClaim . value . locations ;
}
if ( channelClaim && channelClaim . value && channelClaim . value . languages ) {
updateParams . languages = channelClaim . value . languages ;
}
2019-07-18 16:27:35 +02:00
2019-07-01 03:16:44 +02:00
return lbryProxy . channel _update ( updateParams ) . then ( result => {
const channelClaim = result . outputs [ 0 ] ;
dispatch ( {
type : UPDATE _CHANNEL _COMPLETED ,
data : { channelClaim }
} ) ;
2020-06-17 03:56:51 +02:00
dispatch ( {
type : UPDATE _PENDING _CLAIMS ,
data : {
claims : [ channelClaim ]
}
} ) ;
dispatch ( doCheckPendingClaims ( cb ) ) ;
return Boolean ( result . outputs [ 0 ] ) ;
} ) . then ( ) . catch ( error => {
2019-07-01 03:16:44 +02:00
dispatch ( {
type : UPDATE _CHANNEL _FAILED ,
data : error
} ) ;
} ) ;
} ;
}
2019-09-23 17:06:02 +02:00
function doImportChannel ( certificate ) {
2019-09-12 21:06:49 +02:00
return dispatch => {
dispatch ( {
2019-09-23 17:06:02 +02:00
type : IMPORT _CHANNEL _STARTED
2019-09-12 21:06:49 +02:00
} ) ;
return lbryProxy . channel _import ( { channel _data : certificate } ) . then ( result => {
dispatch ( {
2019-09-23 17:06:02 +02:00
type : IMPORT _CHANNEL _COMPLETED
2019-09-12 21:06:49 +02:00
} ) ;
} ) . catch ( error => {
dispatch ( {
type : IMPORT _CHANNEL _FAILED ,
data : error
} ) ;
} ) ;
} ;
}
2020-02-12 22:45:30 +01:00
function doFetchChannelListMine ( page = 1 , pageSize = 99999 , resolve = true ) {
2019-04-23 19:22:14 +02:00
return dispatch => {
dispatch ( {
type : FETCH _CHANNEL _LIST _STARTED
} ) ;
2019-11-05 19:52:17 +01:00
const callback = response => {
2019-04-23 19:22:14 +02:00
dispatch ( {
type : FETCH _CHANNEL _LIST _COMPLETED ,
2020-02-13 17:37:36 +01:00
data : { claims : response . items }
2019-04-23 19:22:14 +02:00
} ) ;
} ;
2020-06-01 20:26:07 +02:00
const failure = error => {
dispatch ( {
type : FETCH _CHANNEL _LIST _FAILED ,
data : error
} ) ;
} ;
lbryProxy . channel _list ( { page , page _size : pageSize , resolve } ) . then ( callback , failure ) ;
2019-04-23 19:22:14 +02:00
} ;
}
2019-07-30 17:48:45 +02:00
function doClaimSearch ( options = {
2019-11-01 20:08:42 +01:00
no _totals : true ,
page _size : 10 ,
page : 1
2020-03-18 18:11:03 +01:00
} ) {
2019-07-30 17:48:45 +02:00
const query = createNormalizedClaimSearchKey ( options ) ;
2019-06-10 04:45:47 +02:00
return dispatch => {
dispatch ( {
2019-07-30 17:48:45 +02:00
type : CLAIM _SEARCH _STARTED ,
data : { query : query }
2019-06-10 04:45:47 +02:00
} ) ;
const success = data => {
const resolveInfo = { } ;
2019-08-20 22:00:26 +02:00
const urls = [ ] ;
2019-06-10 04:45:47 +02:00
data . items . forEach ( stream => {
2019-08-20 22:00:26 +02:00
resolveInfo [ stream . canonical _url ] = { stream } ;
urls . push ( stream . canonical _url ) ;
2019-06-10 04:45:47 +02:00
} ) ;
dispatch ( {
type : CLAIM _SEARCH _COMPLETED ,
2019-08-13 17:27:32 +02:00
data : {
query ,
resolveInfo ,
2019-08-20 22:00:26 +02:00
urls ,
2019-08-13 17:27:32 +02:00
append : options . page && options . page !== 1 ,
pageSize : options . page _size
}
2019-06-10 04:45:47 +02:00
} ) ;
} ;
const failure = err => {
dispatch ( {
type : CLAIM _SEARCH _FAILED ,
2019-07-30 17:48:45 +02:00
data : { query } ,
2019-06-10 04:45:47 +02:00
error : err
} ) ;
} ;
2020-06-11 00:06:12 +02:00
lbryProxy . claim _search ( _extends$6 ( { } , options , {
2020-05-08 22:47:33 +02:00
include _purchase _receipt : true
} ) ) . then ( success , failure ) ;
2019-07-15 04:44:02 +02:00
} ;
}
2020-02-10 16:49:45 +01:00
function doRepost ( options ) {
return dispatch => {
// $FlowFixMe
return new Promise ( resolve => {
dispatch ( {
type : CLAIM _REPOST _STARTED
} ) ;
function success ( response ) {
const repostClaim = response . outputs [ 0 ] ;
dispatch ( {
type : CLAIM _REPOST _COMPLETED ,
data : {
originalClaimId : options . claim _id ,
repostClaim
}
} ) ;
2020-02-13 17:37:36 +01:00
dispatch ( doFetchClaimListMine ( 1 , 10 ) ) ;
2020-02-24 02:19:01 +01:00
resolve ( repostClaim ) ;
2020-02-10 16:49:45 +01:00
}
function failure ( error ) {
dispatch ( {
type : CLAIM _REPOST _FAILED ,
data : {
error : error . message
}
} ) ;
}
lbryProxy . stream _repost ( options ) . then ( success , failure ) ;
} ) ;
} ;
}
2020-04-25 22:31:53 +02:00
function doCheckPublishNameAvailability ( name ) {
return dispatch => {
dispatch ( {
type : CHECK _PUBLISH _NAME _STARTED
} ) ;
return lbryProxy . claim _list ( { name : name } ) . then ( result => {
dispatch ( {
type : CHECK _PUBLISH _NAME _COMPLETED
} ) ;
if ( result . items . length ) {
dispatch ( {
type : FETCH _CLAIM _LIST _MINE _COMPLETED ,
data : {
result ,
resolve : false
}
} ) ;
}
return ! ( result && result . items && result . items . length ) ;
} ) ;
} ;
}
2020-02-10 16:49:45 +01:00
function doClearRepostError ( ) {
return {
type : CLEAR _REPOST _ERROR
} ;
}
2020-05-21 15:38:30 +02:00
function doPurchaseList ( page = 1 , pageSize = PAGE _SIZE ) {
2020-05-08 22:47:33 +02:00
return dispatch => {
dispatch ( {
type : PURCHASE _LIST _STARTED
} ) ;
const success = result => {
return dispatch ( {
type : PURCHASE _LIST _COMPLETED ,
data : {
result
}
} ) ;
} ;
const failure = error => {
dispatch ( {
type : PURCHASE _LIST _FAILED ,
data : {
error : error . message
}
} ) ;
} ;
lbryProxy . purchase _list ( {
page : page ,
page _size : pageSize ,
resolve : true
} ) . then ( success , failure ) ;
} ;
}
2020-06-17 03:56:51 +02:00
const doCheckPendingClaims = onConfirmed => ( dispatch , getState ) => {
let claimCheckInterval ;
const checkClaimList = ( ) => {
const state = getState ( ) ;
const pendingIdSet = new Set ( selectPendingIds ( state ) ) ;
lbryProxy . claim _list ( { page : 1 , page _size : 10 } ) . then ( result => {
const claims = result . items ;
const claimsToConfirm = [ ] ;
claims . forEach ( claim => {
const { claim _id : claimId } = claim ;
if ( claim . confirmations > 0 && pendingIdSet . has ( claimId ) ) {
pendingIdSet . delete ( claimId ) ;
claimsToConfirm . push ( claim ) ;
if ( onConfirmed ) {
onConfirmed ( claim ) ;
}
}
} ) ;
if ( claimsToConfirm . length ) {
dispatch ( {
type : UPDATE _CONFIRMED _CLAIMS ,
data : {
claims : claimsToConfirm
}
} ) ;
}
return pendingIdSet . size ;
} ) . then ( len => {
if ( ! len ) {
clearInterval ( claimCheckInterval ) ;
}
} ) ;
} ;
claimCheckInterval = setInterval ( ( ) => {
checkClaimList ( ) ;
} , 30000 ) ;
} ;
2019-04-03 19:12:51 +02:00
const selectState$3 = state => state . fileInfo || { } ;
const selectFileInfosByOutpoint = reselect . createSelector ( selectState$3 , state => state . byOutpoint || { } ) ;
const selectIsFetchingFileList = reselect . createSelector ( selectState$3 , state => state . isFetchingFileList ) ;
const selectIsFetchingFileListDownloadedOrPublished = reselect . createSelector ( selectIsFetchingFileList , selectIsFetchingClaimListMine , ( isFetchingFileList , isFetchingClaimListMine ) => isFetchingFileList || isFetchingClaimListMine ) ;
const makeSelectFileInfoForUri = uri => reselect . createSelector ( selectClaimsByUri , selectFileInfosByOutpoint , ( claims , byOutpoint ) => {
const claim = claims [ uri ] ;
const outpoint = claim ? ` ${ claim . txid } : ${ claim . nout } ` : undefined ;
return outpoint ? byOutpoint [ outpoint ] : undefined ;
} ) ;
const selectDownloadingByOutpoint = reselect . createSelector ( selectState$3 , state => state . downloadingByOutpoint || { } ) ;
const makeSelectDownloadingForUri = uri => reselect . createSelector ( selectDownloadingByOutpoint , makeSelectFileInfoForUri ( uri ) , ( byOutpoint , fileInfo ) => {
if ( ! fileInfo ) return false ;
return byOutpoint [ fileInfo . outpoint ] ;
} ) ;
2019-08-14 19:08:38 +02:00
const selectUrisLoading = reselect . createSelector ( selectState$3 , state => state . fetching || { } ) ;
2019-04-03 19:12:51 +02:00
2019-08-14 19:08:38 +02:00
const makeSelectLoadingForUri = uri => reselect . createSelector ( selectUrisLoading , makeSelectClaimForUri ( uri ) , ( fetchingByOutpoint , claim ) => {
if ( ! claim ) {
return false ;
}
const { txid , nout } = claim ;
const outpoint = ` ${ txid } : ${ nout } ` ;
const isFetching = fetchingByOutpoint [ outpoint ] ;
return isFetching ;
} ) ;
2019-04-03 19:12:51 +02:00
2019-11-14 18:59:37 +01:00
const selectFileInfosDownloaded = reselect . createSelector ( selectFileInfosByOutpoint , selectMyClaims , ( byOutpoint , myClaims ) => Object . values ( byOutpoint ) . reverse ( ) . filter ( fileInfo => {
2019-04-03 19:12:51 +02:00
const myClaimIds = myClaims . map ( claim => claim . claim _id ) ;
2019-08-02 08:21:28 +02:00
return fileInfo && myClaimIds . indexOf ( fileInfo . claim _id ) === - 1 && ( fileInfo . completed || fileInfo . written _bytes > 0 || fileInfo . blobs _completed > 0 ) ;
2019-04-03 19:12:51 +02:00
} ) ) ;
// export const selectFileInfoForUri = (state, props) => {
// const claims = selectClaimsByUri(state),
// claim = claims[props.uri],
// fileInfos = selectAllFileInfos(state),
// outpoint = claim ? `${claim.txid}:${claim.nout}` : undefined;
// return outpoint && fileInfos ? fileInfos[outpoint] : undefined;
// };
const selectDownloadingFileInfos = reselect . createSelector ( selectDownloadingByOutpoint , selectFileInfosByOutpoint , ( downloadingByOutpoint , fileInfosByOutpoint ) => {
const outpoints = Object . keys ( downloadingByOutpoint ) ;
const fileInfos = [ ] ;
outpoints . forEach ( outpoint => {
const fileInfo = fileInfosByOutpoint [ outpoint ] ;
if ( fileInfo ) fileInfos . push ( fileInfo ) ;
} ) ;
return fileInfos ;
} ) ;
const selectTotalDownloadProgress = reselect . createSelector ( selectDownloadingFileInfos , fileInfos => {
const progress = [ ] ;
fileInfos . forEach ( fileInfo => {
progress . push ( fileInfo . written _bytes / fileInfo . total _bytes * 100 ) ;
} ) ;
const totalProgress = progress . reduce ( ( a , b ) => a + b , 0 ) ;
if ( fileInfos . length > 0 ) return totalProgress / fileInfos . length / 100.0 ;
return - 1 ;
} ) ;
const selectFileListPublishedSort = reselect . createSelector ( selectState$3 , state => state . fileListPublishedSort ) ;
const selectFileListDownloadedSort = reselect . createSelector ( selectState$3 , state => state . fileListDownloadedSort ) ;
2019-06-10 04:45:47 +02:00
const selectDownloadedUris = reselect . createSelector ( selectFileInfosDownloaded ,
// We should use permament_url but it doesn't exist in file_list
2019-11-05 19:52:17 +01:00
info => info . slice ( ) . map ( claim => ` lbry:// ${ claim . claim _name } # ${ claim . claim _id } ` ) ) ;
2019-06-10 04:45:47 +02:00
2019-08-02 08:21:28 +02:00
const makeSelectMediaTypeForUri = uri => reselect . createSelector ( makeSelectFileInfoForUri ( uri ) , makeSelectContentTypeForUri ( uri ) , ( fileInfo , contentType ) => {
if ( ! fileInfo && ! contentType ) {
return undefined ;
}
const fileName = fileInfo && fileInfo . file _name ;
return lbryProxy . getMediaType ( contentType , fileName ) ;
} ) ;
const makeSelectUriIsStreamable = uri => reselect . createSelector ( makeSelectMediaTypeForUri ( uri ) , mediaType => {
const isStreamable = [ 'audio' , 'video' , 'image' ] . indexOf ( mediaType ) !== - 1 ;
return isStreamable ;
} ) ;
const makeSelectDownloadPathForUri = uri => reselect . createSelector ( makeSelectFileInfoForUri ( uri ) , fileInfo => {
return fileInfo && fileInfo . download _path ;
} ) ;
2019-08-14 18:52:24 +02:00
2019-08-14 19:51:30 +02:00
const makeSelectFilePartlyDownloaded = uri => reselect . createSelector ( makeSelectFileInfoForUri ( uri ) , fileInfo => {
if ( ! fileInfo ) {
2019-08-14 18:52:24 +02:00
return false ;
}
2019-08-14 19:51:30 +02:00
return fileInfo . written _bytes > 0 || fileInfo . blobs _completed > 0 ;
2019-08-14 18:52:24 +02:00
} ) ;
2019-08-02 08:21:28 +02:00
const makeSelectFileNameForUri = uri => reselect . createSelector ( makeSelectFileInfoForUri ( uri ) , fileInfo => {
return fileInfo && fileInfo . file _name ;
} ) ;
2019-10-03 23:14:35 +02:00
const selectDownloadUrlsCount = reselect . createSelector ( selectDownloadedUris , uris => uris . length ) ;
function filterFileInfos ( fileInfos , query ) {
if ( query ) {
const queryMatchRegExp = new RegExp ( query , 'i' ) ;
return fileInfos . filter ( fileInfo => {
const { metadata } = fileInfo ;
2020-05-08 22:47:33 +02:00
2019-10-03 23:14:35 +02:00
return metadata . title && metadata . title . match ( queryMatchRegExp ) || fileInfo . channel _name && fileInfo . channel _name . match ( queryMatchRegExp ) || fileInfo . claim _name && fileInfo . claim _name . match ( queryMatchRegExp ) ;
} ) ;
}
return fileInfos ;
}
const makeSelectSearchDownloadUrlsForPage = ( query , page = 1 ) => reselect . createSelector ( selectFileInfosDownloaded , fileInfos => {
const matchingFileInfos = filterFileInfos ( fileInfos , query ) ;
2019-09-25 23:16:27 +02:00
const start = ( Number ( page ) - 1 ) * Number ( PAGE _SIZE ) ;
const end = Number ( page ) * Number ( PAGE _SIZE ) ;
2019-10-03 23:14:35 +02:00
2019-11-05 19:52:17 +01:00
return matchingFileInfos && matchingFileInfos . length ? matchingFileInfos . slice ( start , end ) . map ( fileInfo => buildURI ( {
streamName : fileInfo . claim _name ,
channelName : fileInfo . channel _name ,
channelClaimId : fileInfo . channel _claim _id
} ) ) : [ ] ;
2019-09-23 19:00:12 +02:00
} ) ;
2019-10-03 23:14:35 +02:00
const makeSelectSearchDownloadUrlsCount = query => reselect . createSelector ( selectFileInfosDownloaded , fileInfos => {
return fileInfos && fileInfos . length ? filterFileInfos ( fileInfos , query ) . length : 0 ;
} ) ;
2019-09-23 19:00:12 +02:00
2019-08-02 08:21:28 +02:00
const makeSelectStreamingUrlForUri = uri => reselect . createSelector ( makeSelectFileInfoForUri ( uri ) , fileInfo => {
return fileInfo && fileInfo . streaming _url ;
} ) ;
2019-05-21 21:18:07 +02:00
//
2019-08-02 08:21:28 +02:00
function doFileGet ( uri , saveFile = true , onSuccess ) {
2019-08-13 19:33:32 +02:00
return ( dispatch , getState ) => {
const state = getState ( ) ;
const { nout , txid } = makeSelectClaimForUri ( uri ) ( state ) ;
const outpoint = ` ${ txid } : ${ nout } ` ;
2019-05-21 21:18:07 +02:00
dispatch ( {
2019-08-13 19:33:32 +02:00
type : FETCH _FILE _INFO _STARTED ,
2019-05-21 21:18:07 +02:00
data : {
2019-08-13 19:33:32 +02:00
outpoint
2019-05-21 21:18:07 +02:00
}
} ) ;
// set save_file argument to True to save the file (old behaviour)
lbryProxy . get ( { uri , save _file : saveFile } ) . then ( streamInfo => {
2019-08-02 08:21:28 +02:00
const timeout = streamInfo === null || typeof streamInfo !== 'object' || streamInfo . error === 'Timeout' ;
2019-05-21 21:18:07 +02:00
if ( timeout ) {
dispatch ( {
2019-08-13 19:33:32 +02:00
type : FETCH _FILE _INFO _FAILED ,
data : { outpoint }
2019-05-21 21:18:07 +02:00
} ) ;
dispatch ( doToast ( { message : ` File timeout for uri ${ uri } ` , isError : true } ) ) ;
} else {
2020-05-20 18:06:38 +02:00
if ( streamInfo . purchase _receipt || streamInfo . content _fee ) {
2020-05-18 22:40:33 +02:00
dispatch ( {
type : PURCHASE _URI _COMPLETED ,
2020-05-20 18:06:38 +02:00
data : { uri , purchaseReceipt : streamInfo . purchase _receipt || streamInfo . content _fee }
2020-05-18 22:40:33 +02:00
} ) ;
}
2019-08-02 08:21:28 +02:00
dispatch ( {
type : FETCH _FILE _INFO _COMPLETED ,
data : {
fileInfo : streamInfo ,
2020-05-20 21:40:25 +02:00
outpoint : outpoint
2019-08-02 08:21:28 +02:00
}
2019-05-21 21:18:07 +02:00
} ) ;
2019-08-02 08:21:28 +02:00
if ( onSuccess ) {
onSuccess ( streamInfo ) ;
}
2019-05-21 21:18:07 +02:00
}
2020-05-18 22:40:33 +02:00
} ) . catch ( error => {
2019-05-21 21:18:07 +02:00
dispatch ( {
type : PURCHASE _URI _FAILED ,
2020-05-18 22:40:33 +02:00
data : { uri , error }
2019-05-21 21:18:07 +02:00
} ) ;
dispatch ( {
2019-08-13 19:33:32 +02:00
type : FETCH _FILE _INFO _FAILED ,
data : { outpoint }
2019-05-21 21:18:07 +02:00
} ) ;
dispatch ( doToast ( {
2019-08-02 08:21:28 +02:00
message : ` Failed to view ${ uri } , please try again. If this problem persists, visit https://lbry.com/faq/support for support. ` ,
2019-05-21 21:18:07 +02:00
isError : true
} ) ) ;
} ) ;
} ;
}
2019-08-02 08:21:28 +02:00
function doPurchaseUri ( uri , costInfo , saveFile = true , onSuccess ) {
2019-05-21 21:18:07 +02:00
return ( dispatch , getState ) => {
dispatch ( {
type : PURCHASE _URI _STARTED ,
data : { uri }
} ) ;
const state = getState ( ) ;
const balance = selectBalance ( state ) ;
const fileInfo = makeSelectFileInfoForUri ( uri ) ( state ) ;
const downloadingByOutpoint = selectDownloadingByOutpoint ( state ) ;
const alreadyDownloading = fileInfo && ! ! downloadingByOutpoint [ fileInfo . outpoint ] ;
const alreadyStreaming = makeSelectStreamingUrlForUri ( uri ) ( state ) ;
2019-08-15 00:22:50 +02:00
if ( ! saveFile && ( alreadyDownloading || alreadyStreaming ) ) {
2019-05-21 21:18:07 +02:00
dispatch ( {
type : PURCHASE _URI _FAILED ,
data : { uri , error : ` Already fetching uri: ${ uri } ` }
} ) ;
return ;
}
const { cost } = costInfo ;
2019-05-27 15:59:21 +02:00
if ( parseFloat ( cost ) > balance ) {
2019-05-21 21:18:07 +02:00
dispatch ( {
type : PURCHASE _URI _FAILED ,
data : { uri , error : 'Insufficient credits' }
} ) ;
return ;
}
2019-08-02 08:21:28 +02:00
dispatch ( doFileGet ( uri , saveFile , onSuccess ) ) ;
2019-05-21 21:18:07 +02:00
} ;
}
2020-05-19 04:13:18 +02:00
function doClearPurchasedUriSuccess ( ) {
2019-05-27 15:59:21 +02:00
return {
2020-05-19 04:13:18 +02:00
type : CLEAR _PURCHASED _URI _SUCCESS
2019-05-27 15:59:21 +02:00
} ;
}
2019-04-03 19:12:51 +02:00
function doFetchFileInfo ( uri ) {
return ( dispatch , getState ) => {
const state = getState ( ) ;
const claim = selectClaimsByUri ( state ) [ uri ] ;
const outpoint = claim ? ` ${ claim . txid } : ${ claim . nout } ` : null ;
const alreadyFetching = ! ! selectUrisLoading ( state ) [ uri ] ;
if ( ! alreadyFetching ) {
dispatch ( {
type : FETCH _FILE _INFO _STARTED ,
data : {
outpoint
}
} ) ;
2019-11-05 19:24:41 +01:00
lbryProxy . file _list ( { outpoint , full _status : true , page : 1 , page _size : 1 } ) . then ( result => {
const { items : fileInfos } = result ;
const fileInfo = fileInfos [ 0 ] ;
2019-04-03 19:12:51 +02:00
dispatch ( {
type : FETCH _FILE _INFO _COMPLETED ,
data : {
outpoint ,
2019-11-05 19:24:41 +01:00
fileInfo : fileInfo || null
2019-04-03 19:12:51 +02:00
}
} ) ;
} ) ;
}
} ;
}
2019-11-05 19:24:41 +01:00
function doFileList ( page = 1 , pageSize = 99999 ) {
2019-04-03 19:12:51 +02:00
return ( dispatch , getState ) => {
const state = getState ( ) ;
const isFetching = selectIsFetchingFileList ( state ) ;
if ( ! isFetching ) {
dispatch ( {
type : FILE _LIST _STARTED
} ) ;
2019-11-05 19:24:41 +01:00
lbryProxy . file _list ( { page , page _size : pageSize } ) . then ( result => {
const { items : fileInfos } = result ;
2019-04-03 19:12:51 +02:00
dispatch ( {
type : FILE _LIST _SUCCEEDED ,
data : {
2019-11-14 18:59:37 +01:00
fileInfos : fileInfos
2019-04-03 19:12:51 +02:00
}
} ) ;
} ) ;
}
} ;
}
2020-04-25 22:31:53 +02:00
function doFetchFileInfos ( ) {
2019-04-03 19:12:51 +02:00
return ( dispatch , getState ) => {
const state = getState ( ) ;
const isFetchingFileInfo = selectIsFetchingFileList ( state ) ;
if ( ! isFetchingFileInfo ) dispatch ( doFileList ( ) ) ;
} ;
}
function doSetFileListSort ( page , value ) {
return {
type : SET _FILE _LIST _SORT ,
data : { page , value }
} ;
}
2020-06-11 00:06:12 +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 ; } ;
2020-01-15 01:17:25 +01:00
2019-08-20 22:00:26 +02:00
function _objectWithoutProperties$2 ( obj , keys ) { var target = { } ; for ( var i in obj ) { if ( keys . indexOf ( i ) >= 0 ) continue ; if ( ! Object . prototype . hasOwnProperty . call ( obj , i ) ) continue ; target [ i ] = obj [ i ] ; } return target ; }
2019-07-01 21:49:51 +02:00
2020-05-18 22:40:33 +02:00
const selectState$4 = state => state . publish || { } ;
2019-07-05 04:20:56 +02:00
// Is the current uri the same as the uri they clicked "edit" on
2020-05-18 22:40:33 +02:00
const selectIsStillEditing = reselect . createSelector ( selectState$4 , publishState => {
2019-07-05 04:20:56 +02:00
const { editingURI , uri } = publishState ;
if ( ! editingURI || ! uri ) {
return false ;
2019-07-01 21:49:51 +02:00
}
2019-08-20 22:00:26 +02:00
const {
isChannel : currentIsChannel ,
2019-08-29 09:28:04 +02:00
streamName : currentClaimName ,
channelName : currentContentName
2019-08-20 22:00:26 +02:00
} = parseURI ( uri ) ;
const {
isChannel : editIsChannel ,
2019-08-29 09:28:04 +02:00
streamName : editClaimName ,
channelName : editContentName
2019-08-20 22:00:26 +02:00
} = parseURI ( editingURI ) ;
2019-07-05 04:20:56 +02:00
// Depending on the previous/current use of a channel, we need to compare different things
// ex: going from a channel to anonymous, the new uri won't return contentName, so we need to use claimName
const currentName = currentIsChannel ? currentContentName : currentClaimName ;
const editName = editIsChannel ? editContentName : editClaimName ;
return currentName === editName ;
} ) ;
2020-05-18 22:40:33 +02:00
const selectPublishFormValues = reselect . createSelector ( selectState$4 , selectIsStillEditing , ( state , isStillEditing ) => {
2020-01-16 16:59:35 +01:00
const { pendingPublish , language , languages } = state ,
formValues = _objectWithoutProperties$2 ( state , [ 'pendingPublish' , 'language' , 'languages' ] ) ;
2020-01-15 01:17:25 +01:00
let actualLanguage ;
// Sets default if editing a claim with a set language
2020-01-21 17:46:22 +01:00
if ( ! language && isStillEditing && languages && languages [ 0 ] ) {
2020-01-15 01:17:25 +01:00
actualLanguage = languages [ 0 ] ;
} else {
actualLanguage = language || 'en' ;
}
2020-06-11 00:06:12 +02:00
return _extends$7 ( { } , formValues , { language : actualLanguage } ) ;
2020-01-15 01:17:25 +01:00
} ) ;
2020-05-18 22:40:33 +02:00
const makeSelectPublishFormValue = item => reselect . createSelector ( selectState$4 , state => state [ item ] ) ;
2020-01-15 01:17:25 +01:00
2019-07-05 04:20:56 +02:00
const selectMyClaimForUri = reselect . createSelector ( selectPublishFormValues , selectIsStillEditing , selectClaimsById , selectMyClaimsWithoutChannels , ( { editingURI , uri } , isStillEditing , claimsById , myClaims ) => {
2019-08-29 09:28:04 +02:00
const { channelName : contentName , streamName : claimName } = parseURI ( uri ) ;
const { streamClaimId : editClaimId } = parseURI ( editingURI ) ;
2019-07-05 04:20:56 +02:00
// If isStillEditing
// They clicked "edit" from the file page
// They haven't changed the channel/name after clicking edit
// Get the claim so they can edit without re-uploading a new file
return isStillEditing ? claimsById [ editClaimId ] : myClaims . find ( claim => ! contentName ? claim . name === claimName : claim . name === contentName || claim . name === claimName ) ;
} ) ;
2020-05-18 22:40:33 +02:00
const selectIsResolvingPublishUris = reselect . createSelector ( selectState$4 , selectResolvingUris , ( { uri , name } , resolvingUris ) => {
2019-07-05 04:20:56 +02:00
if ( uri ) {
const isResolvingUri = resolvingUris . includes ( uri ) ;
const { isChannel } = parseURI ( uri ) ;
let isResolvingShortUri ;
2019-08-30 18:28:36 +02:00
if ( isChannel && name ) {
2019-08-20 22:00:26 +02:00
const shortUri = buildURI ( { streamName : name } ) ;
2019-07-05 04:20:56 +02:00
isResolvingShortUri = resolvingUris . includes ( shortUri ) ;
}
return isResolvingUri || isResolvingShortUri ;
}
return false ;
} ) ;
2020-05-18 22:40:33 +02:00
const selectTakeOverAmount = reselect . createSelector ( selectState$4 , selectMyClaimForUri , selectClaimsByUri , ( { name } , myClaimForUri , claimsByUri ) => {
2019-08-28 01:59:04 +02:00
if ( ! name ) {
return null ;
}
2019-07-05 04:20:56 +02:00
// We only care about the winning claim for the short uri
2019-08-28 01:59:04 +02:00
const shortUri = buildURI ( { streamName : name } ) ;
2019-07-05 04:20:56 +02:00
const claimForShortUri = claimsByUri [ shortUri ] ;
if ( ! myClaimForUri && claimForShortUri ) {
2019-08-29 09:28:04 +02:00
return claimForShortUri . meta . effective _amount ;
2019-07-05 04:20:56 +02:00
} else if ( myClaimForUri && claimForShortUri ) {
// https://github.com/lbryio/lbry/issues/1476
// We should check the current effective_amount on my claim to see how much additional lbc
// is needed to win the claim. Currently this is not possible during a takeover.
// With this, we could say something like, "You have x lbc in support, if you bid y additional LBC you will control the claim"
// For now just ignore supports. We will just show the winning claim's bid amount
2019-08-29 09:28:04 +02:00
return claimForShortUri . meta . effective _amount || claimForShortUri . amount ;
2019-07-05 04:20:56 +02:00
}
return null ;
} ) ;
2020-06-11 00:06:12 +02:00
var _extends$8 = Object . assign || function ( target ) { for ( var i = 1 ; i < arguments . length ; i ++ ) { var source = arguments [ i ] ; for ( var key in source ) { if ( Object . prototype . hasOwnProperty . call ( source , key ) ) { target [ key ] = source [ key ] ; } } } return target ; } ;
2019-07-01 21:49:51 +02:00
2020-05-07 13:41:56 +02:00
function _asyncToGenerator ( fn ) { return function ( ) { var gen = fn . apply ( this , arguments ) ; return new Promise ( function ( resolve , reject ) { function step ( key , arg ) { try { var info = gen [ key ] ( arg ) ; var value = info . value ; } catch ( error ) { reject ( error ) ; return ; } if ( info . done ) { resolve ( value ) ; } else { return Promise . resolve ( value ) . then ( function ( value ) { step ( "next" , value ) ; } , function ( err ) { step ( "throw" , err ) ; } ) ; } } return step ( "next" ) ; } ) ; } ; }
2019-07-01 21:49:51 +02:00
const doResetThumbnailStatus = ( ) => dispatch => {
dispatch ( {
type : UPDATE _PUBLISH _FORM ,
data : {
thumbnailPath : ''
}
} ) ;
2019-09-30 21:16:38 +02:00
return fetch ( SPEECH _STATUS ) . then ( res => res . json ( ) ) . then ( status => {
2019-07-01 21:49:51 +02:00
if ( status . disabled ) {
throw Error ( ) ;
}
return dispatch ( {
type : UPDATE _PUBLISH _FORM ,
data : {
uploadThumbnailStatus : READY ,
thumbnail : ''
}
} ) ;
} ) . catch ( ( ) => dispatch ( {
type : UPDATE _PUBLISH _FORM ,
data : {
uploadThumbnailStatus : API _DOWN ,
thumbnail : ''
}
} ) ) ;
} ;
const doClearPublish = ( ) => dispatch => {
dispatch ( { type : CLEAR _PUBLISH } ) ;
return dispatch ( doResetThumbnailStatus ( ) ) ;
} ;
const doUpdatePublishForm = publishFormValue => dispatch => dispatch ( {
type : UPDATE _PUBLISH _FORM ,
2020-06-11 00:06:12 +02:00
data : _extends$8 ( { } , publishFormValue )
2019-07-01 21:49:51 +02:00
} ) ;
2019-10-07 18:33:06 +02:00
const doUploadThumbnail = ( filePath , thumbnailBlob , fsAdapter , fs , path ) => dispatch => {
2019-07-01 21:49:51 +02:00
let thumbnail , fileExt , fileName , fileType ;
const makeid = ( ) => {
let text = '' ;
const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789' ;
for ( let i = 0 ; i < 24 ; i += 1 ) text += possible . charAt ( Math . floor ( Math . random ( ) * 62 ) ) ;
return text ;
} ;
const uploadError = ( error = '' ) => {
dispatch ( batchActions ( {
type : UPDATE _PUBLISH _FORM ,
data : {
uploadThumbnailStatus : READY ,
thumbnail : '' ,
nsfw : false
}
} , doError ( error ) ) ) ;
} ;
2020-04-27 20:13:36 +02:00
const doUpload = data => {
return fetch ( SPEECH _PUBLISH , {
method : 'POST' ,
body : data
} ) . then ( res => res . text ( ) ) . then ( text => text . length ? JSON . parse ( text ) : { } ) . then ( json => {
return json . success ? dispatch ( {
type : UPDATE _PUBLISH _FORM ,
data : {
uploadThumbnailStatus : COMPLETE ,
2020-05-01 18:01:56 +02:00
thumbnail : json . data . serveUrl
2020-04-27 20:13:36 +02:00
}
} ) : uploadError ( json . message || _ _ ( 'Thumbnail upload service may be down, try again later.' ) ) ;
} ) . catch ( err => {
uploadError ( err . message ) ;
} ) ;
} ;
2019-07-01 21:49:51 +02:00
dispatch ( {
type : UPDATE _PUBLISH _FORM ,
data : { uploadThumbnailStatus : IN _PROGRESS }
} ) ;
if ( fsAdapter && fsAdapter . readFile && filePath ) {
fsAdapter . readFile ( filePath , 'base64' ) . then ( base64Image => {
fileExt = 'png' ;
fileName = 'thumbnail.png' ;
fileType = 'image/png' ;
const data = new FormData ( ) ;
const name = makeid ( ) ;
data . append ( 'name' , name ) ;
2019-07-05 04:20:56 +02:00
// $FlowFixMe
2019-07-01 21:49:51 +02:00
data . append ( 'file' , { uri : 'file://' + filePath , type : fileType , name : fileName } ) ;
2020-04-27 20:13:36 +02:00
return doUpload ( data ) ;
2019-07-01 21:49:51 +02:00
} ) ;
} else {
2019-10-07 18:33:06 +02:00
if ( filePath && fs && path ) {
2019-07-01 21:49:51 +02:00
thumbnail = fs . readFileSync ( filePath ) ;
fileExt = path . extname ( filePath ) ;
fileName = path . basename ( filePath ) ;
fileType = ` image/ ${ fileExt . slice ( 1 ) } ` ;
2019-10-07 18:33:06 +02:00
} else if ( thumbnailBlob ) {
fileExt = ` . ${ thumbnailBlob . type && thumbnailBlob . type . split ( '/' ) [ 1 ] } ` ;
fileName = thumbnailBlob . name ;
fileType = thumbnailBlob . type ;
2019-07-01 21:49:51 +02:00
} else {
return null ;
}
const data = new FormData ( ) ;
const name = makeid ( ) ;
2019-10-07 18:33:06 +02:00
const file = thumbnailBlob || thumbnail && new File ( [ thumbnail ] , fileName , { type : fileType } ) ;
2019-07-01 21:49:51 +02:00
data . append ( 'name' , name ) ;
2019-11-01 20:08:42 +01:00
// $FlowFixMe
2019-07-01 21:49:51 +02:00
data . append ( 'file' , file ) ;
2020-04-27 20:13:36 +02:00
return doUpload ( data ) ;
2019-07-01 21:49:51 +02:00
}
} ;
2019-08-13 17:27:32 +02:00
const doPrepareEdit = ( claim , uri , fileInfo , fs ) => dispatch => {
2019-08-14 03:05:30 +02:00
const { name , amount , value = { } } = claim ;
2019-09-04 17:57:48 +02:00
const channelName = claim && claim . signing _channel && claim . signing _channel . name || null ;
2019-07-01 21:49:51 +02:00
const {
author ,
description ,
// use same values as default state
// fee will be undefined for free content
fee = {
2019-07-05 04:20:56 +02:00
amount : '0' ,
2019-07-01 21:49:51 +02:00
currency : 'LBC'
} ,
languages ,
license ,
license _url : licenseUrl ,
thumbnail ,
2019-08-14 20:47:57 +02:00
title ,
tags
2019-07-01 21:49:51 +02:00
} = value ;
const publishData = {
name ,
bid : amount ,
2019-07-29 20:42:28 +02:00
contentIsFree : fee . amount === '0' ,
2019-07-01 21:49:51 +02:00
author ,
description ,
2019-07-29 20:42:28 +02:00
fee ,
2019-07-01 21:49:51 +02:00
languages ,
thumbnail : thumbnail ? thumbnail . url : null ,
title ,
uri ,
uploadThumbnailStatus : thumbnail ? MANUAL : undefined ,
licenseUrl ,
2019-08-14 20:47:57 +02:00
nsfw : isClaimNsfw ( claim ) ,
tags : tags ? tags . map ( tag => ( { name : tag } ) ) : [ ]
2019-07-01 21:49:51 +02:00
} ;
2019-07-13 05:01:16 +02:00
// Make sure custom licenses are mapped properly
2019-07-01 21:49:51 +02:00
// If the license isn't one of the standard licenses, map the custom license and description/url
if ( ! CC _LICENSES . some ( ( { value } ) => value === license ) ) {
if ( ! license || license === NONE || license === PUBLIC _DOMAIN ) {
publishData . licenseType = license ;
} else if ( license && ! licenseUrl && license !== NONE ) {
publishData . licenseType = COPYRIGHT ;
} else {
publishData . licenseType = OTHER ;
}
publishData . otherLicenseDescription = license ;
} else {
publishData . licenseType = license ;
}
2019-07-05 04:20:56 +02:00
if ( channelName ) {
publishData [ 'channel' ] = channelName ;
}
2019-07-01 21:49:51 +02:00
dispatch ( { type : DO _PREPARE _EDIT , data : publishData } ) ;
} ;
2019-07-05 04:20:56 +02:00
const doPublish = ( success , fail ) => ( dispatch , getState ) => {
2019-07-01 21:49:51 +02:00
dispatch ( { type : PUBLISH _START } ) ;
const state = getState ( ) ;
2019-07-05 04:20:56 +02:00
const myClaimForUri = selectMyClaimForUri ( state ) ;
2019-07-01 21:49:51 +02:00
const myChannels = selectMyChannelClaims ( state ) ;
const myClaims = selectMyClaimsWithoutChannels ( state ) ;
2019-07-05 04:20:56 +02:00
// get redux publish form
const publishData = selectPublishFormValues ( state ) ;
2019-07-01 21:49:51 +02:00
2019-07-05 04:20:56 +02:00
// destructure the data values
2019-07-01 21:49:51 +02:00
const {
name ,
bid ,
filePath ,
description ,
language ,
license ,
licenseUrl ,
2020-06-23 20:48:30 +02:00
useLBRYUploader ,
2019-07-05 04:20:56 +02:00
licenseType ,
otherLicenseDescription ,
2019-07-01 21:49:51 +02:00
thumbnail ,
channel ,
title ,
contentIsFree ,
fee ,
uri ,
2019-07-05 04:20:56 +02:00
tags ,
2020-03-02 07:28:36 +01:00
locations ,
optimize
2019-07-05 04:20:56 +02:00
} = publishData ;
2020-01-21 18:00:18 +01:00
// Handle scenario where we have a claim that has the same name as a channel we are publishing with.
2020-01-21 19:33:24 +01:00
const myClaimForUriEditing = myClaimForUri && myClaimForUri . name === name ? myClaimForUri : null ;
2019-07-05 04:20:56 +02:00
let publishingLicense ;
switch ( licenseType ) {
case COPYRIGHT :
case OTHER :
publishingLicense = otherLicenseDescription ;
break ;
default :
publishingLicense = licenseType ;
}
2019-07-01 21:49:51 +02:00
// get the claim id from the channel name, we will use that instead
2019-09-27 00:56:55 +02:00
const namedChannelClaim = myChannels ? myChannels . find ( myChannel => myChannel . name === channel ) : null ;
2019-07-01 21:49:51 +02:00
const channelId = namedChannelClaim ? namedChannelClaim . claim _id : '' ;
const publishPayload = {
name ,
title ,
description ,
2019-10-02 01:00:59 +02:00
locations : [ ] ,
2019-07-05 04:20:56 +02:00
bid : creditsToString ( bid ) ,
languages : [ language ] ,
tags : tags && tags . map ( tag => tag . name ) ,
2019-10-02 01:00:59 +02:00
thumbnail _url : thumbnail ,
blocking : true
2019-07-05 04:20:56 +02:00
} ;
2019-07-01 21:49:51 +02:00
// Temporary solution to keep the same publish flow with the new tags api
// Eventually we will allow users to enter their own tags on publish
// `nsfw` will probably be removed
2019-07-05 04:20:56 +02:00
if ( publishingLicense ) {
publishPayload . license = publishingLicense ;
}
2019-07-01 21:49:51 +02:00
if ( licenseUrl ) {
publishPayload . license _url = licenseUrl ;
}
if ( thumbnail ) {
publishPayload . thumbnail _url = thumbnail ;
}
2019-07-29 20:42:28 +02:00
// Set release time to curret date. On edits, keep original release/transaction time as release_time
2020-01-21 18:00:18 +01:00
if ( myClaimForUriEditing && myClaimForUriEditing . value . release _time ) {
2019-07-05 04:20:56 +02:00
publishPayload . release _time = Number ( myClaimForUri . value . release _time ) ;
2020-01-21 18:00:18 +01:00
} else if ( myClaimForUriEditing && myClaimForUriEditing . timestamp ) {
publishPayload . release _time = Number ( myClaimForUriEditing . timestamp ) ;
2019-07-01 21:49:51 +02:00
} else {
2019-07-29 20:42:28 +02:00
publishPayload . release _time = Number ( Math . round ( Date . now ( ) / 1000 ) ) ;
2019-07-01 21:49:51 +02:00
}
if ( channelId ) {
publishPayload . channel _id = channelId ;
}
2020-01-21 18:00:18 +01:00
if ( myClaimForUriEditing && myClaimForUriEditing . value && myClaimForUriEditing . value . locations ) {
publishPayload . locations = myClaimForUriEditing . value . locations ;
2019-10-02 01:00:59 +02:00
}
2019-07-01 21:49:51 +02:00
if ( ! contentIsFree && fee && fee . currency && Number ( fee . amount ) > 0 ) {
publishPayload . fee _currency = fee . currency ;
publishPayload . fee _amount = creditsToString ( fee . amount ) ;
}
2020-03-02 07:28:36 +01:00
if ( optimize ) {
publishPayload . optimize _file = true ;
}
2019-07-01 21:49:51 +02:00
// Only pass file on new uploads, not metadata only edits.
// The sdk will figure it out
if ( filePath ) publishPayload . file _path = filePath ;
2020-06-23 20:48:30 +02:00
// if (useLBRYUploader) return LbryFirst.upload(publishPayload);
return lbryProxy . publish ( publishPayload ) . then ( response => {
if ( ! useLBRYUploader ) {
return success ( response ) ;
}
publishPayload . permanent _url = response . outputs [ 0 ] . permanent _url ;
return lbryFirstProxy . upload ( publishPayload ) . then ( success ( response ) , fail ) ;
} , fail ) ;
2019-07-01 21:49:51 +02:00
} ;
2020-05-07 13:41:56 +02:00
// Calls file_list until any reflecting files are done
const doCheckReflectingFiles = ( ) => ( dispatch , getState ) => {
const state = getState ( ) ;
const { checkingReflector } = state . claims ;
let reflectorCheckInterval ;
const checkFileList = ( ( ) => {
var _ref = _asyncToGenerator ( function * ( ) {
const state = getState ( ) ;
const reflectingById = selectReflectingById ( state ) ;
const ids = Object . keys ( reflectingById ) ;
const newReflectingById = { } ;
const promises = [ ] ;
// TODO: just use file_list({claim_id: Array<claimId>})
if ( Object . keys ( reflectingById ) . length ) {
ids . forEach ( function ( claimId ) {
promises . push ( lbryProxy . file _list ( { claim _id : claimId } ) ) ;
} ) ;
Promise . all ( promises ) . then ( function ( results ) {
results . forEach ( function ( res ) {
const fileListItem = res . items [ 0 ] ;
const fileClaimId = fileListItem . claim _id ;
const {
is _fully _reflected : done ,
uploading _to _reflector : uploading ,
reflector _progress : progress
} = fileListItem ;
if ( uploading ) {
newReflectingById [ fileClaimId ] = {
fileListItem : fileListItem ,
progress ,
stalled : ! done && ! uploading
} ;
}
} ) ;
} ) . then ( function ( ) {
dispatch ( {
type : UPDATE _FILES _REFLECTING ,
data : newReflectingById
} ) ;
if ( ! Object . keys ( newReflectingById ) . length ) {
dispatch ( {
type : TOGGLE _CHECKING _REFLECTING ,
data : false
} ) ;
clearInterval ( reflectorCheckInterval ) ;
}
} ) ;
} else {
dispatch ( {
type : TOGGLE _CHECKING _REFLECTING ,
data : false
} ) ;
clearInterval ( reflectorCheckInterval ) ;
}
} ) ;
return function checkFileList ( ) {
return _ref . apply ( this , arguments ) ;
} ;
} ) ( ) ;
// do it once...
checkFileList ( ) ;
// then start the interval if it's not already started
if ( ! checkingReflector ) {
dispatch ( {
type : TOGGLE _CHECKING _REFLECTING ,
data : true
} ) ;
reflectorCheckInterval = setInterval ( ( ) => {
checkFileList ( ) ;
} , 5000 ) ;
}
} ;
2019-07-01 21:49:51 +02:00
2019-04-03 19:12:51 +02:00
// Returns a function, that, as long as it continues to be invoked, will not
// be triggered. The function will be called after it stops being called for
// N milliseconds. If `immediate` is passed, trigger the function on the
// leading edge, instead of the trailing.
function debouce ( func , wait , immediate ) {
let timeout ;
return function ( ) {
const context = this ;
const args = arguments ;
const later = ( ) => {
timeout = null ;
if ( ! immediate ) func . apply ( context , args ) ;
} ;
const callNow = immediate && ! timeout ;
clearTimeout ( timeout ) ;
timeout = setTimeout ( later , wait ) ;
if ( callNow ) func . apply ( context , args ) ;
} ;
}
2019-04-23 19:22:14 +02:00
//
2019-04-03 19:12:51 +02:00
function handleFetchResponse ( response ) {
return response . status === 200 ? Promise . resolve ( response . json ( ) ) : Promise . reject ( new Error ( response . statusText ) ) ;
}
2020-06-11 00:06:12 +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 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 ) ;
}
} ;
2020-01-30 07:30:27 +01:00
const doSearch = ( rawQuery , searchOptions ) => ( dispatch , getState ) => {
2019-04-03 19:12:51 +02:00
const query = rawQuery . replace ( /^lbry:\/\//i , '' ) . replace ( /\// , ' ' ) ;
2020-01-30 07:30:27 +01:00
const resolveResults = searchOptions && searchOptions . resolveResults ;
const isBackgroundSearch = searchOptions && searchOptions . isBackgroundSearch || false ;
2019-04-03 19:12:51 +02:00
if ( ! query ) {
dispatch ( {
type : SEARCH _FAIL
} ) ;
return ;
}
const state = getState ( ) ;
2020-01-30 07:30:27 +01:00
let queryWithOptions = makeSelectQueryWithOptions ( query , searchOptions ) ( state ) ;
2019-04-03 19:12:51 +02:00
// If we have already searched for something, we don't need to do anything
const urisForQuery = makeSelectSearchUris ( queryWithOptions ) ( state ) ;
if ( urisForQuery && ! ! urisForQuery . length ) {
return ;
}
dispatch ( {
type : SEARCH _START
} ) ;
// If the user is on the file page with a pre-populated uri and they select
// the search option without typing anything, searchQuery will be empty
// We need to populate it so the input is filled on the search page
// isBackgroundSearch means the search is happening in the background, don't update the search query
if ( ! state . search . searchQuery && ! isBackgroundSearch ) {
dispatch ( doUpdateSearchQuery ( query ) ) ;
}
fetch ( ` ${ CONNECTION _STRING } search? ${ queryWithOptions } ` ) . then ( handleFetchResponse ) . then ( data => {
const uris = [ ] ;
const actions = [ ] ;
data . forEach ( result => {
2019-08-20 22:00:26 +02:00
if ( result ) {
const { name , claimId } = result ;
const urlObj = { } ;
if ( name . startsWith ( '@' ) ) {
urlObj . channelName = name ;
urlObj . channelClaimId = claimId ;
} else {
urlObj . streamName = name ;
urlObj . streamClaimId = claimId ;
}
const url = buildURI ( urlObj ) ;
2020-01-05 11:37:35 +01:00
if ( resolveResults ) {
actions . push ( doResolveUri ( url ) ) ;
}
2019-08-20 22:00:26 +02:00
uris . push ( url ) ;
2019-06-27 08:13:54 +02:00
}
2019-04-03 19:12:51 +02:00
} ) ;
actions . push ( {
type : SEARCH _SUCCESS ,
data : {
query : queryWithOptions ,
uris
}
} ) ;
dispatch ( batchActions ( ... actions ) ) ;
2019-06-27 08:13:54 +02:00
} ) . catch ( e => {
2019-04-03 19:12:51 +02:00
dispatch ( {
type : SEARCH _FAIL
} ) ;
} ) ;
} ;
2020-01-22 02:04:50 +01:00
const doResolvedSearch = ( rawQuery , size , // only pass in if you don't want to use the users setting (ex: related content)
2020-02-10 12:04:34 +01:00
from , isBackgroundSearch = false , options = { } , nsfw ) => ( dispatch , getState ) => {
2020-01-22 02:04:50 +01:00
const query = rawQuery . replace ( /^lbry:\/\//i , '' ) . replace ( /\// , ' ' ) ;
if ( ! query ) {
dispatch ( {
type : RESOLVED _SEARCH _FAIL
} ) ;
return ;
}
2020-06-11 00:06:12 +02:00
const optionsWithFrom = _extends$9 ( { } , size ? { size } : { } , from ? { from } : { } , {
2020-01-30 07:30:27 +01:00
isBackgroundSearch
} , options ) ;
2020-06-11 00:06:12 +02:00
const optionsWithoutFrom = _extends$9 ( { } , size ? { size } : { } , {
2020-01-30 07:30:27 +01:00
isBackgroundSearch
} , options ) ;
2020-01-22 02:04:50 +01:00
const state = getState ( ) ;
2020-01-30 07:30:27 +01:00
let queryWithOptions = makeSelectQueryWithOptions ( query , optionsWithFrom ) ( state ) ;
2020-01-22 02:04:50 +01:00
// make from null so that we can maintain a reference to the same query for multiple pages and simply append the found results
2020-01-30 07:30:27 +01:00
let queryWithoutFrom = makeSelectQueryWithOptions ( query , optionsWithoutFrom ) ( state ) ;
2020-01-22 02:04:50 +01:00
// If we have already searched for something, we don't need to do anything
// TODO: Tweak this check for multiple page results
/ * c o n s t r e s u l t s F o r Q u e r y = m a k e S e l e c t R e s o l v e d S e a r c h R e s u l t s ( q u e r y W i t h O p t i o n s ) ( s t a t e ) ;
if ( resultsForQuery && resultsForQuery . length && resultsForQuery . length > ( from * size ) ) {
return ;
} * /
dispatch ( {
type : RESOLVED _SEARCH _START
} ) ;
if ( ! state . search . searchQuery && ! isBackgroundSearch ) {
dispatch ( doUpdateSearchQuery ( query ) ) ;
}
2020-02-10 12:04:34 +01:00
const fetchUrl = nsfw ? ` ${ CONNECTION _STRING } search?resolve=true& ${ queryWithOptions } ` : ` ${ CONNECTION _STRING } search?resolve=true&nsfw=false& ${ queryWithOptions } ` ;
fetch ( fetchUrl ) . then ( handleFetchResponse ) . then ( data => {
2020-01-22 02:04:50 +01:00
const results = [ ] ;
data . forEach ( result => {
if ( result ) {
results . push ( result ) ;
}
} ) ;
dispatch ( {
type : RESOLVED _SEARCH _SUCCESS ,
data : {
query : queryWithoutFrom ,
results ,
pageSize : size ,
append : parseInt ( from , 10 ) > parseInt ( size , 10 ) - 1
}
} ) ;
} ) . catch ( e => {
dispatch ( {
type : RESOLVED _SEARCH _FAIL
} ) ;
} ) ;
} ;
2019-04-03 19:12:51 +02:00
const doFocusSearchInput = ( ) => dispatch => dispatch ( {
type : SEARCH _FOCUS
} ) ;
const doBlurSearchInput = ( ) => dispatch => dispatch ( {
type : SEARCH _BLUR
} ) ;
2020-01-30 07:30:27 +01:00
const doUpdateSearchOptions = ( newOptions , additionalOptions ) => ( dispatch , getState ) => {
2019-04-03 19:12:51 +02:00
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
2020-01-30 07:30:27 +01:00
dispatch ( doSearch ( searchValue , additionalOptions ) ) ;
2019-04-03 19:12:51 +02:00
}
} ;
2020-01-21 06:46:14 +01:00
//
2020-01-13 23:00:04 +01:00
2019-04-03 19:12:51 +02:00
function savePosition ( claimId , outpoint , position ) {
return dispatch => {
dispatch ( {
type : SET _CONTENT _POSITION ,
data : { claimId , outpoint , position }
} ) ;
} ;
}
2019-04-23 19:22:14 +02:00
//
2019-04-03 19:12:51 +02:00
2019-06-10 04:45:47 +02:00
const doToggleTagFollow = name => ( {
type : TOGGLE _TAG _FOLLOW ,
data : {
name
}
} ) ;
const doAddTag = name => ( {
type : TAG _ADD ,
data : {
name
}
} ) ;
const doDeleteTag = name => ( {
type : TAG _DELETE ,
data : {
name
}
} ) ;
2020-06-29 23:02:19 +02:00
//
function doCommentList ( uri , page = 1 , pageSize = 99999 ) {
return ( dispatch , getState ) => {
const state = getState ( ) ;
const claim = selectClaimsByUri ( state ) [ uri ] ;
const claimId = claim ? claim . claim _id : null ;
dispatch ( {
type : COMMENT _LIST _STARTED
} ) ;
lbryProxy . comment _list ( {
claim _id : claimId ,
page ,
page _size : pageSize
} ) . then ( result => {
const { items : comments } = result ;
dispatch ( {
type : COMMENT _LIST _COMPLETED ,
data : {
comments ,
claimId : claimId ,
uri : uri
}
} ) ;
} ) . catch ( error => {
console . log ( error ) ;
dispatch ( {
type : COMMENT _LIST _FAILED ,
data : error
} ) ;
} ) ;
} ;
}
function doCommentCreate ( comment = '' , claim _id = '' , channel , parent _id ) {
return ( dispatch , getState ) => {
const state = getState ( ) ;
dispatch ( {
type : COMMENT _CREATE _STARTED
} ) ;
const myChannels = selectMyChannelClaims ( state ) ;
const namedChannelClaim = myChannels && myChannels . find ( myChannel => myChannel . name === channel ) ;
const channel _id = namedChannelClaim . claim _id ;
if ( channel _id == null ) {
dispatch ( {
type : COMMENT _CREATE _FAILED ,
data : { }
} ) ;
dispatch ( doToast ( {
message : 'Channel cannot be anonymous, please select a channel and try again.' ,
isError : true
} ) ) ;
return ;
}
return lbryProxy . comment _create ( {
comment : comment ,
claim _id : claim _id ,
channel _id : channel _id ,
parent _id : parent _id
} ) . then ( result => {
dispatch ( {
type : COMMENT _CREATE _COMPLETED ,
data : {
comment : result ,
claimId : claim _id
}
} ) ;
} ) . catch ( error => {
dispatch ( {
type : COMMENT _CREATE _FAILED ,
data : error
} ) ;
dispatch ( doToast ( {
message : 'Unable to create comment, please try again later.' ,
isError : true
} ) ) ;
} ) ;
} ;
}
function doCommentHide ( comment _id ) {
return dispatch => {
dispatch ( {
type : COMMENT _HIDE _STARTED
} ) ;
return lbryProxy . comment _hide ( {
comment _ids : [ comment _id ]
} ) . then ( result => {
dispatch ( {
type : COMMENT _HIDE _COMPLETED ,
data : result
} ) ;
} ) . catch ( error => {
dispatch ( {
type : COMMENT _HIDE _FAILED ,
data : error
} ) ;
dispatch ( doToast ( {
message : 'Unable to hide this comment, please try again later.' ,
isError : true
} ) ) ;
} ) ;
} ;
}
function doCommentAbandon ( comment _id ) {
return dispatch => {
dispatch ( {
type : COMMENT _ABANDON _STARTED
} ) ;
return lbryProxy . comment _abandon ( {
comment _id : comment _id
} ) . then ( result => {
// Comment may not be deleted if the signing channel can't be signed.
// This will happen if the channel was recently created or abandoned.
if ( result . abandoned ) {
dispatch ( {
type : COMMENT _ABANDON _COMPLETED ,
data : {
comment _id : comment _id
}
} ) ;
} else {
dispatch ( {
type : COMMENT _ABANDON _FAILED
} ) ;
dispatch ( doToast ( {
message : 'Your channel is still being setup, try again in a few moments.' ,
isError : true
} ) ) ;
}
} ) . catch ( error => {
dispatch ( {
type : COMMENT _ABANDON _FAILED ,
data : error
} ) ;
dispatch ( doToast ( {
message : 'Unable to delete this comment, please try again later.' ,
isError : true
} ) ) ;
} ) ;
} ;
}
function doCommentUpdate ( comment _id , comment ) {
// if they provided an empty string, they must have wanted to abandon
if ( comment === '' ) {
return doCommentAbandon ( comment _id ) ;
} else {
return dispatch => {
dispatch ( {
type : COMMENT _UPDATE _STARTED
} ) ;
return lbryProxy . comment _update ( {
comment _id : comment _id ,
comment : comment
} ) . then ( result => {
if ( result != null ) {
dispatch ( {
type : COMMENT _UPDATE _COMPLETED ,
data : {
comment : result
}
} ) ;
} else {
// the result will return null
dispatch ( {
type : COMMENT _UPDATE _FAILED
} ) ;
dispatch ( doToast ( {
message : 'Your channel is still being setup, try again in a few moments.' ,
isError : true
} ) ) ;
}
} ) . catch ( error => {
dispatch ( {
type : COMMENT _UPDATE _FAILED ,
data : error
} ) ;
dispatch ( doToast ( {
message : 'Unable to edit this comment, please try again later.' ,
isError : true
} ) ) ;
} ) ;
} ;
}
}
//
const doToggleBlockChannel = uri => ( {
type : TOGGLE _BLOCK _CHANNEL ,
data : {
uri
}
} ) ;
2020-06-11 00:06:12 +02:00
var _extends$a = Object . assign || function ( target ) { for ( var i = 1 ; i < arguments . length ; i ++ ) { var source = arguments [ i ] ; for ( var key in source ) { if ( Object . prototype . hasOwnProperty . call ( source , key ) ) { target [ key ] = source [ key ] ; } } } return target ; } ;
2019-09-10 20:14:40 +02:00
2020-06-17 03:56:51 +02:00
/ *
new claim = { ... maybeResolvedClaim , ... pendingClaim , meta : maybeResolvedClaim [ 'meta' ] }
* /
function mergeClaims ( maybeResolved , pending ) {
return _extends$a ( { } , maybeResolved , pending , { meta : maybeResolved . meta } ) ;
}
var _extends$b = Object . assign || function ( target ) { for ( var i = 1 ; i < arguments . length ; i ++ ) { var source = arguments [ i ] ; for ( var key in source ) { if ( Object . prototype . hasOwnProperty . call ( source , key ) ) { target [ key ] = source [ key ] ; } } } return target ; } ;
2020-05-08 22:47:33 +02:00
function _objectWithoutProperties$3 ( obj , keys ) { var target = { } ; for ( var i in obj ) { if ( keys . indexOf ( i ) >= 0 ) continue ; if ( ! Object . prototype . hasOwnProperty . call ( obj , i ) ) continue ; target [ i ] = obj [ i ] ; } return target ; }
2019-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 : { } ,
2019-11-22 02:36:06 +01:00
paginatedClaimsByChannel : { } ,
2019-04-23 19:22:14 +02:00
channelClaimCounts : { } ,
fetchingChannelClaims : { } ,
resolvingUris : [ ] ,
2019-09-13 21:52:52 +02:00
myChannelClaims : undefined ,
2019-09-24 21:57:51 +02:00
myClaims : undefined ,
2020-05-08 22:47:33 +02:00
myPurchases : undefined ,
myPurchasesPageNumber : undefined ,
myPurchasesPageTotalResults : undefined ,
2020-05-18 22:40:33 +02:00
purchaseUriSuccess : false ,
2020-05-08 22:47:33 +02:00
fetchingMyPurchases : false ,
fetchingMyPurchasesError : undefined ,
2019-04-23 19:22:14 +02:00
fetchingMyChannels : false ,
abandoningById : { } ,
2020-06-17 03:56:51 +02:00
pendingIds : [ ] ,
2020-05-07 13:41:56 +02:00
reflectingById : { } ,
2019-07-17 23:34:00 +02:00
claimSearchError : false ,
2019-07-30 17:48:45 +02:00
claimSearchByQuery : { } ,
2019-08-13 17:27:32 +02:00
claimSearchByQueryLastPageReached : { } ,
2019-09-15 13:00:14 +02:00
fetchingClaimSearchByQuery : { } ,
updateChannelError : '' ,
2019-08-27 06:42:52 +02:00
updatingChannel : false ,
2019-09-10 20:14:40 +02:00
creatingChannel : false ,
2019-09-12 21:06:49 +02:00
createChannelError : undefined ,
2020-02-10 16:49:45 +01:00
pendingChannelImport : false ,
repostLoading : false ,
2020-04-25 22:31:53 +02:00
repostError : undefined ,
fetchingClaimListMinePageError : undefined ,
myClaimsPageResults : [ ] ,
myClaimsPageNumber : undefined ,
myClaimsPageTotalResults : undefined ,
isFetchingClaimListMine : false ,
2020-05-08 22:47:33 +02:00
isFetchingMyPurchases : false ,
2020-05-07 13:41:56 +02:00
isCheckingNameForPublish : false ,
checkingPending : false ,
checkingReflecting : false
2019-04-03 19:12:51 +02:00
} ;
2019-06-10 04:45:47 +02:00
function handleClaimAction ( state , action ) {
2019-06-06 23:37:36 +02:00
const {
resolveInfo
} = action . data ;
2020-06-22 20:37:37 +02:00
2019-04-03 19:12:51 +02:00
const byUri = Object . assign ( { } , state . claimsByUri ) ;
const byId = Object . assign ( { } , state . byId ) ;
const channelClaimCounts = Object . assign ( { } , state . channelClaimCounts ) ;
2020-06-17 03:56:51 +02:00
const pendingIds = state . pendingIds ;
2019-09-04 17:57:48 +02:00
let newResolvingUrls = new Set ( state . resolvingUris ) ;
2019-04-03 19:12:51 +02:00
2019-08-20 22:00:26 +02:00
Object . entries ( resolveInfo ) . forEach ( ( [ url , resolveResponse ] ) => {
2019-04-23 19:22:14 +02:00
// $FlowFixMe
2019-08-20 22:00:26 +02:00
const { claimsInChannel , stream , channel } = resolveResponse ;
2019-04-03 19:12:51 +02:00
2019-06-11 18:22:44 +02:00
if ( stream ) {
2020-06-17 03:56:51 +02:00
if ( pendingIds . includes ( stream . claim _id ) ) {
byId [ stream . claim _id ] = mergeClaims ( stream , byId [ stream . claim _id ] ) ;
} else {
byId [ stream . claim _id ] = stream ;
}
2019-08-20 22:00:26 +02:00
byUri [ url ] = stream . claim _id ;
2019-11-18 20:15:00 +01:00
// If url isn't a canonical_url, make sure that is added too
byUri [ stream . canonical _url ] = stream . claim _id ;
2019-09-04 17:57:48 +02:00
// Also add the permanent_url here until lighthouse returns canonical_url for search results
byUri [ stream . permanent _url ] = stream . claim _id ;
newResolvingUrls . delete ( stream . canonical _url ) ;
newResolvingUrls . delete ( stream . permanent _url ) ;
}
2020-06-17 03:56:51 +02:00
if ( channel && channel . claim _id ) {
2020-06-22 20:37:37 +02:00
if ( ! stream ) {
byUri [ url ] = channel . claim _id ;
}
2020-06-17 03:56:51 +02:00
if ( claimsInChannel ) {
channelClaimCounts [ url ] = claimsInChannel ;
channelClaimCounts [ channel . canonical _url ] = claimsInChannel ;
2019-09-04 17:57:48 +02:00
}
2020-06-17 03:56:51 +02:00
if ( pendingIds . includes ( channel . claim _id ) ) {
byId [ channel . claim _id ] = mergeClaims ( channel , byId [ channel . claim _id ] ) ;
} else {
byId [ channel . claim _id ] = channel ;
}
2019-09-04 17:57:48 +02:00
// Also add the permanent_url here until lighthouse returns canonical_url for search results
byUri [ channel . permanent _url ] = channel . claim _id ;
byUri [ channel . canonical _url ] = channel . claim _id ;
newResolvingUrls . delete ( channel . canonical _url ) ;
newResolvingUrls . delete ( channel . permanent _url ) ;
2019-06-11 18:22:44 +02:00
}
2019-08-20 22:00:26 +02:00
2019-09-04 17:57:48 +02:00
newResolvingUrls . delete ( url ) ;
2019-06-11 18:22:44 +02:00
if ( ! stream && ! channel ) {
2019-08-20 22:00:26 +02:00
byUri [ url ] = null ;
2019-04-03 19:12:51 +02:00
}
} ) ;
return Object . assign ( { } , state , {
byId ,
claimsByUri : byUri ,
channelClaimCounts ,
2019-09-04 17:57:48 +02:00
resolvingUris : Array . from ( newResolvingUrls )
2019-04-03 19:12:51 +02:00
} ) ;
2019-06-10 04:45:47 +02:00
}
2019-09-04 17:57:48 +02:00
reducers [ RESOLVE _URIS _STARTED ] = ( state , action ) => {
const { uris } = action . data ;
const oldResolving = state . resolvingUris || [ ] ;
const newResolving = oldResolving . slice ( ) ;
uris . forEach ( uri => {
if ( ! newResolving . includes ( uri ) ) {
newResolving . push ( uri ) ;
}
} ) ;
return Object . assign ( { } , state , {
resolvingUris : newResolving
} ) ;
} ;
2019-06-10 04:45:47 +02:00
reducers [ RESOLVE _URIS _COMPLETED ] = ( state , action ) => {
2020-06-17 03:56:51 +02:00
return _extends$b ( { } , handleClaimAction ( state , action ) ) ;
2019-04-03 19:12:51 +02:00
} ;
reducers [ FETCH _CLAIM _LIST _MINE _STARTED ] = state => Object . assign ( { } , state , {
isFetchingClaimListMine : true
} ) ;
reducers [ FETCH _CLAIM _LIST _MINE _COMPLETED ] = ( state , action ) => {
2020-04-25 22:31:53 +02:00
const { result , resolve } = action . data ;
const claims = result . items ;
const page = result . page ;
const totalItems = result . total _items ;
2019-04-03 19:12:51 +02:00
const byId = Object . assign ( { } , state . byId ) ;
const byUri = Object . assign ( { } , state . claimsByUri ) ;
2020-06-17 03:56:51 +02:00
const pendingIds = state . pendingIds || [ ] ;
2020-03-25 03:46:35 +01:00
let myClaimIds = new Set ( state . myClaims ) ;
2020-05-08 22:47:33 +02:00
let urlsForCurrentPage = [ ] ;
2019-04-03 19:12:51 +02:00
2020-06-17 03:56:51 +02:00
const pendingIdSet = new Set ( pendingIds ) ;
2019-04-03 19:12:51 +02:00
claims . forEach ( claim => {
2020-06-17 03:56:51 +02:00
const { permanent _url : permanentUri , claim _id : claimId } = claim ;
2019-04-03 19:12:51 +02:00
if ( claim . type && claim . type . match ( /claim|update/ ) ) {
2020-06-17 03:56:51 +02:00
urlsForCurrentPage . push ( permanentUri ) ;
2019-04-03 19:12:51 +02:00
if ( claim . confirmations < 1 ) {
2020-06-17 03:56:51 +02:00
pendingIdSet . add ( claimId ) ;
} else if ( ! resolve && pendingIdSet . has ( claimId ) && claim . confirmations > 0 ) {
pendingIdSet . delete ( claimId ) ;
}
if ( pendingIds . includes ( claimId ) ) {
byId [ claimId ] = mergeClaims ( claim , byId [ claimId ] ) ;
2019-04-03 19:12:51 +02:00
} else {
2020-03-25 03:46:35 +01:00
byId [ claimId ] = claim ;
}
2020-06-17 03:56:51 +02:00
byUri [ permanentUri ] = claimId ;
2020-03-25 03:46:35 +01:00
myClaimIds . add ( claimId ) ;
2019-04-03 19:12:51 +02:00
}
} ) ;
return Object . assign ( { } , state , {
isFetchingClaimListMine : false ,
2020-04-10 14:16:27 +02:00
myClaims : Array . from ( myClaimIds ) ,
2019-04-03 19:12:51 +02:00
byId ,
2020-06-17 03:56:51 +02:00
pendingIds : Array . from ( pendingIdSet ) ,
2019-04-03 19:12:51 +02:00
claimsByUri : byUri ,
2020-05-08 22:47:33 +02:00
myClaimsPageResults : urlsForCurrentPage ,
2020-04-25 22:31:53 +02:00
myClaimsPageNumber : page ,
myClaimsPageTotalResults : totalItems
2019-04-03 19:12:51 +02:00
} ) ;
} ;
reducers [ FETCH _CHANNEL _LIST _STARTED ] = state => Object . assign ( { } , state , { fetchingMyChannels : true } ) ;
reducers [ FETCH _CHANNEL _LIST _COMPLETED ] = ( state , action ) => {
const { claims } = action . data ;
2019-09-24 21:57:51 +02:00
const myClaims = state . myClaims || [ ] ;
2020-03-25 03:46:35 +01:00
let myClaimIds = new Set ( state . myClaims ) ;
2020-06-17 03:56:51 +02:00
const pendingIds = state . pendingIds || [ ] ;
2019-09-13 21:52:52 +02:00
let myChannelClaims ;
2020-02-12 22:45:30 +01:00
const byId = Object . assign ( { } , state . byId ) ;
const byUri = Object . assign ( { } , state . claimsByUri ) ;
const channelClaimCounts = Object . assign ( { } , state . channelClaimCounts ) ;
2019-09-13 21:52:52 +02:00
if ( ! claims . length ) {
// $FlowFixMe
2020-04-15 23:36:48 +02:00
myChannelClaims = null ;
2019-09-13 21:52:52 +02:00
} else {
myChannelClaims = new Set ( state . myChannelClaims ) ;
claims . forEach ( claim => {
2020-02-12 22:45:30 +01:00
const { claims _in _channel : claimsInChannel } = claim . meta ;
const { canonical _url : canonicalUrl , permanent _url : permanentUrl , claim _id : claimId } = claim ;
byUri [ canonicalUrl ] = claimId ;
byUri [ permanentUrl ] = claimId ;
channelClaimCounts [ canonicalUrl ] = claimsInChannel ;
channelClaimCounts [ permanentUrl ] = claimsInChannel ;
2019-09-13 21:52:52 +02:00
// $FlowFixMe
2020-02-12 22:45:30 +01:00
myChannelClaims . add ( claimId ) ;
2020-06-17 03:56:51 +02:00
if ( ! pendingIds . some ( c => c === claimId ) ) {
2020-02-12 22:45:30 +01:00
byId [ claimId ] = claim ;
2020-01-10 03:36:18 +01:00
}
2020-03-25 03:46:35 +01:00
myClaimIds . add ( claimId ) ;
2019-09-13 21:52:52 +02:00
} ) ;
}
2019-04-03 19:12:51 +02:00
return Object . assign ( { } , state , {
byId ,
2020-02-12 22:45:30 +01:00
claimsByUri : byUri ,
channelClaimCounts ,
2019-04-03 19:12:51 +02:00
fetchingMyChannels : false ,
2020-04-15 23:36:48 +02:00
myChannelClaims : myChannelClaims ? Array . from ( myChannelClaims ) : null ,
2020-06-17 03:56:51 +02:00
myClaims : myClaimIds ? Array . from ( myClaimIds ) : null
2019-04-03 19:12:51 +02:00
} ) ;
} ;
2020-06-01 20:26:07 +02:00
reducers [ FETCH _CHANNEL _LIST _FAILED ] = ( state , action ) => {
return Object . assign ( { } , state , {
fetchingMyChannels : false
} ) ;
} ;
2019-04-03 19:12:51 +02:00
reducers [ FETCH _CHANNEL _CLAIMS _STARTED ] = ( state , action ) => {
const { uri , page } = action . data ;
const fetchingChannelClaims = Object . assign ( { } , state . fetchingChannelClaims ) ;
fetchingChannelClaims [ uri ] = page ;
return Object . assign ( { } , state , {
fetchingChannelClaims ,
currentChannelPage : page
} ) ;
} ;
reducers [ FETCH _CHANNEL _CLAIMS _COMPLETED ] = ( state , action ) => {
2019-04-23 19:22:14 +02:00
const {
uri ,
claims ,
2019-11-19 21:29:32 +01:00
claimsInChannel ,
2019-11-22 00:52:37 +01:00
page ,
totalPages
2019-04-23 19:22:14 +02:00
} = action . data ;
2019-11-22 00:52:37 +01:00
// byChannel keeps claim_search relevant results by page. If the total changes, erase it.
2019-11-19 21:29:32 +01:00
const channelClaimCounts = Object . assign ( { } , state . channelClaimCounts ) ;
2019-11-22 00:52:37 +01:00
2019-11-22 02:36:06 +01:00
const paginatedClaimsByChannel = Object . assign ( { } , state . paginatedClaimsByChannel ) ;
2019-11-22 00:52:37 +01:00
// check if count has changed - that means cached pagination will be wrong, so clear it
2019-11-22 02:36:06 +01:00
const previousCount = paginatedClaimsByChannel [ uri ] && paginatedClaimsByChannel [ uri ] [ 'itemCount' ] ;
const byChannel = claimsInChannel === previousCount ? Object . assign ( { } , paginatedClaimsByChannel [ uri ] ) : { } ;
2019-04-03 19:12:51 +02:00
const allClaimIds = new Set ( byChannel . all ) ;
const currentPageClaimIds = [ ] ;
const byId = Object . assign ( { } , state . byId ) ;
const fetchingChannelClaims = Object . assign ( { } , state . fetchingChannelClaims ) ;
const claimsByUri = Object . assign ( { } , state . claimsByUri ) ;
if ( claims !== undefined ) {
claims . forEach ( claim => {
allClaimIds . add ( claim . claim _id ) ;
currentPageClaimIds . push ( claim . claim _id ) ;
byId [ claim . claim _id ] = claim ;
2019-09-04 17:57:48 +02:00
claimsByUri [ claim . canonical _url ] = claim . claim _id ;
2019-04-03 19:12:51 +02:00
} ) ;
}
byChannel . all = allClaimIds ;
2019-11-22 00:52:37 +01:00
byChannel . pageCount = totalPages ;
byChannel . itemCount = claimsInChannel ;
2019-04-03 19:12:51 +02:00
byChannel [ page ] = currentPageClaimIds ;
2019-11-22 02:36:06 +01:00
paginatedClaimsByChannel [ uri ] = byChannel ;
2019-04-03 19:12:51 +02:00
delete fetchingChannelClaims [ uri ] ;
return Object . assign ( { } , state , {
2019-11-22 02:36:06 +01:00
paginatedClaimsByChannel ,
2019-04-03 19:12:51 +02:00
byId ,
fetchingChannelClaims ,
claimsByUri ,
2019-11-19 21:29:32 +01:00
channelClaimCounts ,
2019-04-03 19:12:51 +02:00
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
} ) ;
} ;
2020-04-25 22:31:53 +02:00
reducers [ UPDATE _PENDING _CLAIMS ] = ( state , action ) => {
2020-06-17 03:56:51 +02:00
const { claims : pendingClaims } = action . data ;
2020-04-25 22:31:53 +02:00
const byId = Object . assign ( { } , state . byId ) ;
const byUri = Object . assign ( { } , state . claimsByUri ) ;
2020-06-17 03:56:51 +02:00
const pendingIds = state . pendingIds ;
const pendingIdSet = new Set ( pendingIds ) ;
2020-04-25 22:31:53 +02:00
let myClaimIds = new Set ( state . myClaims ) ;
2020-06-17 03:56:51 +02:00
const myChannelClaims = new Set ( state . myChannelClaims ) ;
2020-04-25 22:31:53 +02:00
2020-05-08 22:47:33 +02:00
// $FlowFixMe
2020-06-17 03:56:51 +02:00
pendingClaims . forEach ( claim => {
let newClaim ;
const { permanent _url : uri , claim _id : claimId , type , value _type : valueType } = claim ;
pendingIdSet . add ( claimId ) ;
const oldClaim = byId [ claimId ] ;
if ( oldClaim && oldClaim . canonical _url ) {
newClaim = mergeClaims ( oldClaim , claim ) ;
} else {
newClaim = claim ;
}
if ( valueType === 'channel' ) {
myChannelClaims . add ( claimId ) ;
}
if ( type && type . match ( /claim|update/ ) ) {
byId [ claimId ] = newClaim ;
2020-04-25 22:31:53 +02:00
byUri [ uri ] = claimId ;
}
myClaimIds . add ( claimId ) ;
} ) ;
return Object . assign ( { } , state , {
myClaims : Array . from ( myClaimIds ) ,
byId ,
2020-06-17 03:56:51 +02:00
myChannelClaims : Array . from ( myChannelClaims ) ,
2020-04-25 22:31:53 +02:00
claimsByUri : byUri ,
2020-06-17 03:56:51 +02:00
pendingIds : Array . from ( pendingIdSet )
2020-04-25 22:31:53 +02:00
} ) ;
} ;
reducers [ UPDATE _CONFIRMED _CLAIMS ] = ( state , action ) => {
2020-06-17 03:56:51 +02:00
const { claims : confirmedClaims } = action . data ;
2020-04-25 22:31:53 +02:00
const byId = Object . assign ( { } , state . byId ) ;
const byUri = Object . assign ( { } , state . claimsByUri ) ;
2020-06-17 03:56:51 +02:00
const pendingIds = state . pendingIds ;
const pendingIdSet = new Set ( pendingIds ) ;
confirmedClaims . forEach ( claim => {
const { permanent _url : permanentUri , claim _id : claimId , type } = claim ;
let newClaim = claim ;
const oldClaim = byId [ claimId ] ;
if ( oldClaim && oldClaim . canonical _url ) {
newClaim = mergeClaims ( oldClaim , claim ) ;
}
if ( type && type . match ( /claim|update|channel/ ) ) {
byId [ claimId ] = newClaim ;
pendingIdSet . delete ( claimId ) ;
2020-04-25 22:31:53 +02:00
}
} ) ;
return Object . assign ( { } , state , {
2020-06-17 03:56:51 +02:00
pendingIds : Array . from ( pendingIdSet ) ,
2020-04-25 22:31:53 +02:00
byId ,
2020-06-17 03:56:51 +02:00
claimsByUri : byUri
2020-04-25 22:31:53 +02:00
} ) ;
} ;
2019-04-03 19:12:51 +02:00
reducers [ ABANDON _CLAIM _SUCCEEDED ] = ( state , action ) => {
const { claimId } = action . data ;
const byId = Object . assign ( { } , state . byId ) ;
2019-10-16 19:32:50 +02:00
const newMyClaims = state . myClaims ? state . myClaims . slice ( ) : [ ] ;
2020-04-10 14:16:27 +02:00
const newMyChannelClaims = state . myChannelClaims ? state . myChannelClaims . slice ( ) : [ ] ;
2019-04-03 19:12:51 +02:00
const claimsByUri = Object . assign ( { } , state . claimsByUri ) ;
Object . keys ( claimsByUri ) . forEach ( uri => {
if ( claimsByUri [ uri ] === claimId ) {
delete claimsByUri [ uri ] ;
}
} ) ;
2020-04-10 14:16:27 +02:00
const myClaims = newMyClaims . filter ( i => i !== claimId ) ;
const myChannelClaims = newMyChannelClaims . filter ( i => i !== claimId ) ;
2019-04-03 19:12:51 +02:00
delete byId [ claimId ] ;
return Object . assign ( { } , state , {
2019-10-17 20:05:33 +02:00
myClaims ,
2020-04-10 14:16:27 +02:00
myChannelClaims ,
2019-04-03 19:12:51 +02:00
byId ,
claimsByUri
} ) ;
} ;
2020-06-17 03:56:51 +02:00
reducers [ CREATE _CHANNEL _STARTED ] = state => _extends$b ( { } , state , {
2019-09-10 20:14:40 +02:00
creatingChannel : true ,
createChannelError : null
2019-08-27 06:42:52 +02:00
} ) ;
2019-04-03 19:12:51 +02:00
reducers [ CREATE _CHANNEL _COMPLETED ] = ( state , action ) => {
return Object . assign ( { } , state , {
2019-08-27 06:42:52 +02:00
creatingChannel : false
2019-04-03 19:12:51 +02:00
} ) ;
} ;
2019-09-10 20:14:40 +02:00
reducers [ CREATE _CHANNEL _FAILED ] = ( state , action ) => {
return Object . assign ( { } , state , {
creatingChannel : false ,
createChannelError : action . data
} ) ;
} ;
2019-04-03 19:12:51 +02:00
2019-09-15 13:00:14 +02:00
reducers [ UPDATE _CHANNEL _STARTED ] = ( state , action ) => {
return Object . assign ( { } , state , {
updateChannelError : '' ,
updatingChannel : true
} ) ;
} ;
2019-07-01 03:16:44 +02:00
reducers [ UPDATE _CHANNEL _COMPLETED ] = ( state , action ) => {
return Object . assign ( { } , state , {
2019-09-15 13:00:14 +02:00
updateChannelError : '' ,
updatingChannel : false
} ) ;
} ;
reducers [ UPDATE _CHANNEL _FAILED ] = ( state , action ) => {
return Object . assign ( { } , state , {
updateChannelError : action . data . message ,
updatingChannel : false
2019-07-01 03:16:44 +02:00
} ) ;
} ;
2019-09-23 17:06:02 +02:00
reducers [ IMPORT _CHANNEL _STARTED ] = state => Object . assign ( { } , state , { pendingChannelImports : true } ) ;
2019-09-12 21:06:49 +02:00
reducers [ IMPORT _CHANNEL _COMPLETED ] = state => Object . assign ( { } , state , { pendingChannelImports : false } ) ;
2019-07-30 17:48:45 +02:00
reducers [ CLAIM _SEARCH _STARTED ] = ( state , action ) => {
const fetchingClaimSearchByQuery = Object . assign ( { } , state . fetchingClaimSearchByQuery ) ;
fetchingClaimSearchByQuery [ action . data . query ] = true ;
2019-06-27 00:01:49 +02:00
2019-06-10 04:45:47 +02:00
return Object . assign ( { } , state , {
2019-07-30 17:48:45 +02:00
fetchingClaimSearchByQuery
2019-06-10 04:45:47 +02:00
} ) ;
} ;
2019-07-30 17:48:45 +02:00
reducers [ CLAIM _SEARCH _COMPLETED ] = ( state , action ) => {
const fetchingClaimSearchByQuery = Object . assign ( { } , state . fetchingClaimSearchByQuery ) ;
const claimSearchByQuery = Object . assign ( { } , state . claimSearchByQuery ) ;
2019-08-13 17:27:32 +02:00
const claimSearchByQueryLastPageReached = Object . assign ( { } , state . claimSearchByQueryLastPageReached ) ;
2019-08-20 22:00:26 +02:00
const { append , query , urls , pageSize } = action . data ;
2019-07-15 04:44:02 +02:00
2019-07-30 17:48:45 +02:00
if ( append ) {
2019-08-20 22:00:26 +02:00
// todo: check for duplicate urls when concatenating?
claimSearchByQuery [ query ] = claimSearchByQuery [ query ] && claimSearchByQuery [ query ] . length ? claimSearchByQuery [ query ] . concat ( urls ) : urls ;
2019-07-16 11:15:51 +02:00
} else {
2019-08-20 22:00:26 +02:00
claimSearchByQuery [ query ] = urls ;
2019-07-16 11:15:51 +02:00
}
2019-07-15 04:44:02 +02:00
2019-08-20 22:00:26 +02:00
// the returned number of urls is less than the page size, so we're on the last page
claimSearchByQueryLastPageReached [ query ] = urls . length < pageSize ;
2019-08-13 17:27:32 +02:00
2019-07-30 17:48:45 +02:00
delete fetchingClaimSearchByQuery [ query ] ;
2020-06-17 03:56:51 +02:00
return Object . assign ( { } , state , _extends$b ( { } , handleClaimAction ( state , action ) , {
2019-07-30 17:48:45 +02:00
claimSearchByQuery ,
2019-08-13 17:27:32 +02:00
claimSearchByQueryLastPageReached ,
2019-07-30 17:48:45 +02:00
fetchingClaimSearchByQuery
} ) ) ;
2019-07-15 04:44:02 +02:00
} ;
2019-07-30 17:48:45 +02:00
reducers [ CLAIM _SEARCH _FAILED ] = ( state , action ) => {
2020-03-31 17:58:31 +02:00
const { query } = action . data ;
const claimSearchByQuery = Object . assign ( { } , state . claimSearchByQuery ) ;
2019-07-30 17:48:45 +02:00
const fetchingClaimSearchByQuery = Object . assign ( { } , state . fetchingClaimSearchByQuery ) ;
2020-03-31 17:58:31 +02:00
delete fetchingClaimSearchByQuery [ query ] ;
claimSearchByQuery [ query ] = null ;
2019-07-15 04:44:02 +02:00
return Object . assign ( { } , state , {
2020-03-31 17:58:31 +02:00
fetchingClaimSearchByQuery ,
claimSearchByQuery
2019-07-15 04:44:02 +02:00
} ) ;
} ;
2020-02-10 16:49:45 +01:00
reducers [ CLAIM _REPOST _STARTED ] = state => {
2020-06-17 03:56:51 +02:00
return _extends$b ( { } , state , {
2020-02-10 16:49:45 +01:00
repostLoading : true ,
repostError : null
} ) ;
} ;
reducers [ CLAIM _REPOST _COMPLETED ] = ( state , action ) => {
const { originalClaimId , repostClaim } = action . data ;
2020-06-17 03:56:51 +02:00
const byId = _extends$b ( { } , state . byId ) ;
const claimsByUri = _extends$b ( { } , state . claimsByUri ) ;
2020-02-10 16:49:45 +01:00
const claimThatWasReposted = byId [ originalClaimId ] ;
2020-06-17 03:56:51 +02:00
const repostStub = _extends$b ( { } , repostClaim , { reposted _claim : claimThatWasReposted } ) ;
2020-02-10 16:49:45 +01:00
byId [ repostStub . claim _id ] = repostStub ;
claimsByUri [ repostStub . permanent _url ] = repostStub . claim _id ;
2020-06-17 03:56:51 +02:00
return _extends$b ( { } , state , {
2020-02-10 16:49:45 +01:00
byId ,
claimsByUri ,
repostLoading : false ,
repostError : null
} ) ;
} ;
reducers [ CLAIM _REPOST _FAILED ] = ( state , action ) => {
const { error } = action . data ;
2020-06-17 03:56:51 +02:00
return _extends$b ( { } , state , {
2020-02-10 16:49:45 +01:00
repostLoading : false ,
repostError : error
} ) ;
} ;
reducers [ CLEAR _REPOST _ERROR ] = state => {
2020-06-17 03:56:51 +02:00
return _extends$b ( { } , state , {
2020-02-10 16:49:45 +01:00
repostError : null
} ) ;
} ;
2020-05-07 13:41:56 +02:00
reducers [ ADD _FILES _REFLECTING ] = ( state , action ) => {
const pendingClaim = action . data ;
const { reflectingById } = state ;
const claimId = pendingClaim && pendingClaim . claim _id ;
reflectingById [ claimId ] = { fileListItem : pendingClaim , progress : 0 , stalled : false } ;
2020-06-17 03:56:51 +02:00
return Object . assign ( { } , state , _extends$b ( { } , state , {
2020-05-07 13:41:56 +02:00
reflectingById : reflectingById
} ) ) ;
} ;
reducers [ UPDATE _FILES _REFLECTING ] = ( state , action ) => {
const newReflectingById = action . data ;
2020-06-17 03:56:51 +02:00
return Object . assign ( { } , state , _extends$b ( { } , state , {
2020-05-07 13:41:56 +02:00
reflectingById : newReflectingById
} ) ) ;
} ;
reducers [ TOGGLE _CHECKING _REFLECTING ] = ( state , action ) => {
const checkingReflecting = action . data ;
2020-06-17 03:56:51 +02:00
return Object . assign ( { } , state , _extends$b ( { } , state , {
2020-05-07 13:41:56 +02:00
checkingReflecting
} ) ) ;
} ;
reducers [ TOGGLE _CHECKING _PENDING ] = ( state , action ) => {
const checking = action . data ;
2020-06-17 03:56:51 +02:00
return Object . assign ( { } , state , _extends$b ( { } , state , {
2020-05-07 13:41:56 +02:00
checkingPending : checking
} ) ) ;
} ;
2020-02-10 16:49:45 +01:00
2020-05-08 22:47:33 +02:00
reducers [ PURCHASE _LIST _STARTED ] = state => {
2020-06-17 03:56:51 +02:00
return _extends$b ( { } , state , {
2020-05-08 22:47:33 +02:00
fetchingMyPurchases : true ,
fetchingMyPurchasesError : null
} ) ;
} ;
reducers [ PURCHASE _LIST _COMPLETED ] = ( state , action ) => {
const { result } = action . data ;
const page = result . page ;
const totalItems = result . total _items ;
let byId = Object . assign ( { } , state . byId ) ;
let byUri = Object . assign ( { } , state . claimsByUri ) ;
let urlsForCurrentPage = [ ] ;
result . items . forEach ( item => {
if ( ! item . claim ) {
// Abandoned claim
return ;
}
const { claim } = item ,
purchaseInfo = _objectWithoutProperties$3 ( item , [ 'claim' ] ) ;
claim . purchase _receipt = purchaseInfo ;
const claimId = claim . claim _id ;
const uri = claim . canonical _url ;
byId [ claimId ] = claim ;
byUri [ uri ] = claimId ;
urlsForCurrentPage . push ( uri ) ;
} ) ;
return Object . assign ( { } , state , {
byId ,
claimsByUri : byUri ,
myPurchases : urlsForCurrentPage ,
myPurchasesPageNumber : page ,
myPurchasesPageTotalResults : totalItems ,
fetchingMyPurchases : false
} ) ;
} ;
reducers [ PURCHASE _LIST _FAILED ] = ( state , action ) => {
const { error } = action . data ;
2020-06-17 03:56:51 +02:00
return _extends$b ( { } , state , {
2020-05-08 22:47:33 +02:00
fetchingMyPurchases : false ,
fetchingMyPurchasesError : error
} ) ;
} ;
2020-05-18 22:40:33 +02:00
reducers [ PURCHASE _URI _COMPLETED ] = ( state , action ) => {
const { uri , purchaseReceipt } = action . data ;
let byId = Object . assign ( { } , state . byId ) ;
let byUri = Object . assign ( { } , state . claimsByUri ) ;
let myPurchases = state . myPurchases ? state . myPurchases . slice ( ) : [ ] ;
const claimId = byUri [ uri ] ;
if ( claimId ) {
let claim = byId [ claimId ] ;
claim . purchase _receipt = purchaseReceipt ;
}
myPurchases . push ( uri ) ;
2020-06-17 03:56:51 +02:00
return _extends$b ( { } , state , {
2020-05-18 22:40:33 +02:00
byId ,
myPurchases ,
purchaseUriSuccess : true
} ) ;
} ;
reducers [ PURCHASE _URI _FAILED ] = state => {
2020-06-17 03:56:51 +02:00
return _extends$b ( { } , state , {
2020-05-18 22:40:33 +02:00
purchaseUriSuccess : false
} ) ;
} ;
2020-05-19 04:13:18 +02:00
reducers [ CLEAR _PURCHASED _URI _SUCCESS ] = state => {
2020-06-17 03:56:51 +02:00
return _extends$b ( { } , state , {
2020-05-19 04:13:18 +02:00
purchaseUriSuccess : false
} ) ;
} ;
2019-04-03 19:12:51 +02:00
function claimsReducer ( state = defaultState , action ) {
const handler = reducers [ action . type ] ;
if ( handler ) return handler ( state , action ) ;
return state ;
}
2020-06-29 23:02:19 +02:00
// 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 ;
} ;
2020-06-17 03:56:51 +02:00
var _extends$c = Object . assign || function ( target ) { for ( var i = 1 ; i < arguments . length ; i ++ ) { var source = arguments [ i ] ; for ( var key in source ) { if ( Object . prototype . hasOwnProperty . call ( source , key ) ) { target [ key ] = source [ key ] ; } } } return target ; } ;
2019-05-21 21:18:07 +02:00
2020-06-23 20:48:30 +02:00
const defaultState$1 = {
2020-06-29 23:02:19 +02:00
commentById : { } , // commentId -> Comment
byId : { } , // ClaimID -> list of comments
commentsByUri : { } , // URI -> claimId
isLoading : false ,
myComments : undefined
} ;
const commentReducer = handleActions ( {
[ COMMENT _CREATE _STARTED ] : ( state , action ) => _extends$c ( { } , state , {
isLoading : true
} ) ,
[ COMMENT _CREATE _FAILED ] : ( state , action ) => _extends$c ( { } , state , {
isLoading : false
} ) ,
[ COMMENT _CREATE _COMPLETED ] : ( state , action ) => {
const { comment , claimId } = action . data ;
const commentById = Object . assign ( { } , state . commentById ) ;
const byId = Object . assign ( { } , state . byId ) ;
const comments = byId [ claimId ] ;
const newCommentIds = comments . slice ( ) ;
// add the comment by its ID
commentById [ comment . comment _id ] = comment ;
// push the comment_id to the top of ID list
newCommentIds . unshift ( comment . comment _id ) ;
byId [ claimId ] = newCommentIds ;
return _extends$c ( { } , state , {
commentById ,
byId ,
isLoading : false
} ) ;
} ,
[ COMMENT _LIST _STARTED ] : state => _extends$c ( { } , state , { isLoading : true } ) ,
[ COMMENT _LIST _COMPLETED ] : ( state , action ) => {
const { comments , claimId , uri } = action . data ;
const commentById = Object . assign ( { } , state . commentById ) ;
const byId = Object . assign ( { } , state . byId ) ;
const commentsByUri = Object . assign ( { } , state . commentsByUri ) ;
if ( comments ) {
// we use an Array to preserve order of listing
// in reality this doesn't matter and we can just
// sort comments by their timestamp
const commentIds = Array ( comments . length ) ;
// map the comment_ids to the new comments
for ( let i = 0 ; i < comments . length ; i ++ ) {
commentIds [ i ] = comments [ i ] . comment _id ;
commentById [ commentIds [ i ] ] = comments [ i ] ;
}
byId [ claimId ] = commentIds ;
commentsByUri [ uri ] = claimId ;
}
return _extends$c ( { } , state , {
byId ,
commentById ,
commentsByUri ,
isLoading : false
} ) ;
} ,
[ COMMENT _LIST _FAILED ] : ( state , action ) => _extends$c ( { } , state , {
isLoading : false
} ) ,
[ COMMENT _ABANDON _STARTED ] : ( state , action ) => _extends$c ( { } , state , {
isLoading : true
} ) ,
[ COMMENT _ABANDON _COMPLETED ] : ( state , action ) => {
const { comment _id } = action . data ;
const commentById = Object . assign ( { } , state . commentById ) ;
const byId = Object . assign ( { } , state . byId ) ;
// to remove the comment and its references
const claimId = commentById [ comment _id ] . claim _id ;
for ( let i = 0 ; i < byId [ claimId ] . length ; i ++ ) {
if ( byId [ claimId ] [ i ] === comment _id ) {
byId [ claimId ] . splice ( i , 1 ) ;
break ;
}
}
delete commentById [ comment _id ] ;
return _extends$c ( { } , state , {
commentById ,
byId ,
isLoading : false
} ) ;
} ,
// do nothing
[ COMMENT _ABANDON _FAILED ] : ( state , action ) => _extends$c ( { } , state , {
isLoading : false
} ) ,
// do nothing
[ COMMENT _UPDATE _STARTED ] : ( state , action ) => _extends$c ( { } , state , {
isLoading : true
} ) ,
// replace existing comment with comment returned here under its comment_id
[ COMMENT _UPDATE _COMPLETED ] : ( state , action ) => {
const { comment } = action . data ;
const commentById = Object . assign ( { } , state . commentById ) ;
commentById [ comment . comment _id ] = comment ;
return _extends$c ( { } , state , {
commentById ,
isLoading : false
} ) ;
} ,
// nothing can be done here
[ COMMENT _UPDATE _FAILED ] : ( state , action ) => _extends$c ( { } , state , {
isLoading : false
} ) ,
// nothing can really be done here
[ COMMENT _HIDE _STARTED ] : ( state , action ) => _extends$c ( { } , state , {
isLoading : true
} ) ,
[ COMMENT _HIDE _COMPLETED ] : ( state , action ) => _extends$c ( { } , state , { // todo: add HiddenComments state & create selectors
isLoading : false
} ) ,
// nothing can be done here
[ COMMENT _HIDE _FAILED ] : ( state , action ) => _extends$c ( { } , state , {
isLoading : false
} )
} , defaultState$1 ) ;
var _extends$d = Object . assign || function ( target ) { for ( var i = 1 ; i < arguments . length ; i ++ ) { var source = arguments [ i ] ; for ( var key in source ) { if ( Object . prototype . hasOwnProperty . call ( source , key ) ) { target [ key ] = source [ key ] ; } } } return target ; } ;
const reducers$1 = { } ;
const defaultState$2 = {
2019-07-01 21:49:51 +02:00
positions : { }
} ;
reducers$1 [ SET _CONTENT _POSITION ] = ( state , action ) => {
const { claimId , outpoint , position } = action . data ;
2020-06-29 23:02:19 +02:00
return _extends$d ( { } , state , {
positions : _extends$d ( { } , state . positions , {
[ claimId ] : _extends$d ( { } , state . positions [ claimId ] , {
2019-07-01 21:49:51 +02:00
[ outpoint ] : position
} )
} )
2019-05-21 21:18:07 +02:00
} ) ;
} ;
2020-06-29 23:02:19 +02:00
function contentReducer ( state = defaultState$2 , action ) {
2019-05-21 21:18:07 +02:00
const handler = reducers$1 [ action . type ] ;
if ( handler ) return handler ( state , action ) ;
return state ;
}
const reducers$2 = { } ;
2020-06-29 23:02:19 +02:00
const defaultState$3 = {
2019-04-03 19:12:51 +02:00
fileListPublishedSort : DATE _NEW ,
fileListDownloadedSort : DATE _NEW
} ;
2019-05-21 21:18:07 +02:00
reducers$2 [ FILE _LIST _STARTED ] = state => Object . assign ( { } , state , {
2019-04-03 19:12:51 +02:00
isFetchingFileList : true
} ) ;
2019-05-21 21:18:07 +02:00
reducers$2 [ FILE _LIST _SUCCEEDED ] = ( state , action ) => {
2019-04-03 19:12:51 +02:00
const { fileInfos } = action . data ;
const newByOutpoint = Object . assign ( { } , state . byOutpoint ) ;
const pendingByOutpoint = Object . assign ( { } , state . pendingByOutpoint ) ;
fileInfos . forEach ( fileInfo => {
const { outpoint } = fileInfo ;
if ( outpoint ) newByOutpoint [ fileInfo . outpoint ] = fileInfo ;
} ) ;
return Object . assign ( { } , state , {
isFetchingFileList : false ,
byOutpoint : newByOutpoint ,
pendingByOutpoint
} ) ;
} ;
2019-05-21 21:18:07 +02:00
reducers$2 [ FETCH _FILE _INFO _STARTED ] = ( state , action ) => {
2019-04-03 19:12:51 +02:00
const { outpoint } = action . data ;
const newFetching = Object . assign ( { } , state . fetching ) ;
newFetching [ outpoint ] = true ;
return Object . assign ( { } , state , {
fetching : newFetching
} ) ;
} ;
2019-05-21 21:18:07 +02:00
reducers$2 [ FETCH _FILE _INFO _COMPLETED ] = ( state , action ) => {
2019-04-03 19:12:51 +02:00
const { fileInfo , outpoint } = action . data ;
const newByOutpoint = Object . assign ( { } , state . byOutpoint ) ;
const newFetching = Object . assign ( { } , state . fetching ) ;
newByOutpoint [ outpoint ] = fileInfo ;
delete newFetching [ outpoint ] ;
return Object . assign ( { } , state , {
byOutpoint : newByOutpoint ,
fetching : newFetching
} ) ;
} ;
2019-08-13 19:33:32 +02:00
reducers$2 [ FETCH _FILE _INFO _FAILED ] = ( state , action ) => {
const { outpoint } = action . data ;
const newFetching = Object . assign ( { } , state . fetching ) ;
delete newFetching [ outpoint ] ;
return Object . assign ( { } , state , {
fetching : newFetching
} ) ;
} ;
2019-05-21 21:18:07 +02:00
reducers$2 [ DOWNLOADING _STARTED ] = ( state , action ) => {
2019-04-03 19:12:51 +02:00
const { uri , outpoint , fileInfo } = action . data ;
const newByOutpoint = Object . assign ( { } , state . byOutpoint ) ;
const newDownloading = Object . assign ( { } , state . downloadingByOutpoint ) ;
newDownloading [ outpoint ] = true ;
newByOutpoint [ outpoint ] = fileInfo ;
return Object . assign ( { } , state , {
downloadingByOutpoint : newDownloading ,
byOutpoint : newByOutpoint
} ) ;
} ;
2019-05-21 21:18:07 +02:00
reducers$2 [ DOWNLOADING _PROGRESSED ] = ( state , action ) => {
2019-04-03 19:12:51 +02:00
const { outpoint , fileInfo } = action . data ;
const newByOutpoint = Object . assign ( { } , state . byOutpoint ) ;
const newDownloading = Object . assign ( { } , state . downloadingByOutpoint ) ;
newByOutpoint [ outpoint ] = fileInfo ;
newDownloading [ outpoint ] = true ;
return Object . assign ( { } , state , {
byOutpoint : newByOutpoint ,
downloadingByOutpoint : newDownloading
} ) ;
} ;
2019-05-21 21:18:07 +02:00
reducers$2 [ DOWNLOADING _CANCELED ] = ( state , action ) => {
2019-08-02 08:21:28 +02:00
const { uri , outpoint } = action . data ;
2019-04-03 19:12:51 +02:00
const newDownloading = Object . assign ( { } , state . downloadingByOutpoint ) ;
delete newDownloading [ outpoint ] ;
return Object . assign ( { } , state , {
downloadingByOutpoint : newDownloading
} ) ;
} ;
2019-05-21 21:18:07 +02:00
reducers$2 [ DOWNLOADING _COMPLETED ] = ( state , action ) => {
2019-04-03 19:12:51 +02:00
const { outpoint , fileInfo } = action . data ;
const newByOutpoint = Object . assign ( { } , state . byOutpoint ) ;
const newDownloading = Object . assign ( { } , state . downloadingByOutpoint ) ;
newByOutpoint [ outpoint ] = fileInfo ;
delete newDownloading [ outpoint ] ;
return Object . assign ( { } , state , {
byOutpoint : newByOutpoint ,
downloadingByOutpoint : newDownloading
} ) ;
} ;
2019-05-21 21:18:07 +02:00
reducers$2 [ FILE _DELETE ] = ( state , action ) => {
2019-04-03 19:12:51 +02:00
const { outpoint } = action . data ;
const newByOutpoint = Object . assign ( { } , state . byOutpoint ) ;
const downloadingByOutpoint = Object . assign ( { } , state . downloadingByOutpoint ) ;
delete newByOutpoint [ outpoint ] ;
delete downloadingByOutpoint [ outpoint ] ;
return Object . assign ( { } , state , {
byOutpoint : newByOutpoint ,
downloadingByOutpoint
} ) ;
} ;
2019-05-21 21:18:07 +02:00
reducers$2 [ SET _FILE _LIST _SORT ] = ( state , action ) => {
2019-04-03 19:12:51 +02:00
const pageSortStates = {
[ PUBLISHED ] : 'fileListPublishedSort' ,
[ DOWNLOADED ] : 'fileListDownloadedSort'
} ;
const pageSortState = pageSortStates [ action . data . page ] ;
const { value } = action . data ;
return Object . assign ( { } , state , {
[ pageSortState ] : value
} ) ;
} ;
2020-06-29 23:02:19 +02:00
function fileInfoReducer ( state = defaultState$3 , action ) {
2019-05-21 21:18:07 +02:00
const handler = reducers$2 [ action . type ] ;
2019-04-03 19:12:51 +02:00
if ( handler ) return handler ( state , action ) ;
return state ;
}
2020-06-29 23:02:19 +02:00
var _extends$e = Object . assign || function ( target ) { for ( var i = 1 ; i < arguments . length ; i ++ ) { var source = arguments [ i ] ; for ( var key in source ) { if ( Object . prototype . hasOwnProperty . call ( source , key ) ) { target [ key ] = source [ key ] ; } } } return target ; } ;
2020-06-23 20:48:30 +02:00
2020-06-29 23:02:19 +02:00
const defaultState$4 = {
2019-04-03 19:12:51 +02:00
notifications : [ ] ,
toasts : [ ] ,
errors : [ ]
} ;
const notificationsReducer = handleActions ( {
// Toasts
[ CREATE _TOAST ] : ( state , action ) => {
const toast = action . data ;
const newToasts = state . toasts . slice ( ) ;
newToasts . push ( toast ) ;
2020-06-29 23:02:19 +02:00
return _extends$e ( { } , state , {
2019-04-03 19:12:51 +02:00
toasts : newToasts
} ) ;
} ,
[ DISMISS _TOAST ] : state => {
const newToasts = state . toasts . slice ( ) ;
newToasts . shift ( ) ;
2020-06-29 23:02:19 +02:00
return _extends$e ( { } , 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 ) ;
2020-06-29 23:02:19 +02:00
return _extends$e ( { } , 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 ) ;
2020-06-29 23:02:19 +02:00
return _extends$e ( { } , 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 ) ;
2020-06-29 23:02:19 +02:00
return _extends$e ( { } , 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 ) ;
2020-06-29 23:02:19 +02:00
return _extends$e ( { } , state , {
2019-04-03 19:12:51 +02:00
errors : newErrors
} ) ;
} ,
[ DISMISS _ERROR ] : state => {
const newErrors = state . errors . slice ( ) ;
newErrors . shift ( ) ;
2020-06-29 23:02:19 +02:00
return _extends$e ( { } , state , {
2019-04-03 19:12:51 +02:00
errors : newErrors
} ) ;
}
2020-06-29 23:02:19 +02:00
} , defaultState$4 ) ;
2019-07-01 21:49:51 +02:00
2020-06-29 23:02:19 +02:00
var _extends$f = Object . assign || function ( target ) { for ( var i = 1 ; i < arguments . length ; i ++ ) { var source = arguments [ i ] ; for ( var key in source ) { if ( Object . prototype . hasOwnProperty . call ( source , key ) ) { target [ key ] = source [ key ] ; } } } return target ; } ;
2019-07-01 21:49:51 +02:00
2020-05-08 22:47:33 +02:00
function _objectWithoutProperties$4 ( obj , keys ) { var target = { } ; for ( var i in obj ) { if ( keys . indexOf ( i ) >= 0 ) continue ; if ( ! Object . prototype . hasOwnProperty . call ( obj , i ) ) continue ; target [ i ] = obj [ i ] ; } return target ; }
2019-07-01 21:49:51 +02:00
2020-06-29 23:02:19 +02:00
const defaultState$5 = {
2019-07-01 21:49:51 +02:00
editingURI : undefined ,
2020-06-29 23:43:49 +02:00
fileText : '' ,
2019-07-01 21:49:51 +02:00
filePath : undefined ,
2020-03-31 16:05:12 +02:00
fileDur : 0 ,
fileSize : 0 ,
fileVid : false ,
2019-07-01 21:49:51 +02:00
contentIsFree : true ,
fee : {
amount : 1 ,
currency : 'LBC'
} ,
title : '' ,
thumbnail _url : '' ,
thumbnailPath : '' ,
uploadThumbnailStatus : API _DOWN ,
description : '' ,
2020-01-15 01:17:25 +01:00
language : '' ,
2019-07-01 21:49:51 +02:00
nsfw : false ,
channel : CHANNEL _ANONYMOUS ,
channelId : '' ,
name : '' ,
nameError : undefined ,
bid : 0.1 ,
bidError : undefined ,
licenseType : 'None' ,
otherLicenseDescription : 'All rights reserved' ,
licenseUrl : '' ,
2019-07-05 04:20:56 +02:00
tags : [ ] ,
2019-07-01 21:49:51 +02:00
publishing : false ,
publishSuccess : false ,
2020-03-02 07:28:36 +01:00
publishError : undefined ,
2020-06-23 20:48:30 +02:00
optimize : false ,
useLBRYUploader : false
2019-07-01 21:49:51 +02:00
} ;
const publishReducer = handleActions ( {
[ UPDATE _PUBLISH _FORM ] : ( state , action ) => {
const { data } = action ;
2020-06-29 23:02:19 +02:00
return _extends$f ( { } , state , data ) ;
2019-07-01 21:49:51 +02:00
} ,
2020-06-29 23:02:19 +02:00
[ CLEAR _PUBLISH ] : state => _extends$f ( { } , defaultState$5 , {
2020-03-31 16:05:12 +02:00
bid : state . bid ,
optimize : state . optimize
2020-03-02 07:28:36 +01:00
} ) ,
2020-06-29 23:02:19 +02:00
[ PUBLISH _START ] : state => _extends$f ( { } , state , {
2019-07-01 21:49:51 +02:00
publishing : true ,
publishSuccess : false
} ) ,
2020-06-29 23:02:19 +02:00
[ PUBLISH _FAIL ] : state => _extends$f ( { } , state , {
2019-07-01 21:49:51 +02:00
publishing : false
} ) ,
2020-06-29 23:02:19 +02:00
[ PUBLISH _SUCCESS ] : state => _extends$f ( { } , state , {
2019-07-01 21:49:51 +02:00
publishing : false ,
publishSuccess : true
} ) ,
[ DO _PREPARE _EDIT ] : ( state , action ) => {
2020-05-08 22:47:33 +02:00
const publishData = _objectWithoutProperties$4 ( action . data , [ ] ) ;
2019-07-01 21:49:51 +02:00
const { channel , name , uri } = publishData ;
// The short uri is what is presented to the user
// The editingUri is the full uri with claim id
const shortUri = buildURI ( {
channelName : channel ,
2019-08-28 01:59:04 +02:00
streamName : name
2019-07-01 21:49:51 +02:00
} ) ;
2020-06-29 23:02:19 +02:00
return _extends$f ( { } , defaultState$5 , publishData , {
2019-07-01 21:49:51 +02:00
editingURI : uri ,
uri : shortUri
} ) ;
}
2020-06-29 23:02:19 +02:00
} , defaultState$5 ) ;
2019-04-03 19:12:51 +02:00
2020-06-29 23:02:19 +02:00
var _extends$g = 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
2020-06-29 23:02:19 +02:00
const defaultState$6 = {
2019-04-03 19:12:51 +02:00
isActive : false , // does the user have any typed text in the search input
focused : false , // is the search input focused
searchQuery : '' , // needs to be an empty string for input focusing
options : {
[ SEARCH _OPTIONS . RESULT _COUNT ] : 30 ,
[ SEARCH _OPTIONS . CLAIM _TYPE ] : SEARCH _OPTIONS . INCLUDE _FILES _AND _CHANNELS ,
[ SEARCH _OPTIONS . MEDIA _AUDIO ] : true ,
[ SEARCH _OPTIONS . MEDIA _VIDEO ] : true ,
[ SEARCH _OPTIONS . MEDIA _TEXT ] : true ,
[ SEARCH _OPTIONS . MEDIA _IMAGE ] : true ,
[ SEARCH _OPTIONS . MEDIA _APPLICATION ] : true
} ,
suggestions : { } ,
2020-01-22 02:04:50 +01:00
urisByQuery : { } ,
resolvedResultsByQuery : { } ,
resolvedResultsByQueryLastPageReached : { }
2019-04-03 19:12:51 +02:00
} ;
const searchReducer = handleActions ( {
2020-06-29 23:02:19 +02:00
[ SEARCH _START ] : state => _extends$g ( { } , state , {
2019-04-03 19:12:51 +02:00
searching : true
} ) ,
[ SEARCH _SUCCESS ] : ( state , action ) => {
const { query , uris } = action . data ;
2020-06-29 23:02:19 +02:00
return _extends$g ( { } , state , {
2019-04-03 19:12:51 +02:00
searching : false ,
urisByQuery : Object . assign ( { } , state . urisByQuery , { [ query ] : uris } )
} ) ;
} ,
2020-06-29 23:02:19 +02:00
[ SEARCH _FAIL ] : state => _extends$g ( { } , state , {
2019-04-03 19:12:51 +02:00
searching : false
} ) ,
2020-06-29 23:02:19 +02:00
[ RESOLVED _SEARCH _START ] : state => _extends$g ( { } , state , {
2020-01-22 02:04:50 +01:00
searching : true
} ) ,
[ RESOLVED _SEARCH _SUCCESS ] : ( state , action ) => {
const resolvedResultsByQuery = Object . assign ( { } , state . resolvedResultsByQuery ) ;
const resolvedResultsByQueryLastPageReached = Object . assign ( { } , state . resolvedResultsByQueryLastPageReached ) ;
const { append , query , results , pageSize } = action . data ;
if ( append ) {
// todo: check for duplicates when concatenating?
resolvedResultsByQuery [ query ] = resolvedResultsByQuery [ query ] && resolvedResultsByQuery [ query ] . length ? resolvedResultsByQuery [ query ] . concat ( results ) : results ;
} else {
resolvedResultsByQuery [ query ] = results ;
}
// the returned number of urls is less than the page size, so we're on the last page
resolvedResultsByQueryLastPageReached [ query ] = results . length < pageSize ;
2020-06-29 23:02:19 +02:00
return _extends$g ( { } , state , {
2020-01-22 02:04:50 +01:00
searching : false ,
resolvedResultsByQuery ,
resolvedResultsByQueryLastPageReached
} ) ;
} ,
2020-06-29 23:02:19 +02:00
[ RESOLVED _SEARCH _FAIL ] : state => _extends$g ( { } , state , {
2020-01-22 02:04:50 +01:00
searching : false
} ) ,
2020-06-29 23:02:19 +02:00
[ UPDATE _SEARCH _QUERY ] : ( state , action ) => _extends$g ( { } , state , {
2019-04-03 19:12:51 +02:00
searchQuery : action . data . query ,
isActive : true
} ) ,
2020-06-29 23:02:19 +02:00
[ UPDATE _SEARCH _SUGGESTIONS ] : ( state , action ) => _extends$g ( { } , state , {
suggestions : _extends$g ( { } , 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
2020-06-29 23:02:19 +02:00
[ DISMISS _NOTIFICATION ] : state => _extends$g ( { } , state , {
2019-04-03 19:12:51 +02:00
isActive : false
} ) ,
2020-06-29 23:02:19 +02:00
[ SEARCH _FOCUS ] : state => _extends$g ( { } , state , {
2019-04-03 19:12:51 +02:00
focused : true
} ) ,
2020-06-29 23:02:19 +02:00
[ SEARCH _BLUR ] : state => _extends$g ( { } , state , {
2019-04-03 19:12:51 +02:00
focused : false
} ) ,
[ UPDATE _SEARCH _OPTIONS ] : ( state , action ) => {
const { options : oldOptions } = state ;
const newOptions = action . data ;
2020-06-29 23:02:19 +02:00
const options = _extends$g ( { } , oldOptions , newOptions ) ;
return _extends$g ( { } , state , {
2019-04-03 19:12:51 +02:00
options
} ) ;
}
2020-06-29 23:02:19 +02:00
} , defaultState$6 ) ;
2019-07-01 21:49:51 +02:00
2020-06-29 23:02:19 +02:00
var _extends$h = Object . assign || function ( target ) { for ( var i = 1 ; i < arguments . length ; i ++ ) { var source = arguments [ i ] ; for ( var key in source ) { if ( Object . prototype . hasOwnProperty . call ( source , key ) ) { target [ key ] = source [ key ] ; } } } return target ; } ;
2019-07-01 21:49:51 +02:00
2019-07-02 22:33:57 +02:00
function getDefaultKnownTags ( ) {
2020-06-29 23:02:19 +02:00
return DEFAULT _FOLLOWED _TAGS . concat ( DEFAULT _KNOWN _TAGS ) . reduce ( ( tagsMap , tag ) => _extends$h ( { } , tagsMap , {
2019-07-02 22:33:57 +02:00
[ tag ] : { name : tag }
} ) , { } ) ;
}
2020-06-29 23:02:19 +02:00
const defaultState$7 = {
2020-03-16 21:29:52 +01:00
followedTags : [ ] ,
2019-07-02 22:33:57 +02:00
knownTags : getDefaultKnownTags ( )
} ;
const tagsReducer = handleActions ( {
2019-07-01 21:49:51 +02:00
[ TOGGLE _TAG _FOLLOW ] : ( state , action ) => {
const { followedTags } = state ;
const { name } = action . data ;
let newFollowedTags = followedTags . slice ( ) ;
if ( newFollowedTags . includes ( name ) ) {
newFollowedTags = newFollowedTags . filter ( tag => tag !== name ) ;
} else {
newFollowedTags . push ( name ) ;
}
2020-06-29 23:02:19 +02:00
return _extends$h ( { } , state , {
2019-07-01 21:49:51 +02:00
followedTags : newFollowedTags
} ) ;
} ,
[ TAG _ADD ] : ( state , action ) => {
const { knownTags } = state ;
const { name } = action . data ;
2020-06-29 23:02:19 +02:00
let newKnownTags = _extends$h ( { } , knownTags ) ;
2019-07-01 21:49:51 +02:00
newKnownTags [ name ] = { name } ;
2020-06-29 23:02:19 +02:00
return _extends$h ( { } , state , {
2019-07-01 21:49:51 +02:00
knownTags : newKnownTags
} ) ;
} ,
[ TAG _DELETE ] : ( state , action ) => {
const { knownTags , followedTags } = state ;
const { name } = action . data ;
2020-06-29 23:02:19 +02:00
let newKnownTags = _extends$h ( { } , knownTags ) ;
2019-07-01 21:49:51 +02:00
delete newKnownTags [ name ] ;
const newFollowedTags = followedTags . filter ( tag => tag !== name ) ;
2020-06-29 23:02:19 +02:00
return _extends$h ( { } , state , {
2019-07-01 21:49:51 +02:00
knownTags : newKnownTags ,
followedTags : newFollowedTags
} ) ;
2019-09-09 20:57:56 +02:00
} ,
2019-09-13 21:52:52 +02:00
[ USER _STATE _POPULATE ] : ( state , action ) => {
2019-09-10 20:14:40 +02:00
const { tags } = action . data ;
2020-03-16 21:29:52 +01:00
if ( Array . isArray ( tags ) ) {
2020-06-29 23:02:19 +02:00
return _extends$h ( { } , state , {
2020-03-16 21:29:52 +01:00
followedTags : tags
} ) ;
}
2020-06-29 23:02:19 +02:00
return _extends$h ( { } , state ) ;
2019-08-02 02:57:27 +02:00
}
2020-06-29 23:02:19 +02:00
} , defaultState$7 ) ;
2019-08-02 02:57:27 +02:00
2020-06-29 23:02:19 +02:00
var _extends$i = 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 defaultState$8 = {
blockedChannels : [ ]
} ;
const blockedReducer = handleActions ( {
[ TOGGLE _BLOCK _CHANNEL ] : ( state , action ) => {
const { blockedChannels } = state ;
const { uri } = action . data ;
let newBlockedChannels = blockedChannels . slice ( ) ;
if ( newBlockedChannels . includes ( uri ) ) {
newBlockedChannels = newBlockedChannels . filter ( id => id !== uri ) ;
} else {
newBlockedChannels . push ( uri ) ;
}
return {
blockedChannels : newBlockedChannels
} ;
} ,
[ USER _STATE _POPULATE ] : ( state , action ) => {
const { blocked } = action . data ;
return _extends$i ( { } , state , {
blockedChannels : blocked && blocked . length ? blocked : state . blockedChannels
} ) ;
}
} , defaultState$8 ) ;
var _extends$j = 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
2020-06-29 23:02:19 +02:00
const defaultState$9 = {
2019-04-03 19:12:51 +02:00
balance : undefined ,
2019-04-18 09:56:16 +02:00
totalBalance : undefined ,
2019-09-24 00:56:53 +02:00
reservedBalance : undefined ,
claimsBalance : undefined ,
supportsBalance : undefined ,
tipsBalance : undefined ,
2019-04-03 19:12:51 +02:00
latestBlock : undefined ,
transactions : { } ,
fetchingTransactions : false ,
2020-04-10 14:16:27 +02:00
fetchingTransactionsError : undefined ,
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 ,
2019-12-18 17:47:18 +01:00
transactionListFilter : 'all' ,
2020-03-25 03:46:35 +01:00
walletReconnecting : false ,
2020-04-10 14:16:27 +02:00
txoFetchParams : { } ,
txoPage : { } ,
fetchingTxos : false ,
fetchingTxosError : undefined ,
2020-04-01 20:26:38 +02:00
pendingSupportTransactions : { } ,
abandonClaimSupportError : undefined
2019-04-03 19:12:51 +02:00
} ;
2019-05-10 07:02:03 +02:00
const walletReducer = handleActions ( {
2020-06-29 23:02:19 +02:00
[ FETCH _TRANSACTIONS _STARTED ] : state => _extends$j ( { } , state , {
2019-05-10 07:02:03 +02:00
fetchingTransactions : true
} ) ,
2019-04-03 19:12:51 +02:00
2019-05-10 07:02:03 +02:00
[ FETCH _TRANSACTIONS _COMPLETED ] : ( state , action ) => {
2020-06-29 23:02:19 +02:00
const byId = _extends$j ( { } , 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
2020-06-29 23:02:19 +02:00
return _extends$j ( { } , state , {
2019-05-10 07:02:03 +02:00
transactions : byId ,
fetchingTransactions : false
} ) ;
} ,
2019-04-03 19:12:51 +02:00
2020-04-10 14:16:27 +02:00
[ FETCH _TXO _PAGE _STARTED ] : state => {
2020-06-29 23:02:19 +02:00
return _extends$j ( { } , state , {
2020-04-10 14:16:27 +02:00
fetchingTxos : true ,
fetchingTxosError : undefined
} ) ;
} ,
[ FETCH _TXO _PAGE _COMPLETED ] : ( state , action ) => {
2020-06-29 23:02:19 +02:00
return _extends$j ( { } , state , {
2020-04-10 14:16:27 +02:00
txoPage : action . data ,
fetchingTxos : false
} ) ;
} ,
[ FETCH _TXO _PAGE _FAILED ] : ( state , action ) => {
2020-06-29 23:02:19 +02:00
return _extends$j ( { } , state , {
2020-04-10 14:16:27 +02:00
txoPage : { } ,
fetchingTxos : false ,
fetchingTxosError : action . data
} ) ;
} ,
[ UPDATE _TXO _FETCH _PARAMS ] : ( state , action ) => {
2020-06-29 23:02:19 +02:00
return _extends$j ( { } , state , {
2020-04-10 14:16:27 +02:00
txoFetchParams : action . data
} ) ;
} ,
2020-06-29 23:02:19 +02:00
[ FETCH _SUPPORTS _STARTED ] : state => _extends$j ( { } , state , {
2019-05-10 07:02:03 +02:00
fetchingSupports : true
} ) ,
2019-04-03 19:12:51 +02:00
2019-05-10 07:02:03 +02:00
[ FETCH _SUPPORTS _COMPLETED ] : ( state , action ) => {
2019-05-14 06:50:21 +02:00
const byOutpoint = state . supports ;
2019-05-10 07:02:03 +02:00
const { supports } = action . data ;
2019-04-03 19:12:51 +02:00
2019-05-14 06:50:21 +02:00
supports . forEach ( transaction => {
const { txid , nout } = transaction ;
byOutpoint [ ` ${ txid } : ${ nout } ` ] = transaction ;
2019-05-10 07:02:03 +02:00
} ) ;
2019-04-03 19:12:51 +02:00
2020-06-29 23:02:19 +02:00
return _extends$j ( { } , 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
2020-06-29 23:02:19 +02:00
return _extends$j ( { } , 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
2020-06-29 23:02:19 +02:00
return _extends$j ( { } , 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
2020-04-01 20:26:38 +02:00
[ ABANDON _CLAIM _SUPPORT _STARTED ] : ( state , action ) => {
2020-06-29 23:02:19 +02:00
return _extends$j ( { } , state , {
2020-04-01 20:26:38 +02:00
abandonClaimSupportError : undefined
} ) ;
} ,
2020-04-01 20:36:11 +02:00
[ ABANDON _CLAIM _SUPPORT _PREVIEW ] : ( state , action ) => {
2020-06-29 23:02:19 +02:00
return _extends$j ( { } , state , {
2020-04-01 20:36:11 +02:00
abandonClaimSupportError : undefined
} ) ;
} ,
2020-03-25 03:46:35 +01:00
[ ABANDON _CLAIM _SUPPORT _COMPLETED ] : ( state , action ) => {
const { claimId , type , txid , effective } = action . data ;
const pendingtxs = Object . assign ( { } , state . pendingSupportTransactions ) ;
pendingtxs [ claimId ] = { txid , type , effective } ;
2020-06-29 23:02:19 +02:00
return _extends$j ( { } , state , {
2020-04-01 20:26:38 +02:00
pendingSupportTransactions : pendingtxs ,
abandonClaimSupportError : undefined
} ) ;
} ,
[ ABANDON _CLAIM _SUPPORT _FAILED ] : ( state , action ) => {
2020-06-29 23:02:19 +02:00
return _extends$j ( { } , state , {
2020-04-01 20:26:38 +02:00
abandonClaimSupportError : action . data
2020-03-25 03:46:35 +01:00
} ) ;
} ,
[ PENDING _SUPPORTS _UPDATED ] : ( state , action ) => {
2020-06-29 23:02:19 +02:00
return _extends$j ( { } , state , {
2020-03-25 03:46:35 +01:00
pendingSupportTransactions : action . data
} ) ;
} ,
2020-06-29 23:02:19 +02:00
[ GET _NEW _ADDRESS _STARTED ] : state => _extends$j ( { } , state , {
2019-05-10 07:02:03 +02:00
gettingNewAddress : true
} ) ,
2019-04-03 19:12:51 +02:00
2019-05-10 07:02:03 +02:00
[ GET _NEW _ADDRESS _COMPLETED ] : ( state , action ) => {
const { address } = action . data ;
2019-04-03 19:12:51 +02:00
2020-06-29 23:02:19 +02:00
return _extends$j ( { } , state , { gettingNewAddress : false , receiveAddress : address } ) ;
2019-05-10 07:02:03 +02:00
} ,
2019-04-03 19:12:51 +02:00
2020-06-29 23:02:19 +02:00
[ UPDATE _BALANCE ] : ( state , action ) => _extends$j ( { } , state , {
2019-09-24 00:56:53 +02:00
totalBalance : action . data . totalBalance ,
balance : action . data . balance ,
reservedBalance : action . data . reservedBalance ,
claimsBalance : action . data . claimsBalance ,
supportsBalance : action . data . supportsBalance ,
tipsBalance : action . data . tipsBalance
2019-05-10 07:02:03 +02:00
} ) ,
2019-04-03 19:12:51 +02:00
2020-06-29 23:02:19 +02:00
[ CHECK _ADDRESS _IS _MINE _STARTED ] : state => _extends$j ( { } , state , {
2019-05-10 07:02:03 +02:00
checkingAddressOwnership : true
} ) ,
2019-04-03 19:12:51 +02:00
2020-06-29 23:02:19 +02:00
[ CHECK _ADDRESS _IS _MINE _COMPLETED ] : state => _extends$j ( { } , state , {
2019-05-10 07:02:03 +02:00
checkingAddressOwnership : false
} ) ,
2019-04-03 19:12:51 +02:00
2019-05-10 07:02:03 +02:00
[ SET _DRAFT _TRANSACTION _AMOUNT ] : ( state , action ) => {
const oldDraft = state . draftTransaction ;
2020-06-29 23:02:19 +02:00
const newDraft = _extends$j ( { } , oldDraft , { amount : parseFloat ( action . data . amount ) } ) ;
2019-04-03 19:12:51 +02:00
2020-06-29 23:02:19 +02:00
return _extends$j ( { } , state , { draftTransaction : newDraft } ) ;
2019-05-10 07:02:03 +02:00
} ,
2019-04-03 19:12:51 +02:00
2019-05-10 07:02:03 +02:00
[ SET _DRAFT _TRANSACTION _ADDRESS ] : ( state , action ) => {
const oldDraft = state . draftTransaction ;
2020-06-29 23:02:19 +02:00
const newDraft = _extends$j ( { } , oldDraft , { address : action . data . address } ) ;
2019-04-03 19:12:51 +02:00
2020-06-29 23:02:19 +02:00
return _extends$j ( { } , state , { draftTransaction : newDraft } ) ;
2019-05-10 07:02:03 +02:00
} ,
2019-04-03 19:12:51 +02:00
2019-05-10 07:02:03 +02:00
[ SEND _TRANSACTION _STARTED ] : state => {
2020-06-29 23:02:19 +02:00
const newDraftTransaction = _extends$j ( { } , state . draftTransaction , { sending : true } ) ;
2019-04-03 19:12:51 +02:00
2020-06-29 23:02:19 +02:00
return _extends$j ( { } , state , { draftTransaction : newDraftTransaction } ) ;
2019-05-10 07:02:03 +02:00
} ,
2019-04-03 19:12:51 +02:00
2019-05-10 07:02:03 +02:00
[ SEND _TRANSACTION _COMPLETED ] : state => Object . assign ( { } , state , {
draftTransaction : buildDraftTransaction ( )
} ) ,
2019-04-03 19:12:51 +02:00
2019-05-10 07:02:03 +02:00
[ SEND _TRANSACTION _FAILED ] : ( state , action ) => {
const newDraftTransaction = Object . assign ( { } , state . draftTransaction , {
sending : false ,
error : action . data . error
} ) ;
2019-04-03 19:12:51 +02:00
2020-06-29 23:02:19 +02:00
return _extends$j ( { } , state , { draftTransaction : newDraftTransaction } ) ;
2019-05-10 07:02:03 +02:00
} ,
2019-04-03 19:12:51 +02:00
2020-06-29 23:02:19 +02:00
[ SUPPORT _TRANSACTION _STARTED ] : state => _extends$j ( { } , state , {
2019-05-10 07:02:03 +02:00
sendingSupport : true
} ) ,
2019-04-03 19:12:51 +02:00
2020-06-29 23:02:19 +02:00
[ SUPPORT _TRANSACTION _COMPLETED ] : state => _extends$j ( { } , state , {
2019-05-10 07:02:03 +02:00
sendingSupport : false
} ) ,
2019-04-03 19:12:51 +02:00
2020-06-29 23:02:19 +02:00
[ SUPPORT _TRANSACTION _FAILED ] : ( state , action ) => _extends$j ( { } , state , {
2019-05-10 07:02:03 +02:00
error : action . data . error ,
sendingSupport : false
} ) ,
2019-04-03 19:12:51 +02:00
2020-06-29 23:02:19 +02:00
[ CLEAR _SUPPORT _TRANSACTION ] : state => _extends$j ( { } , state , {
2019-10-30 08:55:15 +01:00
sendingSupport : false
} ) ,
2020-06-29 23:02:19 +02:00
[ WALLET _STATUS _COMPLETED ] : ( state , action ) => _extends$j ( { } , state , {
2019-05-10 07:02:03 +02:00
walletIsEncrypted : action . result
} ) ,
2019-04-03 19:12:51 +02:00
2020-06-29 23:02:19 +02:00
[ WALLET _ENCRYPT _START ] : state => _extends$j ( { } , state , {
2019-05-10 07:02:03 +02:00
walletEncryptPending : true ,
walletEncryptSucceded : null ,
walletEncryptResult : null
} ) ,
2019-04-03 19:12:51 +02:00
2020-06-29 23:02:19 +02:00
[ WALLET _ENCRYPT _COMPLETED ] : ( state , action ) => _extends$j ( { } , state , {
2019-05-10 07:02:03 +02:00
walletEncryptPending : false ,
walletEncryptSucceded : true ,
walletEncryptResult : action . result
} ) ,
2019-04-03 19:12:51 +02:00
2020-06-29 23:02:19 +02:00
[ WALLET _ENCRYPT _FAILED ] : ( state , action ) => _extends$j ( { } , state , {
2019-05-10 07:02:03 +02:00
walletEncryptPending : false ,
walletEncryptSucceded : false ,
walletEncryptResult : action . result
} ) ,
2019-04-03 19:12:51 +02:00
2020-06-29 23:02:19 +02:00
[ WALLET _DECRYPT _START ] : state => _extends$j ( { } , state , {
2019-05-10 07:02:03 +02:00
walletDecryptPending : true ,
walletDecryptSucceded : null ,
walletDecryptResult : null
} ) ,
2019-04-03 19:12:51 +02:00
2020-06-29 23:02:19 +02:00
[ WALLET _DECRYPT _COMPLETED ] : ( state , action ) => _extends$j ( { } , state , {
2019-05-10 07:02:03 +02:00
walletDecryptPending : false ,
walletDecryptSucceded : true ,
walletDecryptResult : action . result
} ) ,
2019-04-03 19:12:51 +02:00
2020-06-29 23:02:19 +02:00
[ WALLET _DECRYPT _FAILED ] : ( state , action ) => _extends$j ( { } , state , {
2019-05-10 07:02:03 +02:00
walletDecryptPending : false ,
walletDecryptSucceded : false ,
walletDecryptResult : action . result
} ) ,
2019-04-03 19:12:51 +02:00
2020-06-29 23:02:19 +02:00
[ WALLET _UNLOCK _START ] : state => _extends$j ( { } , state , {
2019-05-10 07:02:03 +02:00
walletUnlockPending : true ,
walletUnlockSucceded : null ,
walletUnlockResult : null
} ) ,
2019-04-03 19:12:51 +02:00
2020-06-29 23:02:19 +02:00
[ WALLET _UNLOCK _COMPLETED ] : ( state , action ) => _extends$j ( { } , state , {
2019-05-10 07:02:03 +02:00
walletUnlockPending : false ,
walletUnlockSucceded : true ,
walletUnlockResult : action . result
} ) ,
2020-06-29 23:02:19 +02:00
[ WALLET _UNLOCK _FAILED ] : ( state , action ) => _extends$j ( { } , state , {
2019-05-10 07:02:03 +02:00
walletUnlockPending : false ,
walletUnlockSucceded : false ,
walletUnlockResult : action . result
} ) ,
2020-06-29 23:02:19 +02:00
[ WALLET _LOCK _START ] : state => _extends$j ( { } , state , {
2019-05-10 07:02:03 +02:00
walletLockPending : false ,
walletLockSucceded : null ,
walletLockResult : null
} ) ,
2020-06-29 23:02:19 +02:00
[ WALLET _LOCK _COMPLETED ] : ( state , action ) => _extends$j ( { } , state , {
2019-05-10 07:02:03 +02:00
walletLockPending : false ,
walletLockSucceded : true ,
walletLockResult : action . result
} ) ,
2020-06-29 23:02:19 +02:00
[ WALLET _LOCK _FAILED ] : ( state , action ) => _extends$j ( { } , state , {
2019-05-10 07:02:03 +02:00
walletLockPending : false ,
walletLockSucceded : false ,
walletLockResult : action . result
} ) ,
2020-06-29 23:02:19 +02:00
[ SET _TRANSACTION _LIST _FILTER ] : ( state , action ) => _extends$j ( { } , state , {
2019-05-10 07:02:03 +02:00
transactionListFilter : action . data
} ) ,
2020-06-29 23:02:19 +02:00
[ UPDATE _CURRENT _HEIGHT ] : ( state , action ) => _extends$j ( { } , state , {
2019-05-10 07:02:03 +02:00
latestBlock : action . data
2019-12-18 17:47:18 +01:00
} ) ,
2020-06-29 23:02:19 +02:00
[ WALLET _RESTART ] : state => _extends$j ( { } , state , {
2019-12-18 17:47:18 +01:00
walletReconnecting : true
} ) ,
2020-06-29 23:02:19 +02:00
[ WALLET _RESTART _COMPLETED ] : state => _extends$j ( { } , state , {
2019-12-18 17:47:18 +01:00
walletReconnecting : false
2019-05-10 07:02:03 +02:00
} )
2020-06-29 23:02:19 +02:00
} , defaultState$9 ) ;
2019-06-10 04:45:47 +02:00
2020-01-21 06:46:14 +01:00
//
2020-01-13 23:00:04 +01:00
2020-05-18 22:40:33 +02:00
const selectState$5 = state => state . content || { } ;
2019-04-03 19:12:51 +02:00
2020-05-18 22:40:33 +02:00
const makeSelectContentPositionForUri = uri => reselect . createSelector ( selectState$5 , makeSelectClaimForUri ( uri ) , ( state , claim ) => {
2019-04-03 19:12:51 +02:00
if ( ! claim ) {
return null ;
}
const outpoint = ` ${ claim . txid } : ${ claim . nout } ` ;
const id = claim . claim _id ;
return state . positions [ id ] ? state . positions [ id ] [ outpoint ] : null ;
} ) ;
2020-06-29 23:02:19 +02:00
var _extends$k = 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
2020-05-18 22:40:33 +02:00
const selectState$6 = state => state . notifications || { } ;
2019-04-03 19:12:51 +02:00
2020-05-18 22:40:33 +02:00
const selectToast = reselect . createSelector ( selectState$6 , state => {
2019-04-03 19:12:51 +02:00
if ( state . toasts . length ) {
const { id , params } = state . toasts [ 0 ] ;
2020-06-29 23:02:19 +02:00
return _extends$k ( {
2019-04-03 19:12:51 +02:00
id
} , params ) ;
}
return null ;
} ) ;
2020-05-18 22:40:33 +02:00
const selectError = reselect . createSelector ( selectState$6 , state => {
2019-04-03 19:12:51 +02:00
if ( state . errors . length ) {
const { error } = state . errors [ 0 ] ;
return {
error
} ;
}
return null ;
} ) ;
2019-06-10 04:45:47 +02:00
//
2020-06-29 23:02:19 +02:00
const selectState$7 = state => state . comments || { } ;
2019-06-12 03:14:37 +02:00
2020-06-29 23:02:19 +02:00
const selectCommentsById = reselect . createSelector ( selectState$7 , state => state . commentById || { } ) ;
2020-01-10 03:29:54 +01:00
2020-06-29 23:02:19 +02:00
const selectIsFetchingComments = reselect . createSelector ( selectState$7 , state => state . isLoading ) ;
const selectCommentsByClaimId = reselect . createSelector ( selectState$7 , selectCommentsById , ( state , byId ) => {
const byClaimId = state . byId || { } ;
const comments = { } ;
// replace every comment_id in the list with the actual comment object
Object . keys ( byClaimId ) . forEach ( claimId => {
const commentIds = byClaimId [ claimId ] ;
comments [ claimId ] = Array ( commentIds === null ? 0 : commentIds . length ) ;
for ( let i = 0 ; i < commentIds . length ; i ++ ) {
comments [ claimId ] [ i ] = byId [ commentIds [ i ] ] ;
}
} ) ;
return comments ;
} ) ;
// previously this used a mapping from claimId -> Array<Comments>
/ * e x p o r t c o n s t s e l e c t C o m m e n t s B y I d = c r e a t e S e l e c t o r (
selectState ,
state => state . byId || { }
) ; * /
const selectCommentsByUri = reselect . createSelector ( selectState$7 , state => {
const byUri = state . commentsByUri || { } ;
const comments = { } ;
Object . keys ( byUri ) . forEach ( uri => {
const claimId = byUri [ uri ] ;
if ( claimId === null ) {
comments [ uri ] = null ;
} else {
comments [ uri ] = claimId ;
}
} ) ;
return comments ;
} ) ;
const makeSelectCommentsForUri = uri => reselect . createSelector ( selectCommentsByClaimId , selectCommentsByUri , ( byClaimId , byUri ) => {
const claimId = byUri [ uri ] ;
return byClaimId && byClaimId [ claimId ] ;
} ) ;
// todo: allow SDK to retrieve user comments through comment_list
// todo: implement selectors for selecting comments owned by user
//
const selectState$8 = state => state . tags || { } ;
const selectKnownTagsByName = reselect . createSelector ( selectState$8 , state => state . knownTags ) ;
const selectFollowedTagsList = reselect . createSelector ( selectState$8 , state => state . followedTags . filter ( tag => typeof tag === 'string' ) ) ;
2019-06-10 04:45:47 +02:00
2019-07-26 08:45:02 +02:00
const selectFollowedTags = reselect . createSelector ( selectFollowedTagsList , followedTags => followedTags . map ( tag => ( { name : tag . toLowerCase ( ) } ) ) . sort ( ( a , b ) => a . name . localeCompare ( b . name ) ) ) ;
2019-06-10 04:45:47 +02:00
const selectUnfollowedTags = reselect . createSelector ( selectKnownTagsByName , selectFollowedTagsList , ( tagsByName , followedTags ) => {
const followedTagsSet = new Set ( followedTags ) ;
let tagsToReturn = [ ] ;
Object . keys ( tagsByName ) . forEach ( key => {
if ( ! followedTagsSet . has ( key ) ) {
const { name } = tagsByName [ key ] ;
2019-08-13 17:27:32 +02:00
tagsToReturn . push ( { name : name . toLowerCase ( ) } ) ;
2019-06-10 04:45:47 +02:00
}
} ) ;
return tagsToReturn ;
} ) ;
2019-09-09 20:57:56 +02:00
const makeSelectIsFollowingTag = tag => reselect . createSelector ( selectFollowedTags , followedTags => {
return followedTags . some ( followedTag => followedTag . name === tag . toLowerCase ( ) ) ;
} ) ;
2020-06-29 23:02:19 +02:00
//
const selectState$9 = state => state . blocked || { } ;
const selectBlockedChannels = reselect . createSelector ( selectState$9 , state => state . blockedChannels ) ;
const selectBlockedChannelsCount = reselect . createSelector ( selectBlockedChannels , state => state . length ) ;
const selectChannelIsBlocked = uri => reselect . createSelector ( selectBlockedChannels , state => {
return state . includes ( uri ) ;
} ) ;
2020-04-25 22:31:53 +02:00
exports . ABANDON _STATES = abandon _states ;
2020-01-29 20:18:15 +01:00
exports . ACTIONS = action _types ;
2019-07-01 21:49:51 +02:00
exports . CLAIM _VALUES = claim ;
2019-12-11 15:45:18 +01:00
exports . DAEMON _SETTINGS = daemon _settings ;
2019-07-02 22:33:57 +02:00
exports . DEFAULT _FOLLOWED _TAGS = DEFAULT _FOLLOWED _TAGS ;
exports . DEFAULT _KNOWN _TAGS = DEFAULT _KNOWN _TAGS ;
2019-07-01 21:49:51 +02:00
exports . LICENSES = licenses ;
2019-04-03 19:12:51 +02:00
exports . Lbry = lbryProxy ;
2020-06-23 20:48:30 +02:00
exports . LbryFirst = lbryFirstProxy ;
2019-07-02 22:33:57 +02:00
exports . MATURE _TAGS = MATURE _TAGS ;
2019-04-03 19:12:51 +02:00
exports . PAGES = pages ;
exports . SEARCH _OPTIONS = SEARCH _OPTIONS ;
exports . SEARCH _TYPES = SEARCH _TYPES ;
exports . SETTINGS = settings ;
2019-12-12 20:51:07 +01:00
exports . SHARED _PREFERENCES = shared _preferences ;
2019-04-03 19:12:51 +02:00
exports . SORT _OPTIONS = sort _options ;
2019-10-07 18:33:06 +02:00
exports . SPEECH _URLS = speech _urls ;
2019-04-03 19:12:51 +02:00
exports . THUMBNAIL _STATUSES = thumbnail _upload _statuses ;
exports . TRANSACTIONS = transaction _types ;
2020-04-10 14:16:27 +02:00
exports . TXO _LIST = txo _list ;
2019-09-25 18:30:26 +02:00
exports . TX _LIST = transaction _list ;
2019-10-31 12:46:42 +01:00
exports . apiCall = apiCall ;
2019-04-03 19:12:51 +02:00
exports . batchActions = batchActions ;
2020-06-29 23:02:19 +02:00
exports . blockedReducer = blockedReducer ;
2019-10-15 05:35:38 +02:00
exports . buildSharedStateMiddleware = buildSharedStateMiddleware ;
2019-04-03 19:12:51 +02:00
exports . buildURI = buildURI ;
exports . claimsReducer = claimsReducer ;
2020-06-29 23:02:19 +02:00
exports . commentReducer = commentReducer ;
2019-04-03 19:12:51 +02:00
exports . contentReducer = contentReducer ;
exports . convertToShareLink = convertToShareLink ;
2019-07-30 17:48:45 +02:00
exports . createNormalizedClaimSearchKey = createNormalizedClaimSearchKey ;
2019-04-03 19:12:51 +02:00
exports . creditsToString = creditsToString ;
exports . doAbandonClaim = doAbandonClaim ;
2020-04-10 14:16:27 +02:00
exports . doAbandonTxo = doAbandonTxo ;
2019-06-10 04:45:47 +02:00
exports . doAddTag = doAddTag ;
2019-04-03 19:12:51 +02:00
exports . doBalanceSubscribe = doBalanceSubscribe ;
exports . doBlurSearchInput = doBlurSearchInput ;
exports . doCheckAddressIsMine = doCheckAddressIsMine ;
2020-06-17 03:56:51 +02:00
exports . doCheckPendingClaims = doCheckPendingClaims ;
2020-04-25 22:31:53 +02:00
exports . doCheckPublishNameAvailability = doCheckPublishNameAvailability ;
2020-05-07 13:41:56 +02:00
exports . doCheckReflectingFiles = doCheckReflectingFiles ;
2019-06-11 20:11:18 +02:00
exports . doClaimSearch = doClaimSearch ;
2019-07-01 21:49:51 +02:00
exports . doClearPublish = doClearPublish ;
2020-05-19 04:13:18 +02:00
exports . doClearPurchasedUriSuccess = doClearPurchasedUriSuccess ;
2020-02-10 16:49:45 +01:00
exports . doClearRepostError = doClearRepostError ;
2019-10-30 08:55:15 +01:00
exports . doClearSupport = doClearSupport ;
2020-06-29 23:02:19 +02:00
exports . doCommentAbandon = doCommentAbandon ;
exports . doCommentCreate = doCommentCreate ;
exports . doCommentHide = doCommentHide ;
exports . doCommentList = doCommentList ;
exports . doCommentUpdate = doCommentUpdate ;
2019-04-23 19:22:14 +02:00
exports . doCreateChannel = doCreateChannel ;
2019-06-10 04:45:47 +02:00
exports . doDeleteTag = doDeleteTag ;
2019-04-03 19:12:51 +02:00
exports . doDismissError = doDismissError ;
exports . doDismissToast = doDismissToast ;
exports . doError = doError ;
2019-04-23 19:22:14 +02:00
exports . doFetchChannelListMine = doFetchChannelListMine ;
2019-04-03 19:12:51 +02:00
exports . doFetchClaimListMine = doFetchClaimListMine ;
exports . doFetchClaimsByChannel = doFetchClaimsByChannel ;
exports . doFetchFileInfo = doFetchFileInfo ;
2020-04-25 22:31:53 +02:00
exports . doFetchFileInfos = doFetchFileInfos ;
2019-04-03 19:12:51 +02:00
exports . doFetchTransactions = doFetchTransactions ;
2020-04-10 14:16:27 +02:00
exports . doFetchTxoPage = doFetchTxoPage ;
2019-05-21 21:18:07 +02:00
exports . doFileGet = doFileGet ;
2019-04-03 19:12:51 +02:00
exports . doFileList = doFileList ;
exports . doFocusSearchInput = doFocusSearchInput ;
exports . doGetNewAddress = doGetNewAddress ;
2019-09-12 21:06:49 +02:00
exports . doImportChannel = doImportChannel ;
2019-09-20 17:22:21 +02:00
exports . doPopulateSharedUserState = doPopulateSharedUserState ;
2019-09-30 23:52:41 +02:00
exports . doPreferenceGet = doPreferenceGet ;
exports . doPreferenceSet = doPreferenceSet ;
2019-07-01 21:49:51 +02:00
exports . doPrepareEdit = doPrepareEdit ;
exports . doPublish = doPublish ;
2020-05-08 22:47:33 +02:00
exports . doPurchaseList = doPurchaseList ;
2019-05-21 21:18:07 +02:00
exports . doPurchaseUri = doPurchaseUri ;
2020-02-10 16:49:45 +01:00
exports . doRepost = doRepost ;
2019-07-01 21:49:51 +02:00
exports . doResetThumbnailStatus = doResetThumbnailStatus ;
2019-04-03 19:12:51 +02:00
exports . doResolveUri = doResolveUri ;
exports . doResolveUris = doResolveUris ;
2020-01-22 02:04:50 +01:00
exports . doResolvedSearch = doResolvedSearch ;
2019-04-03 19:12:51 +02:00
exports . doSearch = doSearch ;
exports . doSendDraftTransaction = doSendDraftTransaction ;
exports . doSendTip = doSendTip ;
exports . doSetDraftTransactionAddress = doSetDraftTransactionAddress ;
exports . doSetDraftTransactionAmount = doSetDraftTransactionAmount ;
exports . doSetFileListSort = doSetFileListSort ;
exports . doSetTransactionListFilter = doSetTransactionListFilter ;
2020-03-25 03:46:35 +01:00
exports . doSupportAbandonForClaim = doSupportAbandonForClaim ;
2019-04-03 19:12:51 +02:00
exports . doToast = doToast ;
2020-06-29 23:02:19 +02:00
exports . doToggleBlockChannel = doToggleBlockChannel ;
2019-06-10 04:45:47 +02:00
exports . doToggleTagFollow = doToggleTagFollow ;
2019-04-03 19:12:51 +02:00
exports . doUpdateBalance = doUpdateBalance ;
exports . doUpdateBlockHeight = doUpdateBlockHeight ;
2019-07-01 03:16:44 +02:00
exports . doUpdateChannel = doUpdateChannel ;
2019-07-01 21:49:51 +02:00
exports . doUpdatePublishForm = doUpdatePublishForm ;
2019-04-03 19:12:51 +02:00
exports . doUpdateSearchOptions = doUpdateSearchOptions ;
exports . doUpdateSearchQuery = doUpdateSearchQuery ;
2020-04-10 14:16:27 +02:00
exports . doUpdateTxoPageParams = doUpdateTxoPageParams ;
2019-07-01 21:49:51 +02:00
exports . doUploadThumbnail = doUploadThumbnail ;
2019-04-03 19:12:51 +02:00
exports . doWalletDecrypt = doWalletDecrypt ;
exports . doWalletEncrypt = doWalletEncrypt ;
2019-12-11 20:27:52 +01:00
exports . doWalletReconnect = doWalletReconnect ;
2019-04-03 19:12:51 +02:00
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 ;
2019-07-01 03:16:44 +02:00
exports . makeSelectAmountForUri = makeSelectAmountForUri ;
2019-08-20 22:00:26 +02:00
exports . makeSelectCanonicalUrlForUri = makeSelectCanonicalUrlForUri ;
2019-04-03 19:12:51 +02:00
exports . makeSelectChannelForClaimUri = makeSelectChannelForClaimUri ;
exports . makeSelectClaimForUri = makeSelectClaimForUri ;
exports . makeSelectClaimIsMine = makeSelectClaimIsMine ;
2019-04-23 21:02:32 +02:00
exports . makeSelectClaimIsNsfw = makeSelectClaimIsNsfw ;
2019-04-03 19:12:51 +02:00
exports . makeSelectClaimIsPending = makeSelectClaimIsPending ;
2020-05-08 22:47:33 +02:00
exports . makeSelectClaimWasPurchased = makeSelectClaimWasPurchased ;
2019-04-03 19:12:51 +02:00
exports . makeSelectClaimsInChannelForCurrentPageState = makeSelectClaimsInChannelForCurrentPageState ;
exports . makeSelectClaimsInChannelForPage = makeSelectClaimsInChannelForPage ;
2020-06-29 23:02:19 +02:00
exports . makeSelectCommentsForUri = makeSelectCommentsForUri ;
2019-04-03 19:12:51 +02:00
exports . makeSelectContentPositionForUri = makeSelectContentPositionForUri ;
exports . makeSelectContentTypeForUri = makeSelectContentTypeForUri ;
2019-05-01 16:21:51 +02:00
exports . makeSelectCoverForUri = makeSelectCoverForUri ;
2019-05-06 04:00:45 +02:00
exports . makeSelectDateForUri = makeSelectDateForUri ;
2019-08-02 08:21:28 +02:00
exports . makeSelectDownloadPathForUri = makeSelectDownloadPathForUri ;
2019-04-03 19:12:51 +02:00
exports . makeSelectDownloadingForUri = makeSelectDownloadingForUri ;
exports . makeSelectFetchingChannelClaims = makeSelectFetchingChannelClaims ;
exports . makeSelectFileInfoForUri = makeSelectFileInfoForUri ;
2019-08-02 08:21:28 +02:00
exports . makeSelectFileNameForUri = makeSelectFileNameForUri ;
2019-08-14 18:52:24 +02:00
exports . makeSelectFilePartlyDownloaded = makeSelectFilePartlyDownloaded ;
2019-09-23 04:25:12 +02:00
exports . makeSelectFilteredTransactionsForPage = makeSelectFilteredTransactionsForPage ;
2019-04-03 19:12:51 +02:00
exports . makeSelectFirstRecommendedFileForUri = makeSelectFirstRecommendedFileForUri ;
2019-09-09 20:57:56 +02:00
exports . makeSelectIsFollowingTag = makeSelectIsFollowingTag ;
2019-04-03 19:12:51 +02:00
exports . makeSelectIsUriResolving = makeSelectIsUriResolving ;
2019-11-01 18:17:55 +01:00
exports . makeSelectLatestTransactions = makeSelectLatestTransactions ;
2019-04-03 19:12:51 +02:00
exports . makeSelectLoadingForUri = makeSelectLoadingForUri ;
2019-08-02 08:21:28 +02:00
exports . makeSelectMediaTypeForUri = makeSelectMediaTypeForUri ;
2019-04-03 19:12:51 +02:00
exports . makeSelectMetadataForUri = makeSelectMetadataForUri ;
2019-05-06 19:57:07 +02:00
exports . makeSelectMetadataItemForUri = makeSelectMetadataItemForUri ;
2020-05-08 22:47:33 +02:00
exports . makeSelectMyPurchasesForPage = makeSelectMyPurchasesForPage ;
2019-09-25 23:37:21 +02:00
exports . makeSelectMyStreamUrlsForPage = makeSelectMyStreamUrlsForPage ;
2019-04-03 19:12:51 +02:00
exports . makeSelectNsfwCountForChannel = makeSelectNsfwCountForChannel ;
exports . makeSelectNsfwCountFromUris = makeSelectNsfwCountFromUris ;
2019-11-25 21:11:32 +01:00
exports . makeSelectOmittedCountForChannel = makeSelectOmittedCountForChannel ;
2020-03-25 03:46:35 +01:00
exports . makeSelectPendingAmountByUri = makeSelectPendingAmountByUri ;
2019-09-04 17:57:48 +02:00
exports . makeSelectPermanentUrlForUri = makeSelectPermanentUrlForUri ;
2019-07-05 04:20:56 +02:00
exports . makeSelectPublishFormValue = makeSelectPublishFormValue ;
2019-04-03 19:12:51 +02:00
exports . makeSelectQueryWithOptions = makeSelectQueryWithOptions ;
exports . makeSelectRecommendedContentForUri = makeSelectRecommendedContentForUri ;
2020-05-07 13:41:56 +02:00
exports . makeSelectReflectingClaimForUri = makeSelectReflectingClaimForUri ;
2020-01-22 02:04:50 +01:00
exports . makeSelectResolvedRecommendedContentForUri = makeSelectResolvedRecommendedContentForUri ;
exports . makeSelectResolvedSearchResults = makeSelectResolvedSearchResults ;
exports . makeSelectResolvedSearchResultsLastPageReached = makeSelectResolvedSearchResultsLastPageReached ;
2019-10-03 23:14:35 +02:00
exports . makeSelectSearchDownloadUrlsCount = makeSelectSearchDownloadUrlsCount ;
exports . makeSelectSearchDownloadUrlsForPage = makeSelectSearchDownloadUrlsForPage ;
2019-04-03 19:12:51 +02:00
exports . makeSelectSearchUris = makeSelectSearchUris ;
2019-07-08 20:28:14 +02:00
exports . makeSelectShortUrlForUri = makeSelectShortUrlForUri ;
2019-05-21 21:18:07 +02:00
exports . makeSelectStreamingUrlForUri = makeSelectStreamingUrlForUri ;
2019-08-15 08:13:50 +02:00
exports . makeSelectSupportsForUri = makeSelectSupportsForUri ;
2019-06-10 04:45:47 +02:00
exports . makeSelectTagsForUri = makeSelectTagsForUri ;
2019-04-23 19:22:14 +02:00
exports . makeSelectThumbnailForUri = makeSelectThumbnailForUri ;
2019-04-03 19:12:51 +02:00
exports . makeSelectTitleForUri = makeSelectTitleForUri ;
2019-11-22 02:36:06 +01:00
exports . makeSelectTotalClaimsInChannelSearch = makeSelectTotalClaimsInChannelSearch ;
2019-04-03 19:12:51 +02:00
exports . makeSelectTotalItemsForChannel = makeSelectTotalItemsForChannel ;
exports . makeSelectTotalPagesForChannel = makeSelectTotalPagesForChannel ;
2019-11-22 02:36:06 +01:00
exports . makeSelectTotalPagesInChannelSearch = makeSelectTotalPagesInChannelSearch ;
2019-08-02 08:21:28 +02:00
exports . makeSelectUriIsStreamable = makeSelectUriIsStreamable ;
2019-04-03 19:12:51 +02:00
exports . normalizeURI = normalizeURI ;
exports . notificationsReducer = notificationsReducer ;
exports . parseQueryParams = parseQueryParams ;
exports . parseURI = parseURI ;
2019-07-01 21:49:51 +02:00
exports . publishReducer = publishReducer ;
2019-04-03 19:12:51 +02:00
exports . regexAddress = regexAddress ;
exports . regexInvalidURI = regexInvalidURI ;
exports . savePosition = savePosition ;
exports . searchReducer = searchReducer ;
2020-04-01 20:26:38 +02:00
exports . selectAbandonClaimSupportError = selectAbandonClaimSupportError ;
2019-04-03 19:12:51 +02:00
exports . selectAbandoningIds = selectAbandoningIds ;
exports . selectAllClaimsByChannel = selectAllClaimsByChannel ;
exports . selectAllFetchingChannelClaims = selectAllFetchingChannelClaims ;
exports . selectAllMyClaimsByOutpoint = selectAllMyClaimsByOutpoint ;
exports . selectBalance = selectBalance ;
2020-06-29 23:02:19 +02:00
exports . selectBlockedChannels = selectBlockedChannels ;
exports . selectBlockedChannelsCount = selectBlockedChannelsCount ;
2019-04-03 19:12:51 +02:00
exports . selectBlocks = selectBlocks ;
exports . selectChannelClaimCounts = selectChannelClaimCounts ;
2019-09-12 21:06:49 +02:00
exports . selectChannelImportPending = selectChannelImportPending ;
2020-06-29 23:02:19 +02:00
exports . selectChannelIsBlocked = selectChannelIsBlocked ;
2020-03-25 03:46:35 +01:00
exports . selectClaimIdsByUri = selectClaimIdsByUri ;
2019-07-17 22:50:58 +02:00
exports . selectClaimSearchByQuery = selectClaimSearchByQuery ;
2019-08-13 17:27:32 +02:00
exports . selectClaimSearchByQueryLastPageReached = selectClaimSearchByQueryLastPageReached ;
2019-09-24 00:56:53 +02:00
exports . selectClaimsBalance = selectClaimsBalance ;
2019-04-03 19:12:51 +02:00
exports . selectClaimsById = selectClaimsById ;
exports . selectClaimsByUri = selectClaimsByUri ;
2019-09-13 21:52:52 +02:00
exports . selectCreateChannelError = selectCreateChannelError ;
2019-08-27 06:42:52 +02:00
exports . selectCreatingChannel = selectCreatingChannel ;
2019-04-03 19:12:51 +02:00
exports . selectCurrentChannelPage = selectCurrentChannelPage ;
2019-09-25 23:37:21 +02:00
exports . selectDownloadUrlsCount = selectDownloadUrlsCount ;
2019-06-10 04:45:47 +02:00
exports . selectDownloadedUris = selectDownloadedUris ;
2019-04-03 19:12:51 +02:00
exports . selectDownloadingByOutpoint = selectDownloadingByOutpoint ;
exports . selectDownloadingFileInfos = selectDownloadingFileInfos ;
exports . selectDraftTransaction = selectDraftTransaction ;
exports . selectDraftTransactionAddress = selectDraftTransactionAddress ;
exports . selectDraftTransactionAmount = selectDraftTransactionAmount ;
exports . selectDraftTransactionError = selectDraftTransactionError ;
exports . selectError = selectError ;
2019-06-11 20:11:18 +02:00
exports . selectFetchingClaimSearch = selectFetchingClaimSearch ;
2019-07-31 21:14:51 +02:00
exports . selectFetchingClaimSearchByQuery = selectFetchingClaimSearchByQuery ;
2019-04-03 19:12:51 +02:00
exports . selectFetchingMyChannels = selectFetchingMyChannels ;
2020-04-25 22:31:53 +02:00
exports . selectFetchingMyClaimsPageError = selectFetchingMyClaimsPageError ;
2020-05-08 22:47:33 +02:00
exports . selectFetchingMyPurchasesError = selectFetchingMyPurchasesError ;
2020-04-10 14:16:27 +02:00
exports . selectFetchingTxosError = selectFetchingTxosError ;
2019-04-03 19:12:51 +02:00
exports . selectFileInfosByOutpoint = selectFileInfosByOutpoint ;
exports . selectFileInfosDownloaded = selectFileInfosDownloaded ;
exports . selectFileListDownloadedSort = selectFileListDownloadedSort ;
exports . selectFileListPublishedSort = selectFileListPublishedSort ;
2019-09-23 04:25:12 +02:00
exports . selectFilteredTransactionCount = selectFilteredTransactionCount ;
exports . selectFilteredTransactions = selectFilteredTransactions ;
2019-06-10 04:45:47 +02:00
exports . selectFollowedTags = selectFollowedTags ;
2020-03-10 15:08:23 +01:00
exports . selectFollowedTagsList = selectFollowedTagsList ;
2019-04-03 19:12:51 +02:00
exports . selectGettingNewAddress = selectGettingNewAddress ;
exports . selectHasTransactions = selectHasTransactions ;
exports . selectIsFetchingClaimListMine = selectIsFetchingClaimListMine ;
2020-06-29 23:02:19 +02:00
exports . selectIsFetchingComments = selectIsFetchingComments ;
2019-04-03 19:12:51 +02:00
exports . selectIsFetchingFileList = selectIsFetchingFileList ;
exports . selectIsFetchingFileListDownloadedOrPublished = selectIsFetchingFileListDownloadedOrPublished ;
2020-05-08 22:47:33 +02:00
exports . selectIsFetchingMyPurchases = selectIsFetchingMyPurchases ;
2019-04-03 19:12:51 +02:00
exports . selectIsFetchingTransactions = selectIsFetchingTransactions ;
2020-04-10 14:16:27 +02:00
exports . selectIsFetchingTxos = selectIsFetchingTxos ;
2019-07-01 21:49:51 +02:00
exports . selectIsResolvingPublishUris = selectIsResolvingPublishUris ;
2019-04-03 19:12:51 +02:00
exports . selectIsSearching = selectIsSearching ;
exports . selectIsSendingSupport = selectIsSendingSupport ;
2019-07-01 21:49:51 +02:00
exports . selectIsStillEditing = selectIsStillEditing ;
2019-12-18 17:47:18 +01:00
exports . selectIsWalletReconnecting = selectIsWalletReconnecting ;
2019-04-03 19:12:51 +02:00
exports . selectMyActiveClaims = selectMyActiveClaims ;
exports . selectMyChannelClaims = selectMyChannelClaims ;
2020-06-17 03:56:51 +02:00
exports . selectMyChannelUrls = selectMyChannelUrls ;
2019-07-01 21:49:51 +02:00
exports . selectMyClaimForUri = selectMyClaimForUri ;
2019-06-11 20:36:01 +02:00
exports . selectMyClaimUrisWithoutChannels = selectMyClaimUrisWithoutChannels ;
2019-04-03 19:12:51 +02:00
exports . selectMyClaims = selectMyClaims ;
exports . selectMyClaimsOutpoints = selectMyClaimsOutpoints ;
2020-04-25 22:31:53 +02:00
exports . selectMyClaimsPage = selectMyClaimsPage ;
exports . selectMyClaimsPageItemCount = selectMyClaimsPageItemCount ;
exports . selectMyClaimsPageNumber = selectMyClaimsPageNumber ;
2019-04-03 19:12:51 +02:00
exports . selectMyClaimsRaw = selectMyClaimsRaw ;
exports . selectMyClaimsWithoutChannels = selectMyClaimsWithoutChannels ;
2020-05-08 22:47:33 +02:00
exports . selectMyPurchases = selectMyPurchases ;
exports . selectMyPurchasesCount = selectMyPurchasesCount ;
2019-09-25 23:37:21 +02:00
exports . selectMyStreamUrlsCount = selectMyStreamUrlsCount ;
2020-03-25 03:46:35 +01:00
exports . selectPendingSupportTransactions = selectPendingSupportTransactions ;
2019-04-03 19:12:51 +02:00
exports . selectPlayingUri = selectPlayingUri ;
2019-07-01 21:49:51 +02:00
exports . selectPublishFormValues = selectPublishFormValues ;
2020-05-18 22:40:33 +02:00
exports . selectPurchaseUriSuccess = selectPurchaseUriSuccess ;
2019-04-03 19:12:51 +02:00
exports . selectReceiveAddress = selectReceiveAddress ;
exports . selectRecentTransactions = selectRecentTransactions ;
2020-05-07 13:41:56 +02:00
exports . selectReflectingById = selectReflectingById ;
2020-02-10 16:49:45 +01:00
exports . selectRepostError = selectRepostError ;
exports . selectRepostLoading = selectRepostLoading ;
2019-09-24 00:56:53 +02:00
exports . selectReservedBalance = selectReservedBalance ;
2020-01-22 02:04:50 +01:00
exports . selectResolvedSearchResultsByQuery = selectResolvedSearchResultsByQuery ;
exports . selectResolvedSearchResultsByQueryLastPageReached = selectResolvedSearchResultsByQueryLastPageReached ;
2019-04-03 19:12:51 +02:00
exports . selectResolvingUris = selectResolvingUris ;
exports . selectSearchBarFocused = selectSearchBarFocused ;
exports . selectSearchOptions = selectSearchOptions ;
exports . selectSearchState = selectState ;
exports . selectSearchSuggestions = selectSearchSuggestions ;
exports . selectSearchUrisByQuery = selectSearchUrisByQuery ;
exports . selectSearchValue = selectSearchValue ;
2019-09-24 00:56:53 +02:00
exports . selectSupportsBalance = selectSupportsBalance ;
2019-05-14 06:50:21 +02:00
exports . selectSupportsByOutpoint = selectSupportsByOutpoint ;
2019-07-01 21:49:51 +02:00
exports . selectTakeOverAmount = selectTakeOverAmount ;
2019-09-24 00:56:53 +02:00
exports . selectTipsBalance = selectTipsBalance ;
2019-04-03 19:12:51 +02:00
exports . selectToast = selectToast ;
2019-04-18 09:56:16 +02:00
exports . selectTotalBalance = selectTotalBalance ;
2019-04-03 19:12:51 +02:00
exports . selectTotalDownloadProgress = selectTotalDownloadProgress ;
2019-08-15 08:13:50 +02:00
exports . selectTotalSupports = selectTotalSupports ;
2019-04-03 19:12:51 +02:00
exports . selectTransactionItems = selectTransactionItems ;
exports . selectTransactionListFilter = selectTransactionListFilter ;
exports . selectTransactionsById = selectTransactionsById ;
2020-04-10 14:16:27 +02:00
exports . selectTxoItemCount = selectTxoItemCount ;
exports . selectTxoPage = selectTxoPage ;
exports . selectTxoPageNumber = selectTxoPageNumber ;
exports . selectTxoPageParams = selectTxoPageParams ;
2019-06-10 04:45:47 +02:00
exports . selectUnfollowedTags = selectUnfollowedTags ;
2019-09-15 13:00:14 +02:00
exports . selectUpdateChannelError = selectUpdateChannelError ;
exports . selectUpdatingChannel = selectUpdatingChannel ;
2019-04-03 19:12:51 +02:00
exports . selectUrisLoading = selectUrisLoading ;
exports . selectWalletDecryptPending = selectWalletDecryptPending ;
exports . selectWalletDecryptResult = selectWalletDecryptResult ;
exports . selectWalletDecryptSucceeded = selectWalletDecryptSucceeded ;
exports . selectWalletEncryptPending = selectWalletEncryptPending ;
exports . selectWalletEncryptResult = selectWalletEncryptResult ;
exports . selectWalletEncryptSucceeded = selectWalletEncryptSucceeded ;
exports . selectWalletIsEncrypted = selectWalletIsEncrypted ;
exports . selectWalletState = selectWalletState ;
exports . selectWalletUnlockPending = selectWalletUnlockPending ;
exports . selectWalletUnlockResult = selectWalletUnlockResult ;
exports . selectWalletUnlockSucceeded = selectWalletUnlockSucceeded ;
exports . setSearchApi = setSearchApi ;
2019-07-02 22:33:57 +02:00
exports . tagsReducer = tagsReducer ;
2019-04-03 19:12:51 +02:00
exports . toQueryString = toQueryString ;
exports . walletReducer = walletReducer ;