2019-04-03 19:12:51 +02:00
'use strict' ;
Object . defineProperty ( exports , '__esModule' , { value : true } ) ;
2021-09-01 03:59:00 +02:00
function _interopDefault ( ex ) { return ( ex && ( typeof ex === 'object' ) && 'default' in ex ) ? ex [ 'default' ] : ex ; }
2019-04-03 19:12:51 +02:00
require ( 'proxy-polyfill' ) ;
2020-10-20 06:18:21 +02:00
var uuid = require ( 'uuid' ) ;
2020-07-27 21:35:27 +02:00
var reselect = require ( 'reselect' ) ;
2021-09-01 03:59:00 +02:00
var fromEntries = _interopDefault ( require ( '@ungap/from-entries' ) ) ;
2019-04-03 19:12:51 +02:00
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 ;
2021-03-11 18:56:34 +01:00
const LEVEL _1 _STAKED _AMOUNT = 0 ;
const LEVEL _2 _STAKED _AMOUNT = 1 ;
const LEVEL _3 _STAKED _AMOUNT = 50 ;
const LEVEL _4 _STAKED _AMOUNT = 250 ;
const LEVEL _5 _STAKED _AMOUNT = 1000 ;
2021-03-09 07:23:25 +01:00
2019-07-01 21:49:51 +02:00
var claim = /*#__PURE__*/ Object . freeze ( {
MINIMUM _PUBLISH _BID : MINIMUM _PUBLISH _BID ,
CHANNEL _ANONYMOUS : CHANNEL _ANONYMOUS ,
CHANNEL _NEW : CHANNEL _NEW ,
2021-03-09 07:23:25 +01:00
PAGE _SIZE : PAGE _SIZE ,
LEVEL _1 _STAKED _AMOUNT : LEVEL _1 _STAKED _AMOUNT ,
LEVEL _2 _STAKED _AMOUNT : LEVEL _2 _STAKED _AMOUNT ,
LEVEL _3 _STAKED _AMOUNT : LEVEL _3 _STAKED _AMOUNT ,
LEVEL _4 _STAKED _AMOUNT : LEVEL _4 _STAKED _AMOUNT ,
LEVEL _5 _STAKED _AMOUNT : LEVEL _5 _STAKED _AMOUNT
2019-07-01 21:49:51 +02:00
} ) ;
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' ;
2020-12-30 23:25:57 +01:00
const FETCH _UTXO _COUNT _STARTED = 'FETCH_UTXO_COUNT_STARTED' ;
const FETCH _UTXO _COUNT _COMPLETED = 'FETCH_UTXO_COUNT_COMPLETED' ;
const FETCH _UTXO _COUNT _FAILED = 'FETCH_UTXO_COUNT_FAILED' ;
2021-01-27 16:01:55 +01:00
const TIP _CLAIM _MASS _STARTED = 'TIP_CLAIM_MASS_STARTED' ;
const TIP _CLAIM _MASS _COMPLETED = 'TIP_CLAIM_MASS_COMPLETED' ;
const TIP _CLAIM _MASS _FAILED = 'TIP_CLAIM_MASS_FAILED' ;
2020-12-30 23:25:57 +01:00
const DO _UTXO _CONSOLIDATE _STARTED = 'DO_UTXO_CONSOLIDATE_STARTED' ;
const DO _UTXO _CONSOLIDATE _COMPLETED = 'DO_UTXO_CONSOLIDATE_COMPLETED' ;
const DO _UTXO _CONSOLIDATE _FAILED = 'DO_UTXO_CONSOLIDATE_FAILED' ;
const PENDING _CONSOLIDATED _TXOS _UPDATED = 'PENDING_CONSOLIDATED_TXOS_UPDATED' ;
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' ;
2021-05-07 00:41:02 +02:00
const FETCH _COLLECTION _LIST _STARTED = 'FETCH_COLLECTION_LIST_STARTED' ;
const FETCH _COLLECTION _LIST _COMPLETED = 'FETCH_COLLECTION_LIST_COMPLETED' ;
const FETCH _COLLECTION _LIST _FAILED = 'FETCH_COLLECTION_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' ;
2021-05-07 00:41:02 +02:00
const CLEAR _CHANNEL _ERRORS = 'CLEAR_CHANNEL_ERRORS' ;
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
2021-05-07 00:41:02 +02:00
const COLLECTION _PUBLISH _STARTED = 'COLLECTION_PUBLISH_STARTED' ;
const COLLECTION _PUBLISH _COMPLETED = 'COLLECTION_PUBLISH_COMPLETED' ;
const COLLECTION _PUBLISH _FAILED = 'COLLECTION_PUBLISH_FAILED' ;
const COLLECTION _PUBLISH _UPDATE _STARTED = 'COLLECTION_PUBLISH_UPDATE_STARTED' ;
const COLLECTION _PUBLISH _UPDATE _COMPLETED = 'COLLECTION_PUBLISH_UPDATE_COMPLETED' ;
const COLLECTION _PUBLISH _UPDATE _FAILED = 'COLLECTION_PUBLISH_UPDATE_FAILED' ;
const COLLECTION _PUBLISH _ABANDON _STARTED = 'COLLECTION_PUBLISH_ABANDON_STARTED' ;
const COLLECTION _PUBLISH _ABANDON _COMPLETED = 'COLLECTION_PUBLISH_ABANDON_COMPLETED' ;
const COLLECTION _PUBLISH _ABANDON _FAILED = 'COLLECTION_PUBLISH_ABANDON_FAILED' ;
const CLEAR _COLLECTION _ERRORS = 'CLEAR_COLLECTION_ERRORS' ;
const COLLECTION _ITEMS _RESOLVE _STARTED = 'COLLECTION_ITEMS_RESOLVE_STARTED' ;
const COLLECTION _ITEMS _RESOLVE _COMPLETED = 'COLLECTION_ITEMS_RESOLVE_COMPLETED' ;
const COLLECTION _ITEMS _RESOLVE _FAILED = 'COLLECTION_ITEMS_RESOLVE_FAILED' ;
const COLLECTION _NEW = 'COLLECTION_NEW' ;
const COLLECTION _DELETE = 'COLLECTION_DELETE' ;
const COLLECTION _PENDING = 'COLLECTION_PENDING' ;
const COLLECTION _EDIT = 'COLLECTION_EDIT' ;
const COLLECTION _COPY = 'COLLECTION_COPY' ;
const COLLECTION _SAVE = 'COLLECTION_SAVE' ;
const COLLECTION _ERROR = 'COLLECTION_ERROR' ;
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
// 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
// Sync
2019-09-13 21:52:52 +02:00
const USER _STATE _POPULATE = 'USER_STATE_POPULATE' ;
2020-11-12 19:21:13 +01:00
const SYNC _FATAL _ERROR = 'SYNC_FATAL_ERROR' ;
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 ,
2020-12-30 23:25:57 +01:00
FETCH _UTXO _COUNT _STARTED : FETCH _UTXO _COUNT _STARTED ,
FETCH _UTXO _COUNT _COMPLETED : FETCH _UTXO _COUNT _COMPLETED ,
FETCH _UTXO _COUNT _FAILED : FETCH _UTXO _COUNT _FAILED ,
2021-01-27 16:01:55 +01:00
TIP _CLAIM _MASS _STARTED : TIP _CLAIM _MASS _STARTED ,
TIP _CLAIM _MASS _COMPLETED : TIP _CLAIM _MASS _COMPLETED ,
TIP _CLAIM _MASS _FAILED : TIP _CLAIM _MASS _FAILED ,
2020-12-30 23:25:57 +01:00
DO _UTXO _CONSOLIDATE _STARTED : DO _UTXO _CONSOLIDATE _STARTED ,
DO _UTXO _CONSOLIDATE _COMPLETED : DO _UTXO _CONSOLIDATE _COMPLETED ,
DO _UTXO _CONSOLIDATE _FAILED : DO _UTXO _CONSOLIDATE _FAILED ,
PENDING _CONSOLIDATED _TXOS _UPDATED : PENDING _CONSOLIDATED _TXOS _UPDATED ,
2019-07-01 21:49:51 +02:00
RESOLVE _URIS _STARTED : RESOLVE _URIS _STARTED ,
RESOLVE _URIS _COMPLETED : RESOLVE _URIS _COMPLETED ,
FETCH _CHANNEL _CLAIMS _STARTED : FETCH _CHANNEL _CLAIMS _STARTED ,
FETCH _CHANNEL _CLAIMS _COMPLETED : FETCH _CHANNEL _CLAIMS _COMPLETED ,
FETCH _CLAIM _LIST _MINE _STARTED : FETCH _CLAIM _LIST _MINE _STARTED ,
FETCH _CLAIM _LIST _MINE _COMPLETED : FETCH _CLAIM _LIST _MINE _COMPLETED ,
ABANDON _CLAIM _STARTED : ABANDON _CLAIM _STARTED ,
ABANDON _CLAIM _SUCCEEDED : ABANDON _CLAIM _SUCCEEDED ,
FETCH _CHANNEL _LIST _STARTED : FETCH _CHANNEL _LIST _STARTED ,
FETCH _CHANNEL _LIST _COMPLETED : FETCH _CHANNEL _LIST _COMPLETED ,
2020-06-01 20:26:07 +02:00
FETCH _CHANNEL _LIST _FAILED : FETCH _CHANNEL _LIST _FAILED ,
2021-05-07 00:41:02 +02:00
FETCH _COLLECTION _LIST _STARTED : FETCH _COLLECTION _LIST _STARTED ,
FETCH _COLLECTION _LIST _COMPLETED : FETCH _COLLECTION _LIST _COMPLETED ,
FETCH _COLLECTION _LIST _FAILED : FETCH _COLLECTION _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 ,
2021-05-07 00:41:02 +02:00
CLEAR _CHANNEL _ERRORS : CLEAR _CHANNEL _ERRORS ,
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 ,
2021-05-07 00:41:02 +02:00
COLLECTION _PUBLISH _STARTED : COLLECTION _PUBLISH _STARTED ,
COLLECTION _PUBLISH _COMPLETED : COLLECTION _PUBLISH _COMPLETED ,
COLLECTION _PUBLISH _FAILED : COLLECTION _PUBLISH _FAILED ,
COLLECTION _PUBLISH _UPDATE _STARTED : COLLECTION _PUBLISH _UPDATE _STARTED ,
COLLECTION _PUBLISH _UPDATE _COMPLETED : COLLECTION _PUBLISH _UPDATE _COMPLETED ,
COLLECTION _PUBLISH _UPDATE _FAILED : COLLECTION _PUBLISH _UPDATE _FAILED ,
COLLECTION _PUBLISH _ABANDON _STARTED : COLLECTION _PUBLISH _ABANDON _STARTED ,
COLLECTION _PUBLISH _ABANDON _COMPLETED : COLLECTION _PUBLISH _ABANDON _COMPLETED ,
COLLECTION _PUBLISH _ABANDON _FAILED : COLLECTION _PUBLISH _ABANDON _FAILED ,
CLEAR _COLLECTION _ERRORS : CLEAR _COLLECTION _ERRORS ,
COLLECTION _ITEMS _RESOLVE _STARTED : COLLECTION _ITEMS _RESOLVE _STARTED ,
COLLECTION _ITEMS _RESOLVE _COMPLETED : COLLECTION _ITEMS _RESOLVE _COMPLETED ,
COLLECTION _ITEMS _RESOLVE _FAILED : COLLECTION _ITEMS _RESOLVE _FAILED ,
COLLECTION _NEW : COLLECTION _NEW ,
COLLECTION _DELETE : COLLECTION _DELETE ,
COLLECTION _PENDING : COLLECTION _PENDING ,
COLLECTION _EDIT : COLLECTION _EDIT ,
COLLECTION _COPY : COLLECTION _COPY ,
COLLECTION _SAVE : COLLECTION _SAVE ,
COLLECTION _ERROR : COLLECTION _ERROR ,
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
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 ,
2020-11-12 19:21:13 +01:00
USER _STATE _POPULATE : USER _STATE _POPULATE ,
SYNC _FATAL _ERROR : SYNC _FATAL _ERROR
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-08-27 18:29:29 +02:00
const FIRST _RUN _STARTED = 'first_run_started' ;
2020-02-16 20:52:58 +01:00
const INVITE _ACKNOWLEDGED = 'invite_acknowledged' ;
2020-08-24 04:38:45 +02:00
const FOLLOWING _ACKNOWLEDGED = 'following_acknowledged' ;
const TAGS _ACKNOWLEDGED = 'tags_acknowledged' ;
2020-08-24 04:43:00 +02:00
const REWARDS _ACKNOWLEDGED = 'rewards_acknowledged' ;
2019-04-03 19:12:51 +02:00
const LANGUAGE = 'language' ;
2020-10-15 20:34:25 +02:00
const SEARCH _IN _LANGUAGE = 'search_in_language' ;
2020-02-16 20:52:58 +01:00
const SHOW _MATURE = 'show_mature' ;
2020-10-23 20:36:16 +02:00
const HOMEPAGE = 'homepage' ;
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' ;
2021-09-06 19:06:32 +02:00
const AUTOPLAY _MEDIA = 'autoplay' ;
2020-07-14 17:38:19 +02:00
const AUTOPLAY _NEXT = 'autoplay_next' ;
2020-02-16 20:52:58 +01:00
const OS _NOTIFICATIONS _ENABLED = 'os_notifications_enabled' ;
const AUTO _DOWNLOAD = 'auto_download' ;
const AUTO _LAUNCH = 'auto_launch' ;
2020-08-13 18:59:44 +02:00
const TO _TRAY _WHEN _CLOSED = 'to_tray_when_closed' ;
2020-02-16 20:52:58 +01:00
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' ;
2020-08-11 11:10:38 +02:00
const ENABLE _PUBLISH _PREVIEW = 'enable-publish-preview' ;
2020-09-08 20:41:50 +02:00
const TILE _LAYOUT = 'tile_layout' ;
const VIDEO _THEATER _MODE = 'video_theater_mode' ;
2021-01-14 14:11:44 +01:00
const VIDEO _PLAYBACK _RATE = 'video_playback_rate' ;
2021-07-25 14:52:22 +02:00
const CUSTOM _COMMENTS _SERVER _ENABLED = 'custom_comments_server_enabled' ;
const CUSTOM _COMMENTS _SERVER _URL = 'custom_comments_server_url' ;
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-08-27 18:29:29 +02:00
FIRST _RUN _STARTED : FIRST _RUN _STARTED ,
2020-02-16 20:52:58 +01:00
INVITE _ACKNOWLEDGED : INVITE _ACKNOWLEDGED ,
2020-08-24 04:38:45 +02:00
FOLLOWING _ACKNOWLEDGED : FOLLOWING _ACKNOWLEDGED ,
TAGS _ACKNOWLEDGED : TAGS _ACKNOWLEDGED ,
2020-08-24 04:43:00 +02:00
REWARDS _ACKNOWLEDGED : REWARDS _ACKNOWLEDGED ,
2019-07-01 21:49:51 +02:00
LANGUAGE : LANGUAGE ,
2020-10-15 20:34:25 +02:00
SEARCH _IN _LANGUAGE : SEARCH _IN _LANGUAGE ,
2020-02-16 20:52:58 +01:00
SHOW _MATURE : SHOW _MATURE ,
2020-10-23 20:36:16 +02:00
HOMEPAGE : HOMEPAGE ,
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 ,
2021-09-06 19:06:32 +02:00
AUTOPLAY _MEDIA : AUTOPLAY _MEDIA ,
2020-07-14 17:38:19 +02:00
AUTOPLAY _NEXT : AUTOPLAY _NEXT ,
2020-02-16 20:52:58 +01:00
OS _NOTIFICATIONS _ENABLED : OS _NOTIFICATIONS _ENABLED ,
AUTO _DOWNLOAD : AUTO _DOWNLOAD ,
AUTO _LAUNCH : AUTO _LAUNCH ,
2020-08-13 18:59:44 +02:00
TO _TRAY _WHEN _CLOSED : TO _TRAY _WHEN _CLOSED ,
2020-02-16 20:52:58 +01:00
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 ,
2020-08-11 11:10:38 +02:00
ENABLE _PUBLISH _PREVIEW : ENABLE _PUBLISH _PREVIEW ,
2020-09-08 20:41:50 +02:00
TILE _LAYOUT : TILE _LAYOUT ,
VIDEO _THEATER _MODE : VIDEO _THEATER _MODE ,
2021-01-14 14:11:44 +01:00
VIDEO _PLAYBACK _RATE : VIDEO _PLAYBACK _RATE ,
2021-07-25 14:52:22 +02:00
CUSTOM _COMMENTS _SERVER _ENABLED : CUSTOM _COMMENTS _SERVER _ENABLED ,
CUSTOM _COMMENTS _SERVER _URL : CUSTOM _COMMENTS _SERVER _URL ,
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
* /
2020-07-14 17:38:19 +02:00
// DAEMON
const SDK _SYNC _KEYS = [ LBRYUM _SERVERS , SHARE _USAGE _DATA ] ;
// CLIENT
2021-09-06 19:06:32 +02:00
const CLIENT _SYNC _KEYS = [ SHOW _MATURE , HIDE _REPOSTS , SHOW _ANONYMOUS , INSTANT _PURCHASE _ENABLED , INSTANT _PURCHASE _MAX , THEME , AUTOPLAY _MEDIA , AUTOPLAY _NEXT , HIDE _BALANCE , HIDE _SPLASH _ANIMATION , FLOATING _PLAYER , DARK _MODE _TIMES , AUTOMATIC _DARK _MODE _ENABLED ] ;
2019-12-11 15:45:18 +01:00
2019-12-12 20:51:07 +01:00
var shared _preferences = /*#__PURE__*/ Object . freeze ( {
2020-07-14 17:38:19 +02:00
SDK _SYNC _KEYS : SDK _SYNC _KEYS ,
CLIENT _SYNC _KEYS : CLIENT _SYNC _KEYS
2019-12-11 15:45:18 +01:00
} ) ;
2021-06-04 15:22:54 +02:00
const COLLECTION _ID = 'lid' ;
const COLLECTION _INDEX = 'linx' ;
2021-05-07 00:41:02 +02:00
const COL _TYPE _PLAYLIST = 'playlist' ;
2021-06-02 21:20:55 +02:00
const COL _TYPE _CHANNELS = 'channelList' ;
2021-05-07 00:41:02 +02:00
const WATCH _LATER _ID = 'watchlater' ;
const FAVORITES _ID = 'favorites' ;
const FAVORITE _CHANNELS _ID = 'favoriteChannels' ;
const BUILTIN _LISTS = [ WATCH _LATER _ID , FAVORITES _ID , FAVORITE _CHANNELS _ID ] ;
2021-06-10 22:07:41 +02:00
const COL _KEY _EDITED = 'edited' ;
const COL _KEY _UNPUBLISHED = 'unpublished' ;
const COL _KEY _PENDING = 'pending' ;
const COL _KEY _SAVED = 'saved' ;
2021-05-07 00:41:02 +02:00
var collections = /*#__PURE__*/ Object . freeze ( {
COLLECTION _ID : COLLECTION _ID ,
COLLECTION _INDEX : COLLECTION _INDEX ,
COL _TYPE _PLAYLIST : COL _TYPE _PLAYLIST ,
COL _TYPE _CHANNELS : COL _TYPE _CHANNELS ,
WATCH _LATER _ID : WATCH _LATER _ID ,
FAVORITES _ID : FAVORITES _ID ,
FAVORITE _CHANNELS _ID : FAVORITE _CHANNELS _ID ,
2021-06-10 22:07:41 +02:00
BUILTIN _LISTS : BUILTIN _LISTS ,
COL _KEY _EDITED : COL _KEY _EDITED ,
COL _KEY _UNPUBLISHED : COL _KEY _UNPUBLISHED ,
COL _KEY _PENDING : COL _KEY _PENDING ,
COL _KEY _SAVED : COL _KEY _SAVED
2021-05-07 00:41:02 +02:00
} ) ;
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
2021-03-28 18:36:14 +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
2020-06-05 17:11:03 +02:00
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 ) ,
2021-02-11 16:04:52 +01:00
channel _sign : params => daemonCallWithResult ( 'channel_sign' , params ) ,
2019-04-23 19:22:14 +02:00
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 ) ,
2021-05-07 00:41:02 +02:00
collection _resolve : params => daemonCallWithResult ( 'collection_resolve' , params ) ,
collection _list : params => daemonCallWithResult ( 'collection_list' , params ) ,
collection _create : params => daemonCallWithResult ( 'collection_create' , params ) ,
collection _update : params => daemonCallWithResult ( 'collection_update' , 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 ) ,
2021-06-24 23:53:09 +02:00
txo _list : ( params = { } ) => daemonCallWithResult ( 'txo_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-03-10 03:10:30 +01: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 ( 'status' , params ) ,
stop : ( ) => lbryFirstCallWithResult ( 'stop' , { } ) ,
version : ( ) => lbryFirstCallWithResult ( 'version' , { } ) ,
// Upload to youtube
upload : ( params = { } ) => {
// Only upload when originally publishing for now
if ( ! params . file _path ) {
2020-07-08 07:40:43 +02:00
return Promise . resolve ( ) ;
2020-03-10 03:10:30 +01:00
}
2020-07-08 00:06:59 +02:00
const uploadParams = {
Title : params . title ,
Description : params . description ,
FilePath : params . file _path ,
Category : '' ,
Keywords : ''
} ;
2020-03-10 03:10:30 +01:00
return lbryFirstCallWithResult ( 'youtube.Upload' , uploadParams ) ;
} ,
2020-07-10 18:36:30 +02:00
hasYTAuth : token => {
const hasYTAuthParams = { } ;
hasYTAuthParams . AuthToken = token ;
return lbryFirstCallWithResult ( 'youtube.HasAuth' , hasYTAuthParams ) ;
2020-03-10 03:10:30 +01:00
} ,
ytSignup : ( ) => {
const emptyParams = { } ;
return lbryFirstCallWithResult ( 'youtube.Signup' , emptyParams ) ;
} ,
2020-07-08 07:40:43 +02:00
remove : ( ) => {
const emptyParams = { } ;
return lbryFirstCallWithResult ( 'youtube.Remove' , emptyParams ) ;
} ,
2020-03-10 03:10:30 +01:00
// 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 ( ) ;
2020-07-08 07:40:43 +02:00
const paramsArray = [ params ] ;
2020-03-10 03:10:30 +01:00
const options = {
method : 'POST' ,
headers : LbryFirst . apiRequestHeaders ,
body : JSON . stringify ( {
jsonrpc : '2.0' ,
method ,
2020-07-08 07:40:43 +02:00
params : paramsArray ,
2020-03-10 03:10:30 +01:00
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 = { } ) {
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
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
2021-07-14 21:00:11 +02:00
const regexInvalidURI = /[ =&#:$@%?;/\\"<>%{}|^~[\]`\u{0000}-\u{0008}\u{000b}-\u{000c}\u{000e}-\u{001F}\u{D800}-\u{DFFF}\u{FFFE}-\u{FFFF}]/u ;
2019-04-03 19:12:51 +02:00
const regexAddress = /^(b|r)(?=[^0OIl]{32,33})[0-9A-Za-z]{32,33}$/ ;
2019-08-20 22:00:26 +02:00
const regexPartProtocol = '^((?:lbry://)?)' ;
const regexPartStreamOrChannelName = '([^:$#/]*)' ;
const regexPartModifierSeparator = '([:$#]?)([^/]*)' ;
2019-08-24 04:43:49 +02:00
const queryStringBreaker = '^([\\S]+)([?][\\S]*)' ;
const separateQuerystring = new RegExp ( queryStringBreaker ) ;
2019-04-03 19:12:51 +02:00
2021-07-14 21:00:11 +02:00
const MOD _SEQUENCE _SEPARATOR = '*' ;
const MOD _CLAIM _ID _SEPARATOR _OLD = '#' ;
const MOD _CLAIM _ID _SEPARATOR = ':' ;
const MOD _BID _POSITION _SEPARATOR = '$' ;
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
2020-10-20 17:47:37 +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 ;
2020-10-20 17:47:37 +02:00
const qsRegexResult = separateQuerystring . exec ( url ) ;
2019-08-24 04:43:49 +02:00
if ( qsRegexResult ) {
[ QSStrippedURL , qs ] = qsRegexResult . slice ( 1 ) . map ( match => match || null ) ;
}
2019-04-03 19:12:51 +02:00
2020-10-20 17:47:37 +02:00
const cleanURL = QSStrippedURL || url ;
2019-08-24 04:43:49 +02:00
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 ( ' ' ) ) {
2020-10-20 17:47:37 +02:00
throw new 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
}
2021-07-14 21:00:11 +02:00
if ( modSeperator === MOD _CLAIM _ID _SEPARATOR || MOD _CLAIM _ID _SEPARATOR _OLD ) {
2019-08-20 22:00:26 +02:00
claimId = modValue ;
2021-07-14 21:00:11 +02:00
} else if ( modSeperator === MOD _SEQUENCE _SEPARATOR ) {
2019-08-20 22:00:26 +02:00
claimSequence = modValue ;
2021-07-14 21:00:11 +02:00
} else if ( modSeperator === MOD _BID _POSITION _SEPARATOR ) {
2019-08-20 22:00:26 +02:00
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
}
2021-07-15 21:46:31 +02:00
function splitBySeparator ( uri ) {
const protocolLength = 7 ;
return uri . startsWith ( 'lbry://' ) ? uri . slice ( protocolLength ) . split ( /[#:*]/ ) : uri . split ( /#:\*\$/ ) ;
}
function isURIEqual ( uriA , uriB ) {
const parseA = parseURI ( normalizeURI ( uriA ) ) ;
const parseB = parseURI ( normalizeURI ( uriB ) ) ;
if ( parseA . isChannel ) {
if ( parseB . isChannel && parseA . channelClaimId === parseB . channelClaimId ) {
return true ;
}
} else if ( parseA . streamClaimId === parseB . streamClaimId ) {
return true ;
} else {
return false ;
}
}
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 */
2020-07-27 21:35:27 +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 ; } ;
2019-10-15 05:35:38 +02:00
function extractUserState ( rawObj ) {
if ( rawObj && rawObj . version === '0.1' && rawObj . value ) {
2020-02-25 14:52:39 +01:00
const {
subscriptions ,
2020-10-30 17:45:59 +01:00
following ,
2020-02-25 14:52:39 +01:00
tags ,
blocked ,
2021-04-07 08:27:57 +02:00
coin _swap _codes ,
2020-02-25 14:52:39 +01:00
settings ,
app _welcome _version ,
2021-05-07 00:41:02 +02:00
sharing _3P ,
2021-06-01 15:09:21 +02:00
unpublishedCollections ,
2021-08-01 22:58:45 +02:00
editedCollections ,
2021-06-01 15:09:21 +02:00
builtinCollections ,
savedCollections
2020-02-25 14:52:39 +01:00
} = rawObj . value ;
2019-10-15 05:35:38 +02:00
2021-08-01 22:58:45 +02:00
return _extends$1 ( { } , subscriptions ? { subscriptions } : { } , following ? { following } : { } , tags ? { tags } : { } , blocked ? { blocked } : { } , coin _swap _codes ? { coin _swap _codes } : { } , settings ? { settings } : { } , app _welcome _version ? { app _welcome _version } : { } , sharing _3P ? { sharing _3P } : { } , unpublishedCollections ? { unpublishedCollections } : { } , editedCollections ? { editedCollections } : { } , builtinCollections ? { builtinCollections } : { } , savedCollections ? { savedCollections } : { } ) ;
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 ,
2020-10-30 17:45:59 +01:00
following ,
2020-02-25 14:52:39 +01:00
tags ,
blocked ,
2021-04-07 08:27:57 +02:00
coin _swap _codes ,
2020-02-25 14:52:39 +01:00
settings ,
app _welcome _version ,
2021-05-07 00:41:02 +02:00
sharing _3P ,
2021-06-01 15:09:21 +02:00
unpublishedCollections ,
2021-08-01 22:58:45 +02:00
editedCollections ,
2021-06-01 15:09:21 +02:00
builtinCollections ,
savedCollections
2020-02-25 14:52:39 +01:00
} = 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 ,
2020-10-30 17:45:59 +01:00
following ,
2020-02-25 14:52:39 +01:00
tags ,
blocked ,
2021-04-07 08:27:57 +02:00
coinSwapCodes : coin _swap _codes ,
2020-02-25 14:52:39 +01:00
settings ,
welcomeVersion : app _welcome _version ,
2021-05-07 00:41:02 +02:00
allowAnalytics : sharing _3P ,
2021-06-01 15:09:21 +02:00
unpublishedCollections ,
2021-08-01 22:58:45 +02:00
editedCollections ,
2021-06-01 15:09:21 +02:00
builtinCollections ,
savedCollections
2020-02-25 14:52:39 +01:00
}
2020-01-13 23:00:04 +01:00
} ) ;
2019-10-15 05:35:38 +02:00
} ;
}
function doPreferenceSet ( key , value , version , success , fail ) {
2020-11-12 19:21:13 +01:00
return dispatch => {
const preference = {
type : typeof value ,
version ,
value
} ;
2019-10-15 05:35:38 +02:00
2020-11-12 19:21:13 +01:00
const options = {
key ,
value : JSON . stringify ( preference )
} ;
2019-10-15 05:35:38 +02:00
2020-11-12 19:21:13 +01:00
lbryProxy . preference _set ( options ) . then ( ( ) => {
2020-11-12 20:40:10 +01:00
if ( success ) {
success ( preference ) ;
}
2020-11-12 19:27:03 +01:00
} ) . catch ( err => {
2020-11-12 19:21:13 +01:00
dispatch ( {
2020-11-12 19:27:03 +01:00
type : SYNC _FATAL _ERROR ,
error : err
2020-11-12 19:21:13 +01:00
} ) ;
if ( fail ) {
fail ( ) ;
}
} ) ;
} ;
2019-10-15 05:35:38 +02:00
}
function doPreferenceGet ( key , success , fail ) {
2020-11-12 19:21:13 +01:00
return dispatch => {
const options = {
key
} ;
2019-10-15 05:35:38 +02:00
2020-11-12 19:21:13 +01:00
return lbryProxy . preference _get ( options ) . then ( result => {
if ( result ) {
const preference = result [ key ] ;
return success ( preference ) ;
}
2019-10-15 05:35:38 +02:00
2020-11-12 19:21:13 +01:00
return success ( null ) ;
} ) . catch ( err => {
dispatch ( {
2020-11-12 19:27:03 +01:00
type : SYNC _FATAL _ERROR ,
error : err
2020-11-12 19:21:13 +01:00
} ) ;
if ( fail ) {
fail ( err ) ;
}
} ) ;
} ;
2019-10-15 05:35:38 +02:00
}
//
2021-04-25 03:23:34 +02:00
const RUN _PREFERENCES _DELAY _MS = 2000 ;
2019-10-15 05:35:38 +02:00
const SHARED _PREFERENCE _VERSION = '0.1' ;
let oldShared = { } ;
2021-04-25 03:23:34 +02:00
let timeout ;
2020-09-16 15:56:24 +02:00
const buildSharedStateMiddleware = ( actions , sharedStateFilters , sharedStateCb ) => ( {
getState ,
dispatch
} ) => next => action => {
2019-10-15 05:35:38 +02:00
const currentState = getState ( ) ;
// We don't care if sync is disabled here, we always want to backup preferences to the wallet
2020-07-14 19:22:47 +02:00
if ( ! actions . includes ( action . type ) || typeof action === 'function' ) {
2019-10-15 05:35:38 +02:00
return next ( action ) ;
}
2021-04-25 03:23:34 +02:00
clearTimeout ( timeout ) ;
2019-10-15 05:35:38 +02:00
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
2021-04-25 03:23:34 +02:00
function runPreferences ( ) {
const nextState = getState ( ) ;
const syncEnabled = nextState . settings && nextState . settings . clientSettings && nextState . settings . clientSettings . enable _sync ;
const hasVerifiedEmail = nextState . user && nextState . user . user && nextState . user . user . has _verified _email ;
const preferenceKey = syncEnabled && hasVerifiedEmail ? 'shared' : 'local' ;
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 ) ;
}
2019-10-15 05:35:38 +02:00
2021-04-25 03:23:34 +02:00
shared [ key ] = value ;
} ) ;
2019-10-15 05:35:38 +02:00
2021-04-25 03:23:34 +02:00
if ( ! isEqual ( oldShared , shared ) ) {
// only update if the preference changed from last call in the same session
oldShared = shared ;
dispatch ( doPreferenceSet ( preferenceKey , shared , SHARED _PREFERENCE _VERSION ) ) ;
}
2019-10-15 05:35:38 +02:00
2021-04-25 03:23:34 +02:00
if ( sharedStateCb ) {
// Pass dispatch to the callback to consumers can dispatch actions in response to preference set
sharedStateCb ( { dispatch , getState } ) ;
}
clearTimeout ( timeout ) ;
return actionResult ;
}
timeout = setTimeout ( runPreferences , RUN _PREFERENCES _DELAY _MS ) ;
2019-10-15 05:35:38 +02:00
} ;
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 : {
2020-10-20 06:18:21 +02:00
id : uuid . v4 ( ) ,
2019-04-03 19:12:51 +02:00
params
}
} ;
}
function doDismissToast ( ) {
return {
type : DISMISS _TOAST
} ;
}
function doError ( error ) {
return {
type : CREATE _ERROR ,
data : {
error
}
} ;
}
function doDismissError ( ) {
return {
type : DISMISS _ERROR
} ;
}
2021-04-17 14:50:03 +02:00
// JSON parser
const parseJson = ( data , filters = [ ] ) => {
const list = data . map ( item => {
const temp = { } ;
// Apply filters
Object . entries ( item ) . forEach ( ( [ key , value ] ) => {
if ( ! filters . includes ( key ) ) temp [ key ] = value ;
} ) ;
return temp ;
} ) ;
// Beautify JSON
return JSON . stringify ( list , null , '\t' ) ;
} ;
// CSV Parser
// No need for an external module:
// https://gist.github.com/btzr-io/55c3450ea3d709fc57540e762899fb85
const parseCsv = ( data , filters = [ ] ) => {
// Get items for header
const getHeaders = item => {
const list = [ ] ;
// Apply filters
Object . entries ( item ) . forEach ( ( [ key ] ) => {
if ( ! filters . includes ( key ) ) list . push ( key ) ;
} ) ;
// return headers
return list . join ( ',' ) ;
} ;
// Get rows content
const getData = list => list . map ( item => {
const row = [ ] ;
// Apply filters
Object . entries ( item ) . forEach ( ( [ key , value ] ) => {
if ( ! filters . includes ( key ) ) row . push ( value ) ;
} ) ;
// return rows
return row . join ( ',' ) ;
} ) . join ( '\n' ) ;
// Return CSV string
return ` ${ getHeaders ( data [ 0 ] ) } \n ${ getData ( data ) } ` ;
} ;
const parseData = ( data , format , filters = [ ] ) => {
// Check for validation
const valid = data && data [ 0 ] && format ;
// Pick a format
const formats = {
csv : list => parseCsv ( list , filters ) ,
json : list => parseJson ( list , filters )
} ;
// Return parsed data: JSON || CSV
return valid && formats [ format ] ? formats [ format ] ( data ) : undefined ;
} ;
2020-07-27 21:35:27 +02:00
const selectState = state => state . wallet || { } ;
2019-08-15 08:13:50 +02:00
2020-07-27 21:35:27 +02:00
const selectWalletState = selectState ;
2019-08-15 08:13:50 +02:00
2020-07-27 21:35:27 +02:00
const selectWalletIsEncrypted = reselect . createSelector ( selectState , state => state . walletIsEncrypted ) ;
2019-08-15 08:13:50 +02:00
2020-07-27 21:35:27 +02:00
const selectWalletEncryptPending = reselect . createSelector ( selectState , state => state . walletEncryptPending ) ;
2019-08-15 08:13:50 +02:00
2020-07-27 21:35:27 +02:00
const selectWalletEncryptSucceeded = reselect . createSelector ( selectState , state => state . walletEncryptSucceded ) ;
2019-08-15 08:13:50 +02:00
2020-07-27 21:35:27 +02:00
const selectPendingSupportTransactions = reselect . createSelector ( selectState , state => state . pendingSupportTransactions ) ;
2020-03-25 03:46:35 +01:00
2021-02-03 23:52:01 +01:00
const selectPendingOtherTransactions = reselect . createSelector ( selectState , state => state . pendingTxos ) ;
2020-12-30 23:25:57 +01:00
2020-07-27 21:35:27 +02:00
const selectAbandonClaimSupportError = reselect . createSelector ( selectState , state => state . abandonClaimSupportError ) ;
2020-04-01 20:26:38 +02:00
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 ;
} ) ;
2020-07-27 21:35:27 +02:00
const selectWalletEncryptResult = reselect . createSelector ( selectState , state => state . walletEncryptResult ) ;
2019-08-15 08:13:50 +02:00
2020-07-27 21:35:27 +02:00
const selectWalletDecryptPending = reselect . createSelector ( selectState , state => state . walletDecryptPending ) ;
2019-08-15 08:13:50 +02:00
2020-07-27 21:35:27 +02:00
const selectWalletDecryptSucceeded = reselect . createSelector ( selectState , state => state . walletDecryptSucceded ) ;
2019-08-15 08:13:50 +02:00
2020-07-27 21:35:27 +02:00
const selectWalletDecryptResult = reselect . createSelector ( selectState , state => state . walletDecryptResult ) ;
2019-08-15 08:13:50 +02:00
2020-07-27 21:35:27 +02:00
const selectWalletUnlockPending = reselect . createSelector ( selectState , state => state . walletUnlockPending ) ;
2019-08-15 08:13:50 +02:00
2020-07-27 21:35:27 +02:00
const selectWalletUnlockSucceeded = reselect . createSelector ( selectState , state => state . walletUnlockSucceded ) ;
2019-08-15 08:13:50 +02:00
2020-07-27 21:35:27 +02:00
const selectWalletUnlockResult = reselect . createSelector ( selectState , state => state . walletUnlockResult ) ;
2019-08-15 08:13:50 +02:00
2020-07-27 21:35:27 +02:00
const selectWalletLockPending = reselect . createSelector ( selectState , state => state . walletLockPending ) ;
2019-08-15 08:13:50 +02:00
2020-07-27 21:35:27 +02:00
const selectWalletLockSucceeded = reselect . createSelector ( selectState , state => state . walletLockSucceded ) ;
2019-08-15 08:13:50 +02:00
2020-07-27 21:35:27 +02:00
const selectWalletLockResult = reselect . createSelector ( selectState , state => state . walletLockResult ) ;
2019-08-15 08:13:50 +02:00
2020-07-27 21:35:27 +02:00
const selectBalance = reselect . createSelector ( selectState , state => state . balance ) ;
2019-08-15 08:13:50 +02:00
2020-07-27 21:35:27 +02:00
const selectTotalBalance = reselect . createSelector ( selectState , state => state . totalBalance ) ;
2019-08-15 08:13:50 +02:00
2020-07-27 21:35:27 +02:00
const selectReservedBalance = reselect . createSelector ( selectState , state => state . reservedBalance ) ;
2019-09-24 00:56:53 +02:00
2020-07-27 21:35:27 +02:00
const selectClaimsBalance = reselect . createSelector ( selectState , state => state . claimsBalance ) ;
2019-09-24 00:56:53 +02:00
2020-07-27 21:35:27 +02:00
const selectSupportsBalance = reselect . createSelector ( selectState , state => state . supportsBalance ) ;
2019-09-24 00:56:53 +02:00
2020-07-27 21:35:27 +02:00
const selectTipsBalance = reselect . createSelector ( selectState , state => state . tipsBalance ) ;
2019-09-24 00:56:53 +02:00
2020-07-27 21:35:27 +02:00
const selectTransactionsById = reselect . createSelector ( selectState , state => state . transactions || { } ) ;
2019-08-15 08:13:50 +02:00
2020-07-27 21:35:27 +02:00
const selectSupportsByOutpoint = reselect . createSelector ( selectState , state => state . supports || { } ) ;
2019-08-15 08:13:50 +02:00
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 ) ;
2020-07-27 21:35:27 +02:00
const selectIsFetchingTransactions = reselect . createSelector ( selectState , state => state . fetchingTransactions ) ;
2019-08-15 08:13:50 +02:00
2021-04-17 14:50:03 +02:00
/ * *
* CSV of 'selectTransactionItems' .
* /
const selectTransactionsFile = reselect . createSelector ( selectTransactionItems , transactions => {
if ( ! transactions || transactions . length === 0 ) {
// No data.
return undefined ;
}
const parsed = parseData ( transactions , 'csv' ) ;
if ( ! parsed ) {
// Invalid data, or failed to parse.
return null ;
}
return parsed ;
} ) ;
2020-07-27 21:35:27 +02:00
const selectIsSendingSupport = reselect . createSelector ( selectState , state => state . sendingSupport ) ;
2019-08-15 08:13:50 +02:00
2020-07-27 21:35:27 +02:00
const selectReceiveAddress = reselect . createSelector ( selectState , state => state . receiveAddress ) ;
2019-08-15 08:13:50 +02:00
2020-07-27 21:35:27 +02:00
const selectGettingNewAddress = reselect . createSelector ( selectState , state => state . gettingNewAddress ) ;
2019-08-15 08:13:50 +02:00
2020-07-27 21:35:27 +02:00
const selectDraftTransaction = reselect . createSelector ( selectState , state => state . draftTransaction || { } ) ;
2019-08-15 08:13:50 +02:00
const selectDraftTransactionAmount = reselect . createSelector ( selectDraftTransaction , draft => draft . amount ) ;
const selectDraftTransactionAddress = reselect . createSelector ( selectDraftTransaction , draft => draft . address ) ;
const selectDraftTransactionError = reselect . createSelector ( selectDraftTransaction , draft => draft . error ) ;
2020-07-27 21:35:27 +02:00
const selectBlocks = reselect . createSelector ( selectState , state => state . blocks ) ;
2019-08-15 08:13:50 +02:00
2020-07-27 21:35:27 +02:00
const selectCurrentHeight = reselect . createSelector ( selectState , state => state . latestBlock ) ;
2019-08-15 08:13:50 +02:00
2020-07-27 21:35:27 +02:00
const selectTransactionListFilter = reselect . createSelector ( selectState , state => state . transactionListFilter || '' ) ;
2019-08-15 08:13:50 +02:00
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-07-27 21:35:27 +02:00
const selectTxoPageParams = reselect . createSelector ( selectState , state => state . txoFetchParams ) ;
2020-04-10 14:16:27 +02:00
2020-07-27 21:35:27 +02:00
const selectTxoPage = reselect . createSelector ( selectState , state => state . txoPage && state . txoPage . items || [ ] ) ;
2020-04-10 14:16:27 +02:00
2020-07-27 21:35:27 +02:00
const selectTxoPageNumber = reselect . createSelector ( selectState , state => state . txoPage && state . txoPage . page || 1 ) ;
2020-04-10 14:16:27 +02:00
2020-07-27 21:35:27 +02:00
const selectTxoItemCount = reselect . createSelector ( selectState , state => state . txoPage && state . txoPage . total _items || 1 ) ;
2020-04-10 14:16:27 +02:00
2020-07-27 21:35:27 +02:00
const selectFetchingTxosError = reselect . createSelector ( selectState , state => state . fetchingTxosError ) ;
2020-04-10 14:16:27 +02:00
2020-07-27 21:35:27 +02:00
const selectIsFetchingTxos = reselect . createSelector ( selectState , state => state . fetchingTxos ) ;
2020-04-10 14:16:27 +02:00
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 ) ;
2020-07-27 21:35:27 +02:00
const selectIsWalletReconnecting = reselect . createSelector ( selectState , state => state . walletReconnecting ) ;
2019-12-18 17:47:18 +01:00
2020-12-30 23:25:57 +01:00
const selectIsFetchingUtxoCounts = reselect . createSelector ( selectState , state => state . fetchingUtxoCounts ) ;
const selectIsConsolidatingUtxos = reselect . createSelector ( selectState , state => state . consolidatingUtxos ) ;
2021-01-27 16:01:55 +01:00
const selectIsMassClaimingTips = reselect . createSelector ( selectState , state => state . massClaimingTips ) ;
2021-02-03 23:52:01 +01:00
const selectPendingConsolidateTxid = reselect . createSelector ( selectState , state => state . pendingConsolidateTxid ) ;
const selectPendingMassClaimTxid = reselect . createSelector ( selectState , state => state . pendingMassClaimTxid ) ;
2020-12-30 23:25:57 +01:00
const selectUtxoCounts = reselect . createSelector ( selectState , state => state . utxoCounts ) ;
2020-07-27 21:35:27 +02:00
var _extends$2 = Object . assign || function ( target ) { for ( var i = 1 ; i < arguments . length ; i ++ ) { var source = arguments [ i ] ; for ( var key in source ) { if ( Object . prototype . hasOwnProperty . call ( source , key ) ) { target [ key ] = source [ key ] ; } } } return target ; } ;
2019-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
2020-07-27 21:35:27 +02:00
const matureTagMap = MATURE _TAGS . reduce ( ( acc , tag ) => _extends$2 ( { } , acc , { [ tag ] : true } ) , { } ) ;
2019-04-23 19:22:14 +02:00
const isClaimNsfw = claim => {
if ( ! claim ) {
throw new Error ( 'No claim passed to isClaimNsfw()' ) ;
}
if ( ! claim . value ) {
return false ;
}
const tags = claim . value . tags || [ ] ;
for ( let i = 0 ; i < tags . length ; i += 1 ) {
2019-04-23 21:02:32 +02:00
const tag = tags [ i ] . toLowerCase ( ) ;
2019-07-02 22:33:57 +02:00
if ( matureTagMap [ tag ] ) {
2019-04-23 19:22:14 +02:00
return true ;
}
}
return false ;
} ;
2019-07-30 17:48:45 +02:00
function createNormalizedClaimSearchKey ( options ) {
// Ignore page because we don't care what the last page searched was, we want everything
// Ignore release_time because that will change depending on when you call claim_search ex: release_time: ">12344567"
2019-08-20 22:00:26 +02:00
const rest = _objectWithoutProperties$1 ( options , [ 'page' , 'release_time' ] ) ;
2019-07-30 17:48:45 +02:00
const query = JSON . stringify ( rest ) ;
return query ;
}
2019-07-26 08:27:09 +02:00
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-07-27 21:35:27 +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 ; } ;
2020-05-08 22:47:33 +02:00
2020-07-27 21:35:27 +02:00
const selectState$1 = state => state . claims || { } ;
2019-04-03 19:12:51 +02:00
2021-06-24 20:26:51 +02:00
const selectById = reselect . createSelector ( selectState$1 , state => state . byId || { } ) ;
const selectPendingClaimsById = reselect . createSelector ( selectState$1 , state => state . pendingById || { } ) ;
const selectClaimsById = reselect . createSelector ( selectById , selectPendingClaimsById , ( byId , pendingById ) => {
2021-06-24 23:53:09 +02:00
return Object . assign ( byId , pendingById ) ; // do I need merged to keep metadata?
2021-06-24 20:26:51 +02:00
} ) ;
2019-04-03 19:12:51 +02:00
2020-07-27 21:35:27 +02:00
const selectClaimIdsByUri = reselect . createSelector ( selectState$1 , state => state . claimsByUri || { } ) ;
2020-03-25 03:46:35 +01:00
2020-07-27 21:35:27 +02:00
const selectCurrentChannelPage = reselect . createSelector ( selectState$1 , state => state . currentChannelPage || 1 ) ;
2019-04-03 19:12:51 +02:00
2020-07-27 21:35:27 +02:00
const selectCreatingChannel = reselect . createSelector ( selectState$1 , state => state . creatingChannel ) ;
2019-08-27 06:42:52 +02:00
2020-07-27 21:35:27 +02:00
const selectCreateChannelError = reselect . createSelector ( selectState$1 , state => state . createChannelError ) ;
2019-09-10 20:14:40 +02:00
2020-07-27 21:35:27 +02:00
const selectRepostLoading = reselect . createSelector ( selectState$1 , state => state . repostLoading ) ;
2020-02-10 16:49:45 +01:00
2020-07-27 21:35:27 +02:00
const selectRepostError = reselect . createSelector ( selectState$1 , state => state . repostError ) ;
2020-02-10 16:49:45 +01:00
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 ;
} ) ;
2020-07-27 21:35:27 +02:00
const selectAllClaimsByChannel = reselect . createSelector ( selectState$1 , state => state . paginatedClaimsByChannel || { } ) ;
2019-04-03 19:12:51 +02:00
2021-07-05 21:41:55 +02:00
const selectPendingIds = reselect . createSelector ( selectState$1 , state => Object . keys ( state . pendingById ) || [ ] ) ;
2019-04-03 19:12:51 +02:00
2021-06-24 20:26:51 +02:00
const selectPendingClaims = reselect . createSelector ( selectPendingClaimsById , pendingById => Object . values ( pendingById ) ) ;
2021-03-24 00:55:16 +01:00
2021-06-24 20:26:51 +02:00
const makeSelectClaimIsPending = uri => reselect . createSelector ( selectClaimIdsByUri , selectPendingClaimsById , ( idsByUri , pendingById ) => {
2020-06-17 03:56:51 +02:00
const claimId = idsByUri [ normalizeURI ( uri ) ] ;
2019-07-11 21:00:45 +02:00
if ( claimId ) {
2021-06-24 20:26:51 +02:00
return Boolean ( pendingById [ 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
} ) ;
2021-06-24 20:26:51 +02:00
const makeSelectClaimIdIsPending = claimId => reselect . createSelector ( selectPendingClaimsById , pendingById => {
return Boolean ( pendingById [ claimId ] ) ;
2021-06-23 16:43:17 +02:00
} ) ;
2021-05-07 00:41:02 +02:00
const makeSelectClaimIdForUri = uri => reselect . createSelector ( selectClaimIdsByUri , claimIds => claimIds [ uri ] ) ;
2020-07-27 21:35:27 +02:00
const selectReflectingById = reselect . createSelector ( selectState$1 , state => state . reflectingById ) ;
2019-04-03 19:12:51 +02:00
2021-03-05 19:32:27 +01:00
const makeSelectClaimForClaimId = claimId => reselect . createSelector ( selectClaimsById , byId => byId [ claimId ] ) ;
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
}
2021-02-02 22:18:48 +01:00
const repostedClaim = claim && claim . reposted _claim ;
2020-02-12 15:43:41 +01:00
if ( repostedClaim && returnRepost ) {
2021-03-15 05:50:11 +01:00
const channelUrl = claim . signing _channel && ( claim . signing _channel . canonical _url || claim . signing _channel . permanent _url ) ;
2020-01-30 23:44:08 +01:00
2020-07-27 21:35:27 +02:00
return _extends$3 ( { } , repostedClaim , {
2021-07-15 21:46:31 +02:00
repost _url : normalizeURI ( uri ) ,
2020-12-17 04:35:12 +01:00
repost _channel _url : channelUrl ,
2020-12-17 15:46:17 +01:00
repost _bid _amount : claim && claim . meta && claim . meta . effective _amount
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-07-27 21:35:27 +02:00
const selectMyClaimsRaw = reselect . createSelector ( selectState$1 , selectClaimsById , ( state , byId ) => {
2020-03-25 03:46:35 +01:00
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
2020-07-27 21:35:27 +02:00
const selectAbandoningIds = reselect . createSelector ( selectState$1 , state => Object . keys ( state . abandoningById || { } ) ) ;
2019-04-03 19:12:51 +02:00
2020-07-24 16:40:29 +02:00
const makeSelectAbandoningClaimById = claimId => reselect . createSelector ( selectAbandoningIds , ids => ids . includes ( claimId ) ) ;
const makeSelectIsAbandoningClaimForUri = uri => reselect . createSelector ( selectClaimIdsByUri , selectAbandoningIds , ( claimIdsByUri , abandoningById ) => {
const claimId = claimIdsByUri [ normalizeURI ( uri ) ] ;
return abandoningById . indexOf ( claimId ) >= 0 ;
} ) ;
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-07-27 21:35:27 +02:00
const selectMyPurchases = reselect . createSelector ( selectState$1 , state => state . myPurchases ) ;
2020-05-08 22:47:33 +02:00
2020-07-27 21:35:27 +02:00
const selectPurchaseUriSuccess = reselect . createSelector ( selectState$1 , state => state . purchaseUriSuccess ) ;
2020-05-18 22:40:33 +02:00
2020-07-27 21:35:27 +02:00
const selectMyPurchasesCount = reselect . createSelector ( selectState$1 , state => state . myPurchasesPageTotalResults ) ;
2020-05-08 22:47:33 +02:00
2020-07-27 21:35:27 +02:00
const selectIsFetchingMyPurchases = reselect . createSelector ( selectState$1 , state => state . fetchingMyPurchases ) ;
2020-05-08 22:47:33 +02:00
2020-07-27 21:35:27 +02:00
const selectFetchingMyPurchasesError = reselect . createSelector ( selectState$1 , state => state . fetchingMyPurchasesError ) ;
2020-05-08 22:47:33 +02:00
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 ;
} ) ;
2020-07-27 21:35:27 +02:00
const selectAllFetchingChannelClaims = reselect . createSelector ( selectState$1 , 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 ] ) ;
} ) ;
2021-06-24 20:26:51 +02:00
// THIS IS LEFT OVER FROM ONE TAB CHANNEL_CONTENT
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' ] ;
} ) ;
2021-06-24 20:26:51 +02:00
// THIS IS LEFT OVER FROM ONE_TAB CHANNEL CONTENT
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 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 ;
} ) ;
2020-12-17 04:35:12 +01:00
const makeSelectEffectiveAmountForUri = uri => reselect . createSelector ( makeSelectClaimForUri ( uri , false ) , claim => {
2020-12-16 04:31:33 +01:00
return claim && claim . meta && typeof claim . meta . effective _amount === 'string' && Number ( claim . meta . effective _amount ) ;
2020-12-11 05:03:32 +01:00
} ) ;
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
} ) ;
2020-07-27 21:35:27 +02:00
const selectIsFetchingClaimListMine = reselect . createSelector ( selectState$1 , state => state . isFetchingClaimListMine ) ;
2019-04-03 19:12:51 +02:00
2020-07-27 21:35:27 +02:00
const selectMyClaimsPage = reselect . createSelector ( selectState$1 , state => state . myClaimsPageResults || [ ] ) ;
2020-04-25 22:31:53 +02:00
2020-07-27 21:35:27 +02:00
const selectMyClaimsPageNumber = reselect . createSelector ( selectState$1 , state => state . claimListMinePage && state . claimListMinePage . items || [ ] , state => state . txoPage && state . txoPage . page || 1 ) ;
2020-04-25 22:31:53 +02:00
2020-07-27 21:35:27 +02:00
const selectMyClaimsPageItemCount = reselect . createSelector ( selectState$1 , state => state . myClaimsPageTotalResults || 1 ) ;
2020-04-25 22:31:53 +02:00
2020-07-27 21:35:27 +02:00
const selectFetchingMyClaimsPageError = reselect . createSelector ( selectState$1 , state => state . fetchingClaimListMinePageError ) ;
2020-04-25 22:31:53 +02:00
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
} ) ;
2021-06-23 16:43:17 +02:00
const selectMyClaimsWithoutChannels = reselect . createSelector ( selectMyClaims , myClaims => myClaims . filter ( claim => 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 ;
} ) ;
2020-07-27 21:35:27 +02:00
const selectFetchingMyChannels = reselect . createSelector ( selectState$1 , state => state . fetchingMyChannels ) ;
2019-04-03 19:12:51 +02:00
2021-05-07 00:41:02 +02:00
const selectFetchingMyCollections = reselect . createSelector ( selectState$1 , state => state . fetchingMyCollections ) ;
2020-07-27 21:35:27 +02:00
const selectMyChannelClaims = reselect . createSelector ( selectState$1 , 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 ) ;
2021-05-07 00:41:02 +02:00
const selectMyCollectionIds = reselect . createSelector ( selectState$1 , state => state . myCollectionClaims ) ;
2020-07-27 21:35:27 +02:00
const selectResolvingUris = reselect . createSelector ( selectState$1 , state => state . resolvingUris || [ ] ) ;
2019-04-03 19:12:51 +02:00
2020-07-27 21:35:27 +02:00
const selectChannelImportPending = reselect . createSelector ( selectState$1 , state => state . pendingChannelImport ) ;
2019-09-12 21:06:49 +02:00
2019-04-03 19:12:51 +02:00
const makeSelectIsUriResolving = uri => reselect . createSelector ( selectResolvingUris , resolvingUris => resolvingUris && resolvingUris . indexOf ( uri ) !== - 1 ) ;
2020-07-27 21:35:27 +02:00
const selectPlayingUri = reselect . createSelector ( selectState$1 , state => state . playingUri ) ;
2019-04-03 19:12:51 +02:00
2020-07-27 21:35:27 +02:00
const selectChannelClaimCounts = reselect . createSelector ( selectState$1 , state => state . channelClaimCounts || { } ) ;
2019-04-03 19:12:51 +02:00
2021-06-24 20:26:51 +02:00
const makeSelectPendingClaimForUri = uri => reselect . createSelector ( selectPendingClaimsById , pendingById => {
2020-12-14 01:17:16 +01:00
let uriStreamName ;
let uriChannelName ;
try {
2021-06-24 23:53:09 +02:00
( { streamName : uriStreamName , channelName : uriChannelName } = parseURI ( uri ) ) ;
2020-12-14 01:17:16 +01:00
} catch ( e ) {
return null ;
}
2021-06-24 20:26:51 +02:00
const pendingClaims = Object . values ( pendingById ) ;
2020-12-04 01:25:41 +01:00
const matchingClaim = pendingClaims . find ( claim => {
2021-06-24 20:26:51 +02:00
return claim . normalized _name === uriChannelName || claim . normalized _name === uriStreamName ;
2020-12-04 01:25:41 +01:00
} ) ;
2020-12-14 01:17:16 +01:00
return matchingClaim || null ;
2020-12-04 01:25:41 +01:00
} ) ;
2021-07-15 21:46:31 +02:00
const makeSelectTotalItemsForChannel = uri => reselect . createSelector ( selectChannelClaimCounts , byUri => byUri && byUri [ normalizeURI ( uri ) ] ) ;
2019-04-03 19:12:51 +02:00
2021-07-15 21:46:31 +02:00
const makeSelectTotalPagesForChannel = ( uri , pageSize = 10 ) => reselect . createSelector ( selectChannelClaimCounts , byUri => byUri && byUri [ uri ] && Math . ceil ( byUri [ normalizeURI ( uri ) ] / pageSize ) ) ;
2019-04-03 19:12:51 +02:00
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 ) ) ;
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 ) ;
} ) ;
2019-04-03 19:12:51 +02:00
// 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
} ) ;
2020-10-14 20:07:00 +02:00
const makeSelectChannelPermUrlForClaimUri = ( uri , includePrefix = false ) => reselect . createSelector ( makeSelectClaimForUri ( uri ) , claim => {
if ( claim && claim . value _type === 'channel' ) {
return claim . permanent _url ;
}
if ( ! claim || ! claim . signing _channel || ! claim . is _channel _signature _valid ) {
return null ;
}
return claim . signing _channel . permanent _url ;
} ) ;
const makeSelectMyChannelPermUrlForName = name => reselect . createSelector ( selectMyChannelClaims , claims => {
2020-10-20 05:01:34 +02:00
const matchingClaim = claims && claims . find ( claim => claim . name === name ) ;
2020-10-14 20:07:00 +02:00
return matchingClaim ? matchingClaim . permanent _url : null ;
} ) ;
2019-06-10 04:45:47 +02:00
const makeSelectTagsForUri = uri => reselect . createSelector ( makeSelectMetadataForUri ( uri ) , metadata => {
return metadata && metadata . tags || [ ] ;
} ) ;
2020-07-27 21:35:27 +02:00
const selectFetchingClaimSearchByQuery = reselect . createSelector ( selectState$1 , 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
2020-07-27 21:35:27 +02:00
const selectClaimSearchByQuery = reselect . createSelector ( selectState$1 , state => state . claimSearchByQuery || { } ) ;
2019-07-08 20:28:14 +02:00
2020-07-27 21:35:27 +02:00
const selectClaimSearchByQueryLastPageReached = reselect . createSelector ( selectState$1 , 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
} ) ;
2020-07-27 21:35:27 +02:00
const selectUpdatingChannel = reselect . createSelector ( selectState$1 , state => state . updatingChannel ) ;
2019-09-15 13:00:14 +02:00
2020-07-27 21:35:27 +02:00
const selectUpdateChannelError = reselect . createSelector ( selectState$1 , state => state . updateChannelError ) ;
2019-09-15 13:00:14 +02:00
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-10-27 20:42:53 +01:00
const makeSelectTagInClaimOrChannelForUri = ( uri , tag ) => reselect . createSelector ( makeSelectClaimForUri ( uri ) , claim => {
const claimTags = claim && claim . value && claim . value . tags || [ ] ;
const channelTags = claim && claim . signing _channel && claim . signing _channel . value && claim . signing _channel . value . tags || [ ] ;
return claimTags . includes ( tag ) || channelTags . includes ( tag ) ;
} ) ;
2021-03-17 19:39:18 +01:00
const makeSelectClaimHasSource = uri => reselect . createSelector ( makeSelectClaimForUri ( uri ) , claim => {
if ( ! claim ) {
return false ;
}
2021-03-25 23:37:17 +01:00
return Boolean ( claim . value . source ) ;
2021-03-17 19:39:18 +01:00
} ) ;
2021-03-25 23:49:48 +01:00
const makeSelectClaimIsStreamPlaceholder = uri => reselect . createSelector ( makeSelectClaimForUri ( uri ) , claim => {
if ( ! claim ) {
return false ;
}
return Boolean ( claim . value _type === 'stream' && ! claim . value . source ) ;
} ) ;
2021-03-09 07:23:25 +01:00
const makeSelectTotalStakedAmountForChannelUri = uri => reselect . createSelector ( makeSelectClaimForUri ( uri ) , claim => {
if ( ! claim || ! claim . amount || ! claim . meta || ! claim . meta . support _amount ) {
return 0 ;
}
return parseFloat ( claim . amount ) + parseFloat ( claim . meta . support _amount ) || 0 ;
} ) ;
const makeSelectStakedLevelForChannelUri = uri => reselect . createSelector ( makeSelectTotalStakedAmountForChannelUri ( uri ) , amount => {
2021-03-11 18:56:34 +01:00
let level = 1 ;
2021-03-09 07:23:25 +01:00
switch ( true ) {
2021-03-11 18:56:34 +01:00
case amount >= LEVEL _2 _STAKED _AMOUNT && amount < LEVEL _3 _STAKED _AMOUNT :
level = 2 ;
2021-03-09 07:23:25 +01:00
break ;
2021-03-11 18:56:34 +01:00
case amount >= LEVEL _3 _STAKED _AMOUNT && amount < LEVEL _4 _STAKED _AMOUNT :
level = 3 ;
2021-03-09 07:23:25 +01:00
break ;
2021-03-11 18:56:34 +01:00
case amount >= LEVEL _4 _STAKED _AMOUNT && amount < LEVEL _5 _STAKED _AMOUNT :
level = 4 ;
2021-03-09 07:23:25 +01:00
break ;
2021-03-11 18:56:34 +01:00
case amount >= LEVEL _5 _STAKED _AMOUNT :
level = 5 ;
2021-03-09 07:23:25 +01:00
break ;
}
return level ;
} ) ;
2021-05-07 00:41:02 +02:00
const selectUpdatingCollection = reselect . createSelector ( selectState$1 , state => state . updatingCollection ) ;
const selectUpdateCollectionError = reselect . createSelector ( selectState$1 , state => state . updateCollectionError ) ;
const selectCreatingCollection = reselect . createSelector ( selectState$1 , state => state . creatingCollection ) ;
const selectCreateCollectionError = reselect . createSelector ( selectState$1 , state => state . createCollectionError ) ;
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-07-27 21:35:27 +02:00
var _extends$4 = Object . assign || function ( target ) { for ( var i = 1 ; i < arguments . length ; i ++ ) { var source = arguments [ i ] ; for ( var key in source ) { if ( Object . prototype . hasOwnProperty . call ( source , key ) ) { target [ key ] = source [ key ] ; } } } return target ; } ;
2020-06-11 00:06:12 +02:00
2020-12-30 23:25:57 +01: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" ) ; } ) ; } ; }
2020-07-21 17:16:13 +02:00
const FIFTEEN _SECONDS = 15000 ;
2019-11-01 20:08:42 +01:00
let walletBalancePromise = null ;
2021-03-05 19:32:27 +01:00
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 ( ) ) ;
2020-11-08 01:40:06 +01:00
setInterval ( ( ) => dispatch ( doUpdateBalance ( ) ) , 10000 ) ;
2019-04-03 19:12:51 +02:00
} ;
}
2021-04-20 04:44:40 +02:00
function doFetchTransactions ( page = 1 , pageSize = 999999 ) {
2019-04-03 19:12:51 +02:00
return dispatch => {
dispatch ( {
type : FETCH _TRANSACTIONS _STARTED
} ) ;
2020-07-22 18:46:40 +02:00
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 ) => {
2021-03-18 15:04:46 +01:00
const fetchId = Math . random ( ) . toString ( 36 ) . substr ( 2 , 9 ) ;
2020-04-10 14:16:27 +02:00
dispatch ( {
2021-03-18 15:04:46 +01:00
type : FETCH _TXO _PAGE _STARTED ,
data : fetchId
2020-04-10 14:16:27 +02:00
} ) ;
const state = getState ( ) ;
const queryParams = selectTxoPageParams ( state ) ;
2020-07-22 18:46:40 +02:00
lbryProxy . txo _list ( queryParams ) . then ( res => {
2021-03-05 19:32:27 +01:00
const items = res . items || [ ] ;
const claimsById = selectClaimsById ( state ) ;
const channelIds = items . reduce ( ( acc , cur ) => {
if ( cur . type === 'support' && cur . signing _channel && ! claimsById [ cur . signing _channel . channel _id ] ) {
acc . push ( cur . signing _channel . channel _id ) ;
}
return acc ;
} , [ ] ) ;
if ( channelIds . length ) {
const searchParams = {
page _size : 9999 ,
page : 1 ,
no _totals : true ,
claim _ids : channelIds
} ;
// make sure redux has these channels resolved
dispatch ( doClaimSearch ( searchParams ) ) ;
}
return res ;
} ) . then ( res => {
2020-04-10 14:16:27 +02:00
dispatch ( {
type : FETCH _TXO _PAGE _COMPLETED ,
2021-03-18 15:04:46 +01:00
data : {
result : res ,
fetchId : fetchId
}
2020-04-10 14:16:27 +02:00
} ) ;
} ) . catch ( e => {
dispatch ( {
type : FETCH _TXO _PAGE _COMPLETED ,
2021-03-18 15:04:46 +01:00
data : {
error : e . message ,
fetchId : fetchId
}
2020-04-10 14:16:27 +02:00
} ) ;
} ) ;
} ;
}
function doUpdateTxoPageParams ( params ) {
return dispatch => {
dispatch ( {
type : UPDATE _TXO _FETCH _PARAMS ,
data : params
} ) ;
dispatch ( doFetchTxoPage ( ) ) ;
} ;
}
2020-12-30 23:25:57 +01:00
function doFetchUtxoCounts ( ) {
return ( ( ) => {
var _ref = _asyncToGenerator ( function * ( dispatch ) {
dispatch ( {
type : FETCH _UTXO _COUNT _STARTED
} ) ;
2021-01-27 16:01:55 +01:00
let resultSets = yield Promise . all ( [ lbryProxy . txo _list ( { type : 'other' , is _not _spent : true , page : 1 , page _size : 1 } ) , lbryProxy . txo _list ( { type : 'support' , is _not _spent : true , page : 1 , page _size : 1 } ) ] ) ;
2020-12-30 23:25:57 +01:00
const counts = { } ;
const paymentCount = resultSets [ 0 ] [ 'total_items' ] ;
2021-01-27 16:01:55 +01:00
const supportCount = resultSets [ 1 ] [ 'total_items' ] ;
2020-12-30 23:25:57 +01:00
counts [ 'other' ] = typeof paymentCount === 'number' ? paymentCount : 0 ;
2021-01-27 16:01:55 +01:00
counts [ 'support' ] = typeof supportCount === 'number' ? supportCount : 0 ;
2020-12-30 23:25:57 +01:00
dispatch ( {
type : FETCH _UTXO _COUNT _COMPLETED ,
data : counts ,
debug : { resultSets }
} ) ;
} ) ;
return function ( _x ) {
return _ref . apply ( this , arguments ) ;
} ;
} ) ( ) ;
}
function doUtxoConsolidate ( ) {
return ( ( ) => {
var _ref2 = _asyncToGenerator ( function * ( dispatch ) {
dispatch ( {
type : DO _UTXO _CONSOLIDATE _STARTED
} ) ;
const results = yield lbryProxy . txo _spend ( { type : 'other' } ) ;
const result = results [ 0 ] ;
dispatch ( {
type : PENDING _CONSOLIDATED _TXOS _UPDATED ,
data : { txids : [ result . txid ] }
} ) ;
dispatch ( {
2021-02-03 23:52:01 +01:00
type : DO _UTXO _CONSOLIDATE _COMPLETED ,
data : { txid : result . txid }
2020-12-30 23:25:57 +01:00
} ) ;
dispatch ( doCheckPendingTxs ( ) ) ;
} ) ;
return function ( _x2 ) {
return _ref2 . apply ( this , arguments ) ;
} ;
} ) ( ) ;
}
2021-01-27 16:01:55 +01:00
function doTipClaimMass ( ) {
return ( ( ) => {
var _ref3 = _asyncToGenerator ( function * ( dispatch ) {
dispatch ( {
type : TIP _CLAIM _MASS _STARTED
} ) ;
const results = yield lbryProxy . txo _spend ( { type : 'support' , is _not _my _input : true } ) ;
const result = results [ 0 ] ;
dispatch ( {
type : PENDING _CONSOLIDATED _TXOS _UPDATED ,
data : { txids : [ result . txid ] }
} ) ;
dispatch ( {
2021-02-03 23:52:01 +01:00
type : TIP _CLAIM _MASS _COMPLETED ,
data : { txid : result . txid }
2021-01-27 16:01:55 +01:00
} ) ;
dispatch ( doCheckPendingTxs ( ) ) ;
} ) ;
return function ( _x3 ) {
return _ref3 . apply ( this , arguments ) ;
} ;
} ) ( ) ;
}
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-09-16 15:56:24 +02:00
message : _ _ ( 'You sent %amount% LBRY Credits' , { amount : amount } ) ,
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 }
} ;
}
2021-04-22 07:54:54 +02:00
function doSendTip ( params , isSupport , successCallback , errorCallback , shouldNotify = true ) {
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 ;
}
2021-04-22 07:54:54 +02:00
const success = response => {
if ( shouldNotify ) {
dispatch ( doToast ( {
message : shouldSupport ? _ _ ( 'You deposited %amount% LBRY Credits as a support!' , { amount : params . amount } ) : _ _ ( 'You sent %amount% LBRY Credits as a tip, Mahalo!' , { amount : params . amount } ) ,
linkText : _ _ ( 'History' ) ,
linkTarget : '/wallet'
} ) ) ;
}
2019-04-03 19:12:51 +02:00
dispatch ( {
type : SUPPORT _TRANSACTION _COMPLETED
} ) ;
if ( successCallback ) {
2021-04-22 07:54:54 +02:00
successCallback ( response ) ;
2019-04-03 19:12:51 +02:00
}
} ;
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-07-27 21:35:27 +02:00
lbryProxy . support _create ( _extends$4 ( { } , 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
} ) ;
}
} ) ;
} ;
}
2021-01-04 23:20:27 +01:00
// Collect all tips for a claim
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 ,
2021-01-04 23:20:27 +01:00
data : { claimId , txid : res . txid , effective : res . outputs [ 0 ] . amount , type : claimType }
2020-03-25 03:46:35 +01:00
} ) ;
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
} ) ;
2020-07-21 17:16:13 +02:00
let failed = false ;
2019-12-11 15:45:18 +01:00
// this basically returns null when it's done. :(
// might be good to dispatch ACTIONS.WALLET_RESTARTED
2020-07-21 17:16:13 +02:00
const walletTimeout = setTimeout ( ( ) => {
failed = true ;
dispatch ( {
type : WALLET _RESTART _COMPLETED
} ) ;
dispatch ( doToast ( {
message : _ _ ( 'Your servers were not available. Check your url and port, or switch back to defaults.' ) ,
isError : true
} ) ) ;
} , FIFTEEN _SECONDS ) ;
lbryProxy . wallet _reconnect ( ) . then ( ( ) => {
clearTimeout ( walletTimeout ) ;
if ( ! failed ) dispatch ( { type : WALLET _RESTART _COMPLETED } ) ;
} ) ;
2019-12-11 15:45:18 +01:00
} ;
}
2021-03-05 19:32:27 +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 ) ; // {}
2020-12-30 23:25:57 +01:00
const pendingOtherTxes = selectPendingOtherTransactions ( state ) ;
2021-01-04 23:20:27 +01:00
2020-12-30 23:25:57 +01:00
if ( ! Object . keys ( pendingTxsById ) . length && ! pendingOtherTxes . length ) {
2020-03-25 03:46:35 +01:00
return ;
}
let txCheckInterval ;
const checkTxList = ( ) => {
const state = getState ( ) ;
2020-12-30 23:25:57 +01:00
const pendingSupportTxs = selectPendingSupportTransactions ( state ) ; // {}
const pendingConsolidateTxes = selectPendingOtherTransactions ( state ) ;
2021-02-03 23:52:01 +01:00
const pendingConsTxid = selectPendingConsolidateTxid ( state ) ;
const pendingMassCLaimTxid = selectPendingMassClaimTxid ( state ) ;
2020-12-30 23:25:57 +01:00
2020-03-25 03:46:35 +01:00
const promises = [ ] ;
const newPendingTxes = { } ;
2020-12-30 23:25:57 +01:00
const noLongerPendingConsolidate = [ ] ;
2020-03-25 03:46:35 +01:00
const types = new Set ( [ ] ) ;
2020-12-30 23:25:57 +01:00
// { claimId: {txid: 123, amount 12.3}, }
const entries = Object . entries ( pendingSupportTxs ) ;
entries . forEach ( ( [ claim , data ] ) => {
2020-03-25 03:46:35 +01:00
promises . push ( lbryProxy . transaction _show ( { txid : data . txid } ) ) ;
types . add ( data . type ) ;
} ) ;
2020-12-30 23:25:57 +01:00
if ( pendingConsolidateTxes . length ) {
pendingConsolidateTxes . forEach ( txid => promises . push ( lbryProxy . transaction _show ( { txid } ) ) ) ;
}
2020-03-25 03:46:35 +01:00
Promise . all ( promises ) . then ( txShows => {
2020-12-30 23:25:57 +01:00
let changed = false ;
2020-03-25 03:46:35 +01:00
txShows . forEach ( result => {
2020-12-30 23:25:57 +01:00
if ( pendingConsolidateTxes . includes ( result . txid ) ) {
if ( result . height > 0 ) {
noLongerPendingConsolidate . push ( result . txid ) ;
}
2020-03-25 03:46:35 +01:00
} else {
2020-12-30 23:25:57 +01:00
if ( result . height <= 0 ) {
const match = entries . find ( entry => entry [ 1 ] . txid === result . txid ) ;
newPendingTxes [ match [ 0 ] ] = match [ 1 ] ;
} else {
changed = true ;
}
2020-03-25 03:46:35 +01:00
}
} ) ;
2020-12-30 23:25:57 +01:00
2020-03-25 03:46:35 +01:00
if ( changed ) {
dispatch ( {
type : PENDING _SUPPORTS _UPDATED ,
data : newPendingTxes
} ) ;
if ( types . has ( 'channel' ) ) {
dispatch ( doFetchChannelListMine ( ) ) ;
}
if ( types . has ( 'stream' ) ) {
dispatch ( doFetchClaimListMine ( ) ) ;
}
}
2020-12-30 23:25:57 +01:00
if ( noLongerPendingConsolidate . length ) {
2021-02-03 23:52:01 +01:00
if ( noLongerPendingConsolidate . includes ( pendingConsTxid ) ) {
dispatch ( doToast ( {
message : _ _ ( 'Your wallet is finished consolidating' )
} ) ) ;
}
if ( noLongerPendingConsolidate . includes ( pendingMassCLaimTxid ) ) {
dispatch ( doToast ( {
message : _ _ ( 'Your tips have been collected' )
} ) ) ;
}
2020-12-30 23:25:57 +01:00
dispatch ( {
type : PENDING _CONSOLIDATED _TXOS _UPDATED ,
data : { txids : noLongerPendingConsolidate , remove : true }
} ) ;
}
2020-03-25 03:46:35 +01:00
2020-12-30 23:25:57 +01:00
if ( ! Object . keys ( pendingTxsById ) . length && ! pendingOtherTxes . length ) {
clearInterval ( txCheckInterval ) ;
}
} ) ;
2020-03-25 03:46:35 +01:00
} ;
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
} ;
}
2021-05-07 00:41:02 +02:00
//
const selectState$2 = state => state . collections ;
const selectSavedCollectionIds = reselect . createSelector ( selectState$2 , collectionState => collectionState . saved ) ;
const selectBuiltinCollections = reselect . createSelector ( selectState$2 , state => state . builtin ) ;
const selectResolvedCollections = reselect . createSelector ( selectState$2 , state => state . resolved ) ;
const selectMyUnpublishedCollections = reselect . createSelector ( selectState$2 , state => state . unpublished ) ;
const selectMyEditedCollections = reselect . createSelector ( selectState$2 , state => state . edited ) ;
const selectPendingCollections = reselect . createSelector ( selectState$2 , state => state . pending ) ;
const makeSelectEditedCollectionForId = id => reselect . createSelector ( selectMyEditedCollections , eLists => eLists [ id ] ) ;
const makeSelectPendingCollectionForId = id => reselect . createSelector ( selectPendingCollections , pending => pending [ id ] ) ;
const makeSelectPublishedCollectionForId = id => reselect . createSelector ( selectResolvedCollections , rLists => rLists [ id ] ) ;
const makeSelectUnpublishedCollectionForId = id => reselect . createSelector ( selectMyUnpublishedCollections , rLists => rLists [ id ] ) ;
const makeSelectCollectionIsMine = id => reselect . createSelector ( selectMyCollectionIds , selectMyUnpublishedCollections , selectBuiltinCollections , ( publicIds , privateIds , builtinIds ) => {
return Boolean ( publicIds . includes ( id ) || privateIds [ id ] || builtinIds [ id ] ) ;
} ) ;
const selectMyPublishedCollections = reselect . createSelector ( selectResolvedCollections , selectPendingCollections , selectMyEditedCollections , selectMyCollectionIds , ( resolved , pending , edited , myIds ) => {
// all resolved in myIds, plus those in pending and edited
2021-09-01 03:59:00 +02:00
const myPublishedCollections = fromEntries ( Object . entries ( pending ) . concat ( Object . entries ( resolved ) . filter ( ( [ key , val ] ) => myIds . includes ( key ) &&
2021-05-07 00:41:02 +02:00
// $FlowFixMe
! pending [ key ] ) ) ) ;
// now add in edited:
Object . entries ( edited ) . forEach ( ( [ id , item ] ) => {
myPublishedCollections [ id ] = item ;
} ) ;
return myPublishedCollections ;
} ) ;
const selectMyPublishedMixedCollections = reselect . createSelector ( selectMyPublishedCollections , published => {
2021-09-01 03:59:00 +02:00
const myCollections = fromEntries (
2021-05-07 00:41:02 +02:00
// $FlowFixMe
Object . entries ( published ) . filter ( ( [ key , collection ] ) => {
// $FlowFixMe
return collection . type === 'collection' ;
} ) ) ;
return myCollections ;
} ) ;
const selectMyPublishedPlaylistCollections = reselect . createSelector ( selectMyPublishedCollections , published => {
2021-09-01 03:59:00 +02:00
const myCollections = fromEntries (
2021-05-07 00:41:02 +02:00
// $FlowFixMe
Object . entries ( published ) . filter ( ( [ key , collection ] ) => {
// $FlowFixMe
return collection . type === 'playlist' ;
} ) ) ;
return myCollections ;
} ) ;
const makeSelectMyPublishedCollectionForId = id => reselect . createSelector ( selectMyPublishedCollections , myPublishedCollections => myPublishedCollections [ id ] ) ;
// export const selectSavedCollections = createSelector(
// selectResolvedCollections,
// selectSavedCollectionIds,
// (resolved, myIds) => {
2021-09-01 03:59:00 +02:00
// const mySavedCollections = fromEntries(
2021-05-07 00:41:02 +02:00
// Object.entries(resolved).filter(([key, val]) => myIds.includes(key))
// );
// return mySavedCollections;
// }
// );
const makeSelectIsResolvingCollectionForId = id => reselect . createSelector ( selectState$2 , state => {
return state . isResolvingCollectionById [ id ] ;
} ) ;
const makeSelectCollectionForId = id => reselect . createSelector ( selectBuiltinCollections , selectResolvedCollections , selectMyUnpublishedCollections , selectMyEditedCollections , selectPendingCollections , ( bLists , rLists , uLists , eLists , pLists ) => {
2021-06-25 22:53:26 +02:00
const collection = bLists [ id ] || uLists [ id ] || eLists [ id ] || pLists [ id ] || rLists [ id ] ;
2021-05-07 00:41:02 +02:00
return collection ;
} ) ;
2021-07-23 16:19:58 +02:00
const makeSelectClaimUrlInCollection = url => reselect . createSelector ( selectBuiltinCollections , selectMyPublishedCollections , selectMyUnpublishedCollections , selectMyEditedCollections , selectPendingCollections , ( bLists , myRLists , uLists , eLists , pLists ) => {
const collections = [ bLists , uLists , eLists , myRLists , pLists ] ;
2021-07-05 18:02:06 +02:00
const itemsInCollections = [ ] ;
collections . map ( list => {
Object . entries ( list ) . forEach ( ( [ key , value ] ) => {
2021-08-01 22:58:45 +02:00
// $FlowFixMe
2021-07-05 18:02:06 +02:00
value . items . map ( item => {
itemsInCollections . push ( item ) ;
} ) ;
} ) ;
} ) ;
return itemsInCollections . includes ( url ) ;
} ) ;
2021-05-07 00:41:02 +02:00
const makeSelectCollectionForIdHasClaimUrl = ( id , url ) => reselect . createSelector ( makeSelectCollectionForId ( id ) , collection => collection && collection . items . includes ( url ) ) ;
const makeSelectUrlsForCollectionId = id => reselect . createSelector ( makeSelectCollectionForId ( id ) , collection => collection && collection . items ) ;
const makeSelectClaimIdsForCollectionId = id => reselect . createSelector ( makeSelectCollectionForId ( id ) , collection => {
const items = collection && collection . items || [ ] ;
const ids = items . map ( item => {
const { claimId } = parseURI ( item ) ;
return claimId ;
} ) ;
return ids ;
} ) ;
2021-08-25 14:01:50 +02:00
const makeSelectIndexForUrlInCollection = ( url , id ) => reselect . createSelector ( state => state . content . shuffleList , makeSelectUrlsForCollectionId ( id ) , makeSelectClaimForUri ( url ) , ( shuffleState , urls , claim ) => {
const shuffleUrls = shuffleState && shuffleState . collectionId === id && shuffleState . newUrls ;
const listUrls = shuffleUrls || urls ;
const index = listUrls && listUrls . findIndex ( u => u === url ) ;
2021-06-07 22:21:31 +02:00
if ( index > - 1 ) {
return index ;
2021-06-10 20:03:11 +02:00
} else if ( claim ) {
2021-08-25 14:01:50 +02:00
const index = listUrls && listUrls . findIndex ( u => u === claim . permanent _url ) ;
2021-06-10 20:03:11 +02:00
if ( index > - 1 ) return index ;
return claim ;
2021-06-07 22:21:31 +02:00
}
return null ;
} ) ;
2021-08-25 14:01:50 +02:00
const makeSelectPreviousUrlForCollectionAndUrl = ( id , url ) => reselect . createSelector ( state => state . content . shuffleList , state => state . content . loopList , makeSelectIndexForUrlInCollection ( url , id ) , makeSelectUrlsForCollectionId ( id ) , ( shuffleState , loopState , index , urls ) => {
const loopList = loopState && loopState . collectionId === id && loopState . loop ;
const shuffleUrls = shuffleState && shuffleState . collectionId === id && shuffleState . newUrls ;
2021-06-10 20:03:11 +02:00
if ( index > - 1 ) {
2021-08-25 14:01:50 +02:00
const listUrls = shuffleUrls || urls ;
let nextUrl ;
if ( index === 0 && loopList ) {
nextUrl = listUrls [ listUrls . length - 1 ] ;
} else {
nextUrl = listUrls [ index - 1 ] ;
}
return nextUrl || null ;
} else {
return null ;
}
} ) ;
const makeSelectNextUrlForCollectionAndUrl = ( id , url ) => reselect . createSelector ( state => state . content . shuffleList , state => state . content . loopList , makeSelectIndexForUrlInCollection ( url , id ) , makeSelectUrlsForCollectionId ( id ) , ( shuffleState , loopState , index , urls ) => {
const loopList = loopState && loopState . collectionId === id && loopState . loop ;
const shuffleUrls = shuffleState && shuffleState . collectionId === id && shuffleState . newUrls ;
if ( index > - 1 ) {
const listUrls = shuffleUrls || urls ;
2021-06-10 20:03:11 +02:00
// We'll get the next playble url
2021-08-25 14:01:50 +02:00
let remainingUrls = listUrls . slice ( index + 1 ) ;
if ( ! remainingUrls . length && loopList ) {
remainingUrls = listUrls . slice ( 0 ) ;
}
const nextUrl = remainingUrls && remainingUrls [ 0 ] ;
2021-06-10 20:03:11 +02:00
return nextUrl || null ;
} else {
return null ;
2021-05-07 00:41:02 +02:00
}
} ) ;
const makeSelectNameForCollectionId = id => reselect . createSelector ( makeSelectCollectionForId ( id ) , collection => {
return collection && collection . name || '' ;
} ) ;
2021-05-12 21:11:04 +02:00
const makeSelectCountForCollectionId = id => reselect . createSelector ( makeSelectCollectionForId ( id ) , collection => {
2021-05-19 17:36:11 +02:00
if ( collection ) {
if ( collection . itemCount !== undefined ) {
return collection . itemCount ;
}
2021-08-25 14:01:50 +02:00
let itemCount = 0 ;
collection . items . map ( item => {
if ( item ) {
itemCount += 1 ;
}
} ) ;
return itemCount ;
2021-05-12 21:11:04 +02:00
}
2021-05-19 17:36:11 +02:00
return null ;
2021-05-12 21:11:04 +02:00
} ) ;
2020-07-27 21:35:27 +02:00
var _extends$5 = Object . assign || function ( target ) { for ( var i = 1 ; i < arguments . length ; i ++ ) { var source = arguments [ i ] ; for ( var key in source ) { if ( Object . prototype . hasOwnProperty . call ( source , key ) ) { target [ key ] = source [ key ] ; } } } return target ; } ;
2019-04-23 19:22:14 +02:00
2020-12-30 23:25:57 +01:00
function _asyncToGenerator$1 ( 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" ) ; } ) ; } ; }
2020-12-17 04:35:12 +01:00
2021-07-02 22:44:44 +02:00
let onChannelConfirmCallback ;
2021-06-24 20:26:51 +02:00
let checkPendingInterval ;
2020-12-17 04:35:12 +01:00
function doResolveUris ( uris , returnCachedClaims = false , resolveReposts = true ) {
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
2021-05-07 00:41:02 +02:00
const collectionIds = [ ] ;
2020-12-17 04:35:12 +01:00
return lbryProxy . resolve ( _extends$5 ( { urls : urisToResolve } , options ) ) . then ( ( ( ) => {
2020-12-30 23:25:57 +01:00
var _ref = _asyncToGenerator$1 ( function * ( result ) {
2020-12-17 04:35:12 +01:00
let repostedResults = { } ;
const repostsToResolve = [ ] ;
2019-04-03 19:12:51 +02:00
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
} ;
2020-12-17 04:35:12 +01:00
function processResult ( result , resolveInfo = { } , checkReposts = false ) {
Object . entries ( result ) . forEach ( ( [ uri , uriResolveInfo ] ) => {
// Flow has terrible Object.entries support
// https://github.com/facebook/flow/issues/2221
if ( uriResolveInfo ) {
if ( uriResolveInfo . error ) {
2021-05-07 00:41:02 +02:00
// $FlowFixMe
2020-12-17 04:35:12 +01:00
resolveInfo [ uri ] = _extends$5 ( { } , fallbackResolveInfo ) ;
} else {
if ( checkReposts ) {
if ( uriResolveInfo . reposted _claim ) {
2020-12-30 23:25:57 +01:00
// $FlowFixMe
2020-12-17 04:35:12 +01:00
const repostUrl = uriResolveInfo . reposted _claim . permanent _url ;
if ( ! resolvingUris . includes ( repostUrl ) ) {
repostsToResolve . push ( repostUrl ) ;
}
}
}
let result = { } ;
if ( uriResolveInfo . value _type === 'channel' ) {
result . channel = uriResolveInfo ;
// $FlowFixMe
result . claimsInChannel = uriResolveInfo . meta . claims _in _channel ;
2021-05-07 00:41:02 +02:00
} else if ( uriResolveInfo . value _type === 'collection' ) {
result . collection = uriResolveInfo ;
// $FlowFixMe
collectionIds . push ( uriResolveInfo . claim _id ) ;
2020-12-17 04:35:12 +01:00
} else {
result . stream = uriResolveInfo ;
if ( uriResolveInfo . signing _channel ) {
result . channel = uriResolveInfo . signing _channel ;
result . claimsInChannel = uriResolveInfo . signing _channel . meta && uriResolveInfo . signing _channel . meta . claims _in _channel || 0 ;
}
}
// $FlowFixMe
resolveInfo [ uri ] = result ;
2019-06-06 23:37:36 +02:00
}
2019-06-04 18:06:19 +02:00
}
2020-12-17 04:35:12 +01:00
} ) ;
2019-04-23 19:22:14 +02:00
}
2020-12-17 04:35:12 +01:00
processResult ( result , resolveInfo , resolveReposts ) ;
2019-04-03 19:12:51 +02:00
2020-12-17 04:35:12 +01:00
if ( repostsToResolve . length ) {
dispatch ( {
type : RESOLVE _URIS _STARTED ,
data : { uris : repostsToResolve , debug : 'reposts' }
} ) ;
repostedResults = yield lbryProxy . resolve ( _extends$5 ( { urls : repostsToResolve } , options ) ) ;
}
processResult ( repostedResults , resolveInfo ) ;
dispatch ( {
type : RESOLVE _URIS _COMPLETED ,
data : { resolveInfo }
} ) ;
2021-05-07 00:41:02 +02:00
if ( collectionIds . length ) {
dispatch ( doFetchItemsInCollections ( { collectionIds : collectionIds , pageSize : 5 } ) ) ;
}
2020-12-17 04:35:12 +01:00
return result ;
2019-04-03 19:12:51 +02:00
} ) ;
2020-12-17 04:35:12 +01:00
return function ( _x ) {
return _ref . apply ( this , arguments ) ;
} ;
} ) ( ) ) ;
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
}
2021-03-15 19:20:12 +01:00
function doFetchClaimListMine ( page = 1 , pageSize = 99999 , resolve = true , filterBy = [ ] ) {
2019-04-03 19:12:51 +02:00
return dispatch => {
dispatch ( {
type : FETCH _CLAIM _LIST _MINE _STARTED
} ) ;
2021-03-15 19:20:12 +01:00
let claimTypes = [ 'stream' , 'repost' ] ;
if ( filterBy && filterBy . length !== 0 ) {
claimTypes = claimTypes . filter ( t => filterBy . includes ( t ) ) ;
}
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 ,
2021-03-15 19:20:12 +01:00
claim _type : claimTypes ,
2020-04-25 22:31:53 +02:00
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-07-03 00:03:55 +02:00
function doClearChannelErrors ( ) {
return {
type : CLEAR _CHANNEL _ERRORS
} ;
}
2021-07-02 22:44:44 +02:00
function doCreateChannel ( name , amount , optionalParams , onConfirm ) {
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 ) ;
}
2020-11-06 15:59:12 +01:00
if ( optionalParams . languages ) {
createParams . languages = optionalParams . languages ;
}
2019-09-15 13:00:14 +02:00
}
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 ]
}
} ) ;
2021-07-02 22:44:44 +02:00
dispatch ( doCheckPendingClaims ( onConfirm ) ) ;
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
} ) ;
} ) ;
} ;
}
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 ,
2020-10-16 05:02:34 +02:00
languages : params . languages || [ ] ,
2019-10-02 01:00:59 +02:00
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 ;
}
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
} ) ;
2021-06-04 16:08:43 +02:00
return lbryProxy . channel _import ( { channel _data : certificate } ) . then ( ( ) => {
2019-09-12 21:06:49 +02:00
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
} ;
}
2021-05-07 00:41:02 +02:00
function doFetchCollectionListMine ( page = 1 , pageSize = 99999 ) {
return dispatch => {
dispatch ( {
type : FETCH _COLLECTION _LIST _STARTED
} ) ;
const callback = response => {
const { items } = response ;
dispatch ( {
type : FETCH _COLLECTION _LIST _COMPLETED ,
data : { claims : items }
} ) ;
dispatch ( doFetchItemsInCollections ( {
collectionIds : items . map ( claim => claim . claim _id ) ,
page _size : 5
} ) ) ;
} ;
const failure = error => {
dispatch ( {
type : FETCH _COLLECTION _LIST _FAILED ,
data : error
} ) ;
} ;
2021-05-12 21:11:04 +02:00
lbryProxy . collection _list ( { page , page _size : pageSize , resolve _claims : 1 , resolve : true } ) . then ( callback , failure ) ;
2021-05-07 00:41:02 +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 ) ;
2021-04-23 04:31:08 +02:00
return ( ( ) => {
var _ref2 = _asyncToGenerator$1 ( function * ( dispatch ) {
2019-06-10 04:45:47 +02:00
dispatch ( {
2021-04-23 04:31:08 +02:00
type : CLAIM _SEARCH _STARTED ,
data : { query : query }
2019-06-10 04:45:47 +02:00
} ) ;
2021-04-23 04:31:08 +02:00
const success = function ( data ) {
const resolveInfo = { } ;
const urls = [ ] ;
data . items . forEach ( function ( stream ) {
resolveInfo [ stream . canonical _url ] = { stream } ;
urls . push ( stream . canonical _url ) ;
} ) ;
2019-06-10 04:45:47 +02:00
2021-04-23 04:31:08 +02:00
dispatch ( {
type : CLAIM _SEARCH _COMPLETED ,
data : {
query ,
resolveInfo ,
urls ,
append : options . page && options . page !== 1 ,
pageSize : options . page _size
}
} ) ;
2021-05-07 00:41:02 +02:00
return resolveInfo ;
2021-04-23 04:31:08 +02:00
} ;
const failure = function ( err ) {
dispatch ( {
type : CLAIM _SEARCH _FAILED ,
data : { query } ,
error : err
} ) ;
return false ;
} ;
return yield lbryProxy . claim _search ( _extends$5 ( { } , options , {
include _purchase _receipt : true
} ) ) . then ( success , failure ) ;
} ) ;
return function ( _x2 ) {
return _ref2 . apply ( this , arguments ) ;
} ;
} ) ( ) ;
2019-07-15 04:44:02 +02:00
}
2020-02-10 16:49:45 +01:00
function doRepost ( options ) {
return dispatch => {
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-12-04 01:25:41 +01:00
dispatch ( {
type : UPDATE _PENDING _CLAIMS ,
data : {
claims : [ repostClaim ]
}
} ) ;
2020-02-10 16:49:45 +01:00
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 ) ;
} ) ;
} ;
}
2021-05-07 00:41:02 +02:00
function doCollectionPublish ( options , localId ) {
return dispatch => {
// $FlowFixMe
2021-05-31 00:26:53 +02:00
const params = {
name : options . name ,
bid : creditsToString ( options . bid ) ,
title : options . title ,
thumbnail _url : options . thumbnail _url ,
description : options . description ,
tags : [ ] ,
languages : options . languages || [ ] ,
locations : [ ] ,
blocking : true ,
claims : options . claims
} ;
if ( options . tags ) {
params [ 'tags' ] = options . tags . map ( tag => tag . name ) ;
}
2021-06-01 18:19:35 +02:00
if ( options . channel _id ) {
params [ 'channel_id' ] = options . channel _id ;
}
2021-05-07 00:41:02 +02:00
return new Promise ( resolve => {
dispatch ( {
type : COLLECTION _PUBLISH _STARTED
} ) ;
function success ( response ) {
const collectionClaim = response . outputs [ 0 ] ;
dispatch ( batchActions ( {
2021-05-12 21:11:04 +02:00
type : COLLECTION _PUBLISH _COMPLETED ,
data : { claimId : collectionClaim . claim _id }
2021-05-07 00:41:02 +02:00
} ,
2021-06-01 14:12:02 +02:00
// move unpublished collection to pending collection with new publish id
2021-05-07 00:41:02 +02:00
// recent publish won't resolve this second. handle it in checkPending
{
type : UPDATE _PENDING _CLAIMS ,
data : {
claims : [ collectionClaim ]
}
} ) ) ;
2021-06-03 20:03:33 +02:00
dispatch ( {
type : COLLECTION _PENDING ,
data : { localId : localId , claimId : collectionClaim . claim _id }
} ) ;
2021-05-07 00:41:02 +02:00
dispatch ( doCheckPendingClaims ( ) ) ;
dispatch ( doFetchCollectionListMine ( 1 , 10 ) ) ;
2021-06-02 21:20:55 +02:00
return resolve ( collectionClaim ) ;
2021-05-07 00:41:02 +02:00
}
function failure ( error ) {
dispatch ( {
type : COLLECTION _PUBLISH _FAILED ,
data : {
error : error . message
}
} ) ;
}
2021-06-02 21:20:55 +02:00
return lbryProxy . collection _create ( params ) . then ( success , failure ) ;
2021-05-07 00:41:02 +02:00
} ) ;
} ;
}
2021-08-22 21:52:44 +02:00
function doCollectionPublishUpdate ( options , isBackgroundUpdate ) {
return ( dispatch , getState ) => {
2021-06-01 14:12:02 +02:00
// TODO: implement one click update
2021-05-07 00:41:02 +02:00
2021-08-22 21:52:44 +02:00
const updateParams = isBackgroundUpdate ? {
blocking : true ,
claim _id : options . claim _id ,
clear _claims : true
} : {
2021-05-07 00:41:02 +02:00
bid : creditsToString ( options . bid ) ,
title : options . title ,
2021-05-19 21:47:23 +02:00
thumbnail _url : options . thumbnail _url ,
2021-05-07 00:41:02 +02:00
description : options . description ,
tags : [ ] ,
languages : options . languages || [ ] ,
locations : [ ] ,
2021-05-12 21:11:04 +02:00
blocking : true ,
claim _id : options . claim _id ,
2021-09-11 05:36:55 +02:00
clear _claims : true ,
replace : true
2021-05-07 00:41:02 +02:00
} ;
2021-08-22 21:52:44 +02:00
if ( isBackgroundUpdate && updateParams . claim _id ) {
2021-08-22 22:22:40 +02:00
const state = getState ( ) ;
2021-08-22 21:52:44 +02:00
updateParams [ 'claims' ] = makeSelectClaimIdsForCollectionId ( updateParams . claim _id ) ( state ) ;
} else if ( options . claims ) {
updateParams [ 'claims' ] = options . claims ;
}
2021-05-07 00:41:02 +02:00
if ( options . tags ) {
updateParams [ 'tags' ] = options . tags . map ( tag => tag . name ) ;
}
return new Promise ( resolve => {
dispatch ( {
type : COLLECTION _PUBLISH _UPDATE _STARTED
} ) ;
function success ( response ) {
const collectionClaim = response . outputs [ 0 ] ;
dispatch ( {
type : COLLECTION _PUBLISH _UPDATE _COMPLETED ,
data : {
collectionClaim
}
} ) ;
2021-05-12 21:11:04 +02:00
dispatch ( {
type : COLLECTION _PENDING ,
data : { claimId : collectionClaim . claim _id }
} ) ;
2021-05-07 00:41:02 +02:00
dispatch ( {
type : UPDATE _PENDING _CLAIMS ,
data : {
claims : [ collectionClaim ]
}
} ) ;
dispatch ( doCheckPendingClaims ( ) ) ;
2021-06-02 21:20:55 +02:00
return resolve ( collectionClaim ) ;
2021-05-07 00:41:02 +02:00
}
function failure ( error ) {
dispatch ( {
type : COLLECTION _PUBLISH _UPDATE _FAILED ,
data : {
error : error . message
}
} ) ;
}
2021-06-02 21:20:55 +02:00
return lbryProxy . collection _update ( updateParams ) . then ( success , failure ) ;
2021-05-07 00:41:02 +02:00
} ) ;
} ;
}
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 ) ;
} ;
}
2021-07-02 22:44:44 +02:00
const doCheckPendingClaims = onChannelConfirmed => ( dispatch , getState ) => {
if ( onChannelConfirmed ) {
onChannelConfirmCallback = onChannelConfirmed ;
}
2021-06-24 20:26:51 +02:00
clearInterval ( checkPendingInterval ) ;
2021-07-02 22:44:44 +02:00
const checkTxoList = ( ) => {
2020-06-17 03:56:51 +02:00
const state = getState ( ) ;
2021-06-24 20:26:51 +02:00
const pendingById = Object . assign ( { } , selectPendingClaimsById ( state ) ) ;
const pendingTxos = Object . values ( pendingById ) . map ( p => p . txid ) ;
// use collections
2021-05-07 00:41:02 +02:00
const pendingCollections = selectPendingCollections ( state ) ;
2021-06-24 20:26:51 +02:00
if ( pendingTxos . length ) {
lbryProxy . txo _list ( { txid : pendingTxos } ) . then ( result => {
const txos = result . items ;
const idsToConfirm = [ ] ;
txos . forEach ( txo => {
if ( txo . claim _id && txo . confirmations > 0 ) {
idsToConfirm . push ( txo . claim _id ) ;
delete pendingById [ txo . claim _id ] ;
2020-06-17 03:56:51 +02:00
}
2021-06-24 20:26:51 +02:00
} ) ;
return { idsToConfirm , pendingById } ;
} ) . then ( results => {
const { idsToConfirm , pendingById } = results ;
if ( idsToConfirm . length ) {
return lbryProxy . claim _list ( { claim _id : idsToConfirm , resolve : true } ) . then ( results => {
const claims = results . items ;
2021-06-24 23:53:09 +02:00
const collectionIds = claims . filter ( c => c . value _type === 'collection' ) . map ( c => c . claim _id ) ;
2021-06-24 20:26:51 +02:00
dispatch ( {
type : UPDATE _CONFIRMED _CLAIMS ,
data : {
claims : claims ,
pending : pendingById
}
} ) ;
2021-06-24 23:53:09 +02:00
if ( collectionIds . length ) {
dispatch ( doFetchItemsInCollections ( {
collectionIds
} ) ) ;
}
2021-07-02 22:44:44 +02:00
const channelClaims = claims . filter ( claim => claim . value _type === 'channel' ) ;
if ( channelClaims . length && onChannelConfirmCallback ) {
channelClaims . forEach ( claim => onChannelConfirmCallback ( claim ) ) ;
}
2021-07-01 23:16:34 +02:00
if ( Object . keys ( pendingById ) . length === 0 ) {
clearInterval ( checkPendingInterval ) ;
}
2021-06-24 20:26:51 +02:00
} ) ;
2020-06-17 03:56:51 +02:00
}
} ) ;
2021-06-24 20:26:51 +02:00
} else {
clearInterval ( checkPendingInterval ) ;
}
2020-06-17 03:56:51 +02:00
} ;
2021-06-24 20:26:51 +02:00
// do something with onConfirmed (typically get blocklist for channel)
checkPendingInterval = setInterval ( ( ) => {
2021-07-02 22:44:44 +02:00
checkTxoList ( ) ;
2020-06-17 03:56:51 +02:00
} , 30000 ) ;
} ;
2021-05-07 00:41:02 +02:00
function _asyncToGenerator$2 ( 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" ) ; } ) ; } ; }
const getTimestamp = ( ) => {
return Math . floor ( Date . now ( ) / 1000 ) ;
} ;
2021-08-03 20:05:03 +02:00
const FETCH _BATCH _SIZE = 50 ;
2021-05-25 14:59:56 +02:00
2021-05-07 00:41:02 +02:00
const doLocalCollectionCreate = ( name , collectionItems , type , sourceId ) => dispatch => {
return dispatch ( {
type : COLLECTION _NEW ,
data : {
entry : {
id : uuid . v4 ( ) , // start with a uuid, this becomes a claimId after publish
name : name ,
updatedAt : getTimestamp ( ) ,
items : collectionItems || [ ] ,
sourceId : sourceId ,
type : type
}
}
} ) ;
} ;
2021-05-26 17:36:17 +02:00
const doCollectionDelete = ( id , colKey = undefined ) => ( dispatch , getState ) => {
const state = getState ( ) ;
const claim = makeSelectClaimForClaimId ( id ) ( state ) ;
const collectionDelete = ( ) => dispatch ( {
2021-05-07 00:41:02 +02:00
type : COLLECTION _DELETE ,
data : {
2021-05-12 21:11:04 +02:00
id : id ,
collectionKey : colKey
2021-05-07 00:41:02 +02:00
}
} ) ;
2021-05-28 14:37:32 +02:00
if ( claim && ! colKey ) {
// could support "abandon, but keep" later
2021-05-26 17:36:17 +02:00
const { txid , nout } = claim ;
return dispatch ( doAbandonClaim ( txid , nout , collectionDelete ) ) ;
}
return collectionDelete ( ) ;
2021-05-07 00:41:02 +02:00
} ;
// Given a collection, save its collectionId to be resolved and displayed in Library
// export const doCollectionSave = (
// id: string,
// ) => (dispatch: Dispatch) => {
// return dispatch({
// type: ACTIONS.COLLECTION_SAVE,
// data: {
// id: id,
// },
// });
// };
// Given a collection and name, copy it to a local private collection with a name
// export const doCollectionCopy = (
// id: string,
// ) => (dispatch: Dispatch) => {
// return dispatch({
// type: ACTIONS.COLLECTION_COPY,
// data: {
// id: id,
// },
// });
// };
const doFetchItemsInCollections = ( resolveItemsOptions , resolveStartedCallback ) => ( ( ) => {
var _ref = _asyncToGenerator$2 ( function * ( dispatch , getState ) {
2021-05-25 14:59:56 +02:00
let fetchItemsForCollectionClaim = ( ( ) => {
var _ref2 = _asyncToGenerator$2 ( function * ( claim , pageSize ) {
const totalItems = claim . value . claims && claim . value . claims . length ;
const claimId = claim . claim _id ;
const itemOrder = claim . value . claims ;
2021-06-04 15:22:54 +02:00
const sortResults = function ( items , claimList ) {
const newItems = [ ] ;
2021-05-25 14:59:56 +02:00
claimList . forEach ( function ( id ) {
2021-06-04 15:22:54 +02:00
const index = items . findIndex ( function ( i ) {
2021-05-25 14:59:56 +02:00
return i . claim _id === id ;
} ) ;
2021-06-04 15:22:54 +02:00
if ( index >= 0 ) {
newItems . push ( items [ index ] ) ;
}
2021-05-25 14:59:56 +02:00
} ) ;
2021-06-04 15:22:54 +02:00
/ *
This will return newItems [ ] of length less than total _items below
if one or more of the claims has been abandoned . That ' s ok for now .
* /
return newItems ;
2021-05-25 14:59:56 +02:00
} ;
const mergeBatches = function ( arrayOfResults , claimList ) {
2021-05-07 00:41:02 +02:00
const mergedResults = {
items : [ ] ,
total _items : 0
} ;
arrayOfResults . forEach ( function ( result ) {
mergedResults . items = mergedResults . items . concat ( result . items ) ;
mergedResults . total _items = result . total _items ;
} ) ;
2021-05-25 14:59:56 +02:00
mergedResults . items = sortResults ( mergedResults . items , claimList ) ;
2021-05-07 00:41:02 +02:00
return mergedResults ;
} ;
try {
2021-05-25 14:59:56 +02:00
const batchSize = pageSize || FETCH _BATCH _SIZE ;
2021-05-07 00:41:02 +02:00
const batches = [ ] ;
2021-05-25 14:59:56 +02:00
for ( let i = 0 ; i < Math . ceil ( totalItems / batchSize ) ; i ++ ) {
batches [ i ] = lbryProxy . claim _search ( {
claim _ids : claim . value . claims ,
page : i + 1 ,
2021-08-03 20:05:03 +02:00
page _size : batchSize ,
no _totals : true
2021-05-07 00:41:02 +02:00
} ) ;
}
2021-05-25 14:59:56 +02:00
const itemsInBatches = yield Promise . all ( batches ) ;
const result = mergeBatches ( itemsInBatches , itemOrder ) ;
2021-05-07 00:41:02 +02:00
// $FlowFixMe
const itemsById = { claimId : claimId } ;
2021-05-25 14:59:56 +02:00
if ( result . items ) {
itemsById . items = result . items ;
2021-05-07 00:41:02 +02:00
} else {
itemsById . items = null ;
}
return itemsById ;
} catch ( e ) {
return {
claimId : claimId ,
items : null
} ;
}
} ) ;
2021-05-25 14:59:56 +02:00
return function fetchItemsForCollectionClaim ( _x3 , _x4 ) {
2021-05-07 00:41:02 +02:00
return _ref2 . apply ( this , arguments ) ;
} ;
} ) ( ) ;
2021-05-25 14:59:56 +02:00
/ *
1 ) make sure all the collection claims are loaded into claims reducer , search / resolve if necessary .
2 ) get the item claims for each
3 ) format and make sure they ' re in the order as in the claim
4 ) Build the collection objects and update collections reducer
5 ) Update redux claims reducer
* /
2021-05-07 00:41:02 +02:00
let state = getState ( ) ;
const { collectionIds , pageSize } = resolveItemsOptions ;
2019-04-03 19:12:51 +02:00
2021-05-07 00:41:02 +02:00
dispatch ( {
type : COLLECTION _ITEMS _RESOLVE _STARTED ,
data : { ids : collectionIds }
} ) ;
if ( resolveStartedCallback ) resolveStartedCallback ( ) ;
const collectionIdsToSearch = collectionIds . filter ( function ( claimId ) {
return ! state . claims . byId [ claimId ] ;
} ) ;
2021-05-25 14:59:56 +02:00
2021-05-07 00:41:02 +02:00
if ( collectionIdsToSearch . length ) {
2021-05-25 14:59:56 +02:00
yield dispatch ( doClaimSearch ( { claim _ids : collectionIdsToSearch , page : 1 , page _size : 9999 } ) ) ;
2021-05-07 00:41:02 +02:00
}
2021-05-25 14:59:56 +02:00
const stateAfterClaimSearch = getState ( ) ;
2021-05-07 00:41:02 +02:00
2021-05-25 14:59:56 +02:00
function formatForClaimActions ( resultClaimsByUri ) {
const formattedClaims = { } ;
2021-05-07 00:41:02 +02:00
Object . entries ( resultClaimsByUri ) . forEach ( ( [ uri , uriResolveInfo ] ) => {
// Flow has terrible Object.entries support
// https://github.com/facebook/flow/issues/2221
if ( uriResolveInfo ) {
let result = { } ;
if ( uriResolveInfo . value _type === 'channel' ) {
result . channel = uriResolveInfo ;
// $FlowFixMe
result . claimsInChannel = uriResolveInfo . meta . claims _in _channel ;
// ALSO SKIP COLLECTIONS
2021-05-25 14:59:56 +02:00
} else if ( uriResolveInfo . value _type === 'collection' ) {
result . collection = uriResolveInfo ;
2021-05-07 00:41:02 +02:00
} else {
result . stream = uriResolveInfo ;
if ( uriResolveInfo . signing _channel ) {
result . channel = uriResolveInfo . signing _channel ;
result . claimsInChannel = uriResolveInfo . signing _channel . meta && uriResolveInfo . signing _channel . meta . claims _in _channel || 0 ;
}
}
// $FlowFixMe
2021-05-25 14:59:56 +02:00
formattedClaims [ uri ] = result ;
2021-05-07 00:41:02 +02:00
}
} ) ;
2021-05-25 14:59:56 +02:00
return formattedClaims ;
2021-05-07 00:41:02 +02:00
}
2021-05-25 14:59:56 +02:00
const invalidCollectionIds = [ ] ;
const promisedCollectionItemFetches = [ ] ;
collectionIds . forEach ( function ( collectionId ) {
const claim = makeSelectClaimForClaimId ( collectionId ) ( stateAfterClaimSearch ) ;
if ( ! claim ) {
invalidCollectionIds . push ( collectionId ) ;
} else {
promisedCollectionItemFetches . push ( fetchItemsForCollectionClaim ( claim , pageSize ) ) ;
}
} ) ;
// $FlowFixMe
const collectionItemsById = yield Promise . all ( promisedCollectionItemFetches ) ;
const newCollectionObjectsById = { } ;
const resolvedItemsByUrl = { } ;
collectionItemsById . forEach ( function ( entry ) {
2021-05-07 00:41:02 +02:00
// $FlowFixMe
const collectionItems = entry . items ;
const collectionId = entry . claimId ;
if ( collectionItems ) {
const claim = makeSelectClaimForClaimId ( collectionId ) ( stateAfterClaimSearch ) ;
const editedCollection = makeSelectEditedCollectionForId ( collectionId ) ( stateAfterClaimSearch ) ;
2021-05-19 17:36:11 +02:00
const { name , timestamp , value } = claim || { } ;
const { title } = value ;
2021-05-07 00:41:02 +02:00
const valueTypes = new Set ( ) ;
const streamTypes = new Set ( ) ;
2021-05-25 14:59:56 +02:00
let newItems = [ ] ;
let isPlaylist ;
2021-05-07 00:41:02 +02:00
2021-05-25 14:59:56 +02:00
if ( collectionItems ) {
collectionItems . forEach ( function ( collectionItem ) {
newItems . push ( collectionItem . permanent _url ) ;
valueTypes . add ( collectionItem . value _type ) ;
if ( collectionItem . value . stream _type ) {
streamTypes . add ( collectionItem . value . stream _type ) ;
}
resolvedItemsByUrl [ collectionItem . canonical _url ] = collectionItem ;
} ) ;
isPlaylist = valueTypes . size === 1 && valueTypes . has ( 'stream' ) && ( streamTypes . size === 1 && ( streamTypes . has ( 'audio' ) || streamTypes . has ( 'video' ) ) || streamTypes . size === 2 && streamTypes . has ( 'audio' ) && streamTypes . has ( 'video' ) ) ;
}
newCollectionObjectsById [ collectionId ] = {
items : newItems ,
2021-05-07 00:41:02 +02:00
id : collectionId ,
2021-05-19 17:36:11 +02:00
name : title || name ,
2021-05-07 00:41:02 +02:00
itemCount : claim . value . claims . length ,
type : isPlaylist ? 'playlist' : 'collection' ,
updatedAt : timestamp
} ;
2021-05-25 14:59:56 +02:00
2021-05-07 00:41:02 +02:00
if ( editedCollection && timestamp > editedCollection [ 'updatedAt' ] ) {
dispatch ( {
type : COLLECTION _DELETE ,
data : {
id : collectionId ,
collectionKey : 'edited'
}
} ) ;
}
2021-05-25 14:59:56 +02:00
} else {
invalidCollectionIds . push ( collectionId ) ;
2021-05-07 00:41:02 +02:00
}
} ) ;
2021-05-25 14:59:56 +02:00
const formattedClaimsByUri = formatForClaimActions ( collectionItemsById ) ;
2021-05-07 00:41:02 +02:00
dispatch ( {
type : RESOLVE _URIS _COMPLETED ,
2021-05-25 14:59:56 +02:00
data : { resolveInfo : formattedClaimsByUri }
2021-05-07 00:41:02 +02:00
} ) ;
dispatch ( {
type : COLLECTION _ITEMS _RESOLVE _COMPLETED ,
data : {
2021-05-25 14:59:56 +02:00
resolvedCollections : newCollectionObjectsById ,
2021-05-07 00:41:02 +02:00
failedCollectionIds : invalidCollectionIds
}
} ) ;
} ) ;
return function ( _x , _x2 ) {
return _ref . apply ( this , arguments ) ;
} ;
} ) ( ) ;
const doFetchItemsInCollection = ( options , cb ) => {
const { collectionId , pageSize } = options ;
const newOptions = {
collectionIds : [ collectionId ]
} ;
if ( pageSize ) newOptions . pageSize = pageSize ;
return doFetchItemsInCollections ( newOptions , cb ) ;
} ;
const doCollectionEdit = ( collectionId , params ) => ( ( ) => {
var _ref3 = _asyncToGenerator$2 ( function * ( dispatch , getState ) {
const state = getState ( ) ;
const collection = makeSelectCollectionForId ( collectionId ) ( state ) ;
const editedCollection = makeSelectEditedCollectionForId ( collectionId ) ( state ) ;
const unpublishedCollection = makeSelectUnpublishedCollectionForId ( collectionId ) ( state ) ;
const publishedCollection = makeSelectPublishedCollectionForId ( collectionId ) ( state ) ; // needs to be published only
const generateCollectionItemsFromSearchResult = function ( results ) {
return Object . values ( results )
// $FlowFixMe
. reduce ( function ( acc , cur ) {
let url ;
if ( cur . stream ) {
url = cur . stream . permanent _url ;
} else if ( cur . channel ) {
url = cur . channel . permanent _url ;
} else if ( cur . collection ) {
url = cur . collection . permanent _url ;
} else {
return acc ;
}
acc . push ( url ) ;
return acc ;
} , [ ] ) ;
} ;
if ( ! collection ) {
return dispatch ( {
type : COLLECTION _ERROR ,
data : {
message : 'collection does not exist'
}
} ) ;
}
let currentItems = collection . items ? collection . items . concat ( ) : [ ] ;
const { claims : passedClaims , order , claimIds , replace , remove , type } = params ;
const collectionType = type || collection . type ;
let newItems = currentItems ;
if ( passedClaims ) {
if ( remove ) {
const passedUrls = passedClaims . map ( function ( claim ) {
return claim . permanent _url ;
} ) ;
// $FlowFixMe // need this?
newItems = currentItems . filter ( function ( item ) {
return ! passedUrls . includes ( item ) ;
} ) ;
} else {
passedClaims . forEach ( function ( claim ) {
return newItems . push ( claim . permanent _url ) ;
} ) ;
}
}
if ( claimIds ) {
const batches = [ ] ;
if ( claimIds . length > 50 ) {
for ( let i = 0 ; i < Math . ceil ( claimIds . length / 50 ) ; i ++ ) {
batches [ i ] = claimIds . slice ( i * 50 , ( i + 1 ) * 50 ) ;
}
} else {
batches [ 0 ] = claimIds ;
}
const resultArray = yield Promise . all ( batches . map ( function ( batch ) {
let options = { claim _ids : batch , page : 1 , page _size : 50 } ;
return dispatch ( doClaimSearch ( options ) ) ;
} ) ) ;
const searchResults = Object . assign ( { } , ... resultArray ) ;
if ( replace ) {
newItems = generateCollectionItemsFromSearchResult ( searchResults ) ;
} else {
newItems = currentItems . concat ( generateCollectionItemsFromSearchResult ( searchResults ) ) ;
}
}
if ( order ) {
const [ movedItem ] = currentItems . splice ( order . from , 1 ) ;
currentItems . splice ( order . to , 0 , movedItem ) ;
}
// console.log('p&e', publishedCollection.items, newItems, publishedCollection.items.join(','), newItems.join(','))
if ( editedCollection ) {
2021-05-25 14:59:56 +02:00
// delete edited if newItems are the same as publishedItems
2021-05-07 00:41:02 +02:00
if ( publishedCollection . items . join ( ',' ) === newItems . join ( ',' ) ) {
dispatch ( {
type : COLLECTION _DELETE ,
data : {
id : collectionId ,
collectionKey : 'edited'
}
} ) ;
} else {
dispatch ( {
type : COLLECTION _EDIT ,
data : {
id : collectionId ,
collectionKey : 'edited' ,
collection : {
items : newItems ,
id : collectionId ,
name : params . name || collection . name ,
updatedAt : getTimestamp ( ) ,
type : collectionType
}
}
} ) ;
}
} else if ( publishedCollection ) {
dispatch ( {
type : COLLECTION _EDIT ,
data : {
id : collectionId ,
collectionKey : 'edited' ,
collection : {
items : newItems ,
id : collectionId ,
name : params . name || collection . name ,
updatedAt : getTimestamp ( ) ,
type : collectionType
}
}
} ) ;
} else if ( BUILTIN _LISTS . includes ( collectionId ) ) {
dispatch ( {
type : COLLECTION _EDIT ,
data : {
id : collectionId ,
collectionKey : 'builtin' ,
collection : {
items : newItems ,
id : collectionId ,
name : params . name || collection . name ,
updatedAt : getTimestamp ( ) ,
type : collectionType
}
}
} ) ;
} else if ( unpublishedCollection ) {
dispatch ( {
type : COLLECTION _EDIT ,
data : {
id : collectionId ,
collectionKey : 'unpublished' ,
collection : {
items : newItems ,
id : collectionId ,
name : params . name || collection . name ,
updatedAt : getTimestamp ( ) ,
type : collectionType
}
}
} ) ;
}
return true ;
} ) ;
2021-05-25 14:59:56 +02:00
return function ( _x5 , _x6 ) {
2021-05-07 00:41:02 +02:00
return _ref3 . apply ( this , arguments ) ;
} ;
} ) ( ) ;
const selectState$3 = state => state . fileInfo || { } ;
const selectFileInfosByOutpoint = reselect . createSelector ( selectState$3 , state => state . byOutpoint || { } ) ;
const selectIsFetchingFileList = reselect . createSelector ( selectState$3 , state => state . isFetchingFileList ) ;
2019-04-03 19:12:51 +02:00
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 ;
} ) ;
2021-05-07 00:41:02 +02:00
const selectDownloadingByOutpoint = reselect . createSelector ( selectState$3 , state => state . downloadingByOutpoint || { } ) ;
2019-04-03 19:12:51 +02:00
const makeSelectDownloadingForUri = uri => reselect . createSelector ( selectDownloadingByOutpoint , makeSelectFileInfoForUri ( uri ) , ( byOutpoint , fileInfo ) => {
if ( ! fileInfo ) return false ;
return byOutpoint [ fileInfo . outpoint ] ;
} ) ;
2021-05-07 00:41:02 +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 ;
} ) ;
2021-05-07 00:41:02 +02:00
const selectFileListPublishedSort = reselect . createSelector ( selectState$3 , state => state . fileListPublishedSort ) ;
2019-04-03 19:12:51 +02:00
2021-05-07 00:41:02 +02:00
const selectFileListDownloadedSort = reselect . createSelector ( selectState$3 , state => state . fileListDownloadedSort ) ;
2019-04-03 19:12:51 +02:00
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 } ` }
} ) ;
2020-10-20 17:47:37 +02:00
if ( onSuccess ) {
onSuccess ( fileInfo ) ;
}
2019-05-21 21:18:07 +02:00
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-07-27 21:35:27 +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 ; } ;
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
2021-05-07 00:41:02 +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
2021-05-07 00:41:02 +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 ;
} ) ;
2021-05-07 00:41:02 +02:00
const selectPublishFormValues = reselect . createSelector ( selectState$4 , state => state . settings , selectIsStillEditing , ( publishState , settingsState , isStillEditing ) => {
2021-06-09 16:32:22 +02:00
const { languages } = publishState ,
formValues = _objectWithoutProperties$2 ( publishState , [ 'languages' ] ) ;
2021-06-13 13:51:49 +02:00
const language = languages && languages . length && languages [ 0 ] ;
2020-11-16 23:35:25 +01:00
const { clientSettings } = settingsState ;
const { language : languageSet } = clientSettings ;
2020-01-15 01:17:25 +01:00
let actualLanguage ;
// Sets default if editing a claim with a set language
2020-11-16 23:35:25 +01:00
if ( ! language && isStillEditing && languageSet ) {
actualLanguage = languageSet ;
2020-01-15 01:17:25 +01:00
} else {
2020-11-16 23:35:25 +01:00
actualLanguage = language || languageSet || 'en' ;
2020-01-15 01:17:25 +01:00
}
2021-01-19 22:31:13 +01:00
2020-07-27 21:35:27 +02:00
return _extends$6 ( { } , formValues , { language : actualLanguage } ) ;
2020-01-15 01:17:25 +01:00
} ) ;
2021-05-07 00:41:02 +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 ) ;
} ) ;
2021-05-07 00:41:02 +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 ;
} ) ;
2021-05-07 00:41:02 +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-07-27 21:35:27 +02:00
var _extends$7 = Object . assign || function ( target ) { for ( var i = 1 ; i < arguments . length ; i ++ ) { var source = arguments [ i ] ; for ( var key in source ) { if ( Object . prototype . hasOwnProperty . call ( source , key ) ) { target [ key ] = source [ key ] ; } } } return target ; } ;
2019-07-01 21:49:51 +02:00
2021-05-07 00:41:02 +02:00
function _asyncToGenerator$3 ( 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" ) ; } ) ; } ; }
2020-05-07 13:41:56 +02:00
2019-07-01 21:49:51 +02:00
const doResetThumbnailStatus = ( ) => dispatch => {
dispatch ( {
type : UPDATE _PUBLISH _FORM ,
data : {
2021-05-17 19:23:37 +02:00
thumbnailPath : '' ,
thumbnailError : undefined
2019-07-01 21:49:51 +02:00
}
} ) ;
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-07-27 21:35:27 +02:00
data : _extends$7 ( { } , 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 => {
2020-08-10 23:31:29 +02:00
const downMessage = _ _ ( 'Thumbnail upload service may be down, try again later.' ) ;
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 ) ) ) ;
} ;
2021-05-17 19:23:37 +02:00
dispatch ( {
type : UPDATE _PUBLISH _FORM ,
data : {
thumbnailError : undefined
}
} ) ;
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
}
2020-08-10 23:31:29 +02:00
} ) : uploadError ( json . message || downMessage ) ;
2020-04-27 20:13:36 +02:00
} ) . catch ( err => {
2020-08-10 23:31:29 +02:00
let message = err . message ;
// This sucks but ¯\_(ツ)_/¯
if ( message === 'Failed to fetch' ) {
message = downMessage ;
}
uploadError ( message ) ;
2020-04-27 20:13:36 +02:00
} ) ;
} ;
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 ,
2021-02-11 15:12:15 +01:00
release _time ,
2019-07-01 21:49:51 +02:00
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 ,
2021-04-30 10:22:28 +02:00
releaseTime : release _time ,
releaseTimeEdited : undefined ,
2019-07-01 21:49:51 +02:00
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 } ) ;
} ;
2020-07-23 09:41:01 +02:00
const doPublish = ( success , fail , preview ) => ( dispatch , getState ) => {
if ( ! preview ) {
dispatch ( { type : PUBLISH _START } ) ;
}
2019-07-01 21:49:51 +02:00
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 ,
2021-04-30 10:22:28 +02:00
releaseTimeEdited ,
2019-07-01 21:49:51 +02:00
license ,
licenseUrl ,
2020-03-10 03:10:30 +01: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 ,
2021-01-19 22:31:13 +01:00
optimize ,
2021-03-29 02:53:51 +02:00
isLivestreamPublish ,
remoteFileUrl
2019-07-05 04:20:56 +02:00
} = publishData ;
2021-01-19 22:31:13 +01:00
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 ,
2020-07-23 09:41:01 +02:00
blocking : true ,
preview : false
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
2021-03-29 02:53:51 +02:00
if ( remoteFileUrl ) {
publishPayload . remote _url = remoteFileUrl ;
}
2019-07-01 21:49:51 +02:00
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 ;
}
2020-07-08 00:06:59 +02:00
if ( useLBRYUploader ) {
publishPayload . tags . push ( 'lbry-first' ) ;
}
2019-07-29 20:42:28 +02:00
// Set release time to curret date. On edits, keep original release/transaction time as release_time
2021-04-30 10:22:28 +02:00
if ( releaseTimeEdited ) {
publishPayload . release _time = releaseTimeEdited ;
2021-02-11 15:12:15 +01:00
} else 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
2021-03-17 19:39:18 +01:00
if ( filePath && ! isLivestreamPublish ) publishPayload . file _path = filePath ;
2021-01-19 22:31:13 +01:00
2020-07-23 09:41:01 +02:00
if ( preview ) {
publishPayload . preview = true ;
publishPayload . optimize _file = false ;
return lbryProxy . publish ( publishPayload ) . then ( previewResponse => {
return preview ( previewResponse ) ;
} , fail ) ;
}
2020-03-10 03:10:30 +01:00
return lbryProxy . publish ( publishPayload ) . then ( response => {
if ( ! useLBRYUploader ) {
return success ( response ) ;
}
2020-07-09 16:51:50 +02:00
2020-07-10 19:39:55 +02:00
// $FlowFixMe
publishPayload . permanent _url = response . outputs [ 0 ] . permanent _url ;
2020-07-09 16:51:50 +02:00
return lbryFirstProxy . upload ( publishPayload ) . then ( ( ) => {
// Return original publish response so app treats it like a normal publish
return success ( response ) ;
} ) . catch ( error => {
return success ( response , error ) ;
} ) ;
2020-03-10 03:10:30 +01:00
} , 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 = ( ( ) => {
2021-05-07 00:41:02 +02:00
var _ref = _asyncToGenerator$3 ( function * ( ) {
2020-05-07 13:41:56 +02:00
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 ) {
2020-07-10 12:16:09 +02:00
if ( res . items [ 0 ] ) {
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
} ;
}
2020-05-07 13:41:56 +02:00
}
} ) ;
} ) . 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
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
2020-07-27 21:35:27 +02:00
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 ( '&' ) ;
}
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-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 ) {
2020-07-27 21:35:27 +02:00
return _extends$8 ( { } , maybeResolved , pending , { meta : maybeResolved . meta } ) ;
2020-06-17 03:56:51 +02:00
}
2020-07-27 21:35:27 +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 ; } ;
2020-06-17 03:56:51 +02:00
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 ,
2021-05-07 00:41:02 +02:00
myCollectionClaims : [ ] ,
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 ,
2021-05-07 00:41:02 +02:00
fetchingMyCollections : false ,
2019-04-23 19:22:14 +02:00
abandoningById : { } ,
2021-06-24 20:26:51 +02:00
pendingById : { } ,
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 : '' ,
2021-05-07 00:41:02 +02:00
updateCollectionError : '' ,
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 ,
2021-05-07 00:41:02 +02:00
updatingCollection : false ,
creatingCollection : false ,
createCollectionError : 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 ) {
2021-05-07 00:41:02 +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 ) ;
2021-06-24 20:26:51 +02:00
const pendingById = state . pendingById ;
2019-09-04 17:57:48 +02:00
let newResolvingUrls = new Set ( state . resolvingUris ) ;
2020-07-22 21:23:11 +02:00
let myClaimIds = new Set ( state . myClaims ) ;
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
2021-05-07 00:41:02 +02:00
const { claimsInChannel , stream , channel : channelFromResolve , collection } = resolveResponse ;
2021-02-19 05:30:20 +01:00
const channel = channelFromResolve || stream && stream . signing _channel ;
2019-04-03 19:12:51 +02:00
2019-06-11 18:22:44 +02:00
if ( stream ) {
2021-06-24 20:26:51 +02:00
if ( pendingById [ stream . claim _id ] ) {
2020-06-17 03:56:51 +02:00
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-07-22 21:23:11 +02:00
if ( stream . is _my _output ) {
myClaimIds . add ( stream . claim _id ) ;
}
2019-09-04 17:57:48 +02:00
}
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
}
2021-06-24 20:26:51 +02:00
if ( pendingById [ channel . claim _id ] ) {
2020-06-17 03:56:51 +02:00
byId [ channel . claim _id ] = mergeClaims ( channel , byId [ channel . claim _id ] ) ;
} else {
byId [ channel . claim _id ] = channel ;
}
2021-06-01 18:19:35 +02:00
2019-09-04 17:57:48 +02:00
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
2021-05-07 00:41:02 +02:00
if ( collection ) {
2021-06-24 20:26:51 +02:00
if ( pendingById [ collection . claim _id ] ) {
2021-05-07 00:41:02 +02:00
byId [ collection . claim _id ] = mergeClaims ( collection , byId [ collection . claim _id ] ) ;
} else {
byId [ collection . claim _id ] = collection ;
}
byUri [ url ] = collection . claim _id ;
byUri [ collection . canonical _url ] = collection . claim _id ;
byUri [ collection . permanent _url ] = collection . claim _id ;
newResolvingUrls . delete ( collection . canonical _url ) ;
newResolvingUrls . delete ( collection . permanent _url ) ;
if ( collection . is _my _output ) {
myClaimIds . add ( collection . claim _id ) ;
}
}
2019-09-04 17:57:48 +02:00
newResolvingUrls . delete ( url ) ;
2021-06-24 20:26:51 +02:00
if ( ! stream && ! channel && ! collection && ! pendingById [ byUri [ url ] ] ) {
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 ,
2020-07-22 21:23:11 +02:00
resolvingUris : Array . from ( newResolvingUrls ) ,
myClaims : Array . from ( myClaimIds )
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-07-27 21:35:27 +02:00
return _extends$9 ( { } , 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 ) => {
2021-06-24 20:26:51 +02:00
const { result } = action . data ;
2020-04-25 22:31:53 +02:00
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 ) ;
2021-06-24 20:26:51 +02:00
const pendingById = Object . assign ( { } , state . pendingById ) ;
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
claims . forEach ( claim => {
2021-06-24 20:26:51 +02:00
const { permanent _url : permanentUri , claim _id : claimId , canonical _url : canonicalUri } = 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 ) {
2021-06-24 20:26:51 +02:00
pendingById [ claimId ] = claim ;
if ( byId [ claimId ] ) {
byId [ claimId ] = mergeClaims ( claim , byId [ claimId ] ) ;
} else {
byId [ claimId ] = claim ;
}
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 ;
2021-06-24 20:26:51 +02:00
byUri [ canonicalUri ] = 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 ,
2021-06-24 20:26:51 +02:00
pendingById ,
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 ;
2020-03-25 03:46:35 +01:00
let myClaimIds = new Set ( state . myClaims ) ;
2021-06-24 20:26:51 +02:00
const pendingById = Object . assign ( { } , state . pendingById ) ;
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 ;
2021-06-24 23:53:09 +02:00
const {
canonical _url : canonicalUrl ,
permanent _url : permanentUrl ,
claim _id : claimId ,
confirmations
} = claim ;
2020-02-12 22:45:30 +01:00
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 ) ;
2021-06-24 20:26:51 +02:00
if ( confirmations < 1 ) {
pendingById [ claimId ] = claim ;
if ( byId [ claimId ] ) {
byId [ claimId ] = mergeClaims ( claim , byId [ claimId ] ) ;
} else {
byId [ claimId ] = claim ;
}
} else {
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 ,
2021-06-24 20:26:51 +02:00
pendingById ,
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
} ) ;
} ;
2021-05-07 00:41:02 +02:00
reducers [ FETCH _COLLECTION _LIST _STARTED ] = state => _extends$9 ( { } , state , {
fetchingMyCollections : true
} ) ;
reducers [ FETCH _COLLECTION _LIST _COMPLETED ] = ( state , action ) => {
const { claims } = action . data ;
const myClaims = state . myClaims || [ ] ;
let myClaimIds = new Set ( myClaims ) ;
2021-06-24 20:26:51 +02:00
const pendingById = Object . assign ( { } , state . pendingById ) ;
2021-05-07 00:41:02 +02:00
let myCollectionClaimsSet = new Set ( [ ] ) ;
const byId = Object . assign ( { } , state . byId ) ;
const byUri = Object . assign ( { } , state . claimsByUri ) ;
if ( claims . length ) {
myCollectionClaimsSet = new Set ( state . myCollectionClaims ) ;
claims . forEach ( claim => {
2021-06-24 23:53:09 +02:00
const {
canonical _url : canonicalUrl ,
permanent _url : permanentUrl ,
claim _id : claimId ,
confirmations
} = claim ;
2021-05-07 00:41:02 +02:00
byUri [ canonicalUrl ] = claimId ;
byUri [ permanentUrl ] = claimId ;
// $FlowFixMe
myCollectionClaimsSet . add ( claimId ) ;
// we don't want to overwrite a pending result with a resolve
2021-06-24 20:26:51 +02:00
if ( confirmations < 1 ) {
pendingById [ claimId ] = claim ;
if ( byId [ claimId ] ) {
byId [ claimId ] = mergeClaims ( claim , byId [ claimId ] ) ;
} else {
byId [ claimId ] = claim ;
}
} else {
2021-05-07 00:41:02 +02:00
byId [ claimId ] = claim ;
}
myClaimIds . add ( claimId ) ;
} ) ;
}
return _extends$9 ( { } , state , {
byId ,
2021-06-24 20:26:51 +02:00
pendingById ,
2021-05-07 00:41:02 +02:00
claimsByUri : byUri ,
fetchingMyCollections : false ,
myCollectionClaims : Array . from ( myCollectionClaimsSet ) ,
myClaims : myClaimIds ? Array . from ( myClaimIds ) : null
} ) ;
} ;
reducers [ FETCH _COLLECTION _LIST _FAILED ] = state => {
return _extends$9 ( { } , state , { fetchingMyCollections : 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 ) ;
2021-06-24 20:26:51 +02:00
const pendingById = Object . assign ( { } , state . pendingById ) ;
2020-04-25 22:31:53 +02:00
const byUri = Object . assign ( { } , state . claimsByUri ) ;
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 ;
2021-06-24 20:26:51 +02:00
pendingById [ claimId ] = claim ; // make sure we don't need to merge?
2020-06-17 03:56:51 +02:00
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 ,
2021-06-24 20:26:51 +02:00
pendingById ,
2020-06-17 03:56:51 +02:00
myChannelClaims : Array . from ( myChannelClaims ) ,
2021-06-24 20:26:51 +02:00
claimsByUri : byUri
2020-04-25 22:31:53 +02:00
} ) ;
} ;
reducers [ UPDATE _CONFIRMED _CLAIMS ] = ( state , action ) => {
2021-06-24 23:53:09 +02:00
const {
claims : confirmedClaims ,
pending : pendingClaims
} = action . data ;
2020-04-25 22:31:53 +02:00
const byId = Object . assign ( { } , state . byId ) ;
const byUri = Object . assign ( { } , state . claimsByUri ) ;
2021-06-24 20:26:51 +02:00
//
2020-06-17 03:56:51 +02:00
confirmedClaims . forEach ( claim => {
2021-06-24 20:26:51 +02:00
const { claim _id : claimId , type } = claim ;
2020-06-17 03:56:51 +02:00
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 ;
2020-04-25 22:31:53 +02:00
}
} ) ;
return Object . assign ( { } , state , {
2021-06-24 20:26:51 +02:00
pendingById : pendingClaims ,
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 ) ;
2021-05-26 17:36:17 +02:00
const newMyCollectionClaims = state . myCollectionClaims ? state . myCollectionClaims . slice ( ) : [ ] ;
2019-04-03 19:12:51 +02:00
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 ) ;
2021-05-26 17:36:17 +02:00
const myCollectionClaims = newMyCollectionClaims . filter ( i => i !== claimId ) ;
2020-04-10 14:16:27 +02:00
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 ,
2021-05-26 17:36:17 +02:00
myCollectionClaims ,
2019-04-03 19:12:51 +02:00
byId ,
claimsByUri
} ) ;
} ;
2020-07-27 21:35:27 +02:00
reducers [ CLEAR _CHANNEL _ERRORS ] = state => _extends$9 ( { } , state , {
2020-07-03 00:03:55 +02:00
createChannelError : null ,
updateChannelError : null
} ) ;
2020-07-27 21:35:27 +02:00
reducers [ CREATE _CHANNEL _STARTED ] = state => _extends$9 ( { } , 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
} ) ;
} ;
2021-05-07 00:41:02 +02:00
reducers [ CLEAR _COLLECTION _ERRORS ] = state => _extends$9 ( { } , state , {
createCollectionError : null ,
updateCollectionError : null
} ) ;
reducers [ COLLECTION _PUBLISH _STARTED ] = state => _extends$9 ( { } , state , {
creatingCollection : true ,
createCollectionError : null
} ) ;
reducers [ COLLECTION _PUBLISH _COMPLETED ] = ( state , action ) => {
2021-05-12 21:11:04 +02:00
const myCollections = state . myCollectionClaims || [ ] ;
const myClaims = state . myClaims || [ ] ;
const { claimId } = action . data ;
let myClaimIds = new Set ( myClaims ) ;
let myCollectionClaimsSet = new Set ( myCollections ) ;
myClaimIds . add ( claimId ) ;
myCollectionClaimsSet . add ( claimId ) ;
2021-05-07 00:41:02 +02:00
return Object . assign ( { } , state , {
2021-05-12 21:11:04 +02:00
creatingCollection : false ,
myClaims : Array . from ( myClaimIds ) ,
myCollectionClaims : Array . from ( myCollectionClaimsSet )
2021-05-07 00:41:02 +02:00
} ) ;
} ;
reducers [ COLLECTION _PUBLISH _FAILED ] = ( state , action ) => {
return Object . assign ( { } , state , {
creatingCollection : false ,
createCollectionError : action . data . error
} ) ;
} ;
reducers [ COLLECTION _PUBLISH _UPDATE _STARTED ] = ( state , action ) => {
return Object . assign ( { } , state , {
updateCollectionError : '' ,
updatingCollection : true
} ) ;
} ;
reducers [ COLLECTION _PUBLISH _UPDATE _COMPLETED ] = ( state , action ) => {
return Object . assign ( { } , state , {
updateCollectionError : '' ,
updatingCollection : false
} ) ;
} ;
reducers [ COLLECTION _PUBLISH _UPDATE _FAILED ] = ( state , action ) => {
return Object . assign ( { } , state , {
updateCollectionError : action . data . error ,
updatingCollection : false
} ) ;
} ;
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-07-27 21:35:27 +02:00
return Object . assign ( { } , state , _extends$9 ( { } , 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-11-09 18:05:53 +01:00
const claimSearchByQueryLastPageReached = Object . assign ( { } , state . claimSearchByQueryLastPageReached ) ;
2020-03-31 17:58:31 +02:00
delete fetchingClaimSearchByQuery [ query ] ;
2020-11-09 18:05:53 +01:00
if ( claimSearchByQuery [ query ] && claimSearchByQuery [ query ] . length !== 0 ) {
claimSearchByQueryLastPageReached [ query ] = true ;
} else {
claimSearchByQuery [ query ] = null ;
}
2019-07-15 04:44:02 +02:00
return Object . assign ( { } , state , {
2020-03-31 17:58:31 +02:00
fetchingClaimSearchByQuery ,
2020-11-09 18:05:53 +01:00
claimSearchByQuery ,
claimSearchByQueryLastPageReached
2019-07-15 04:44:02 +02:00
} ) ;
} ;
2020-02-10 16:49:45 +01:00
reducers [ CLAIM _REPOST _STARTED ] = state => {
2020-07-27 21:35:27 +02:00
return _extends$9 ( { } , 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-07-27 21:35:27 +02:00
const byId = _extends$9 ( { } , state . byId ) ;
const claimsByUri = _extends$9 ( { } , state . claimsByUri ) ;
2020-02-10 16:49:45 +01:00
const claimThatWasReposted = byId [ originalClaimId ] ;
2020-07-27 21:35:27 +02:00
const repostStub = _extends$9 ( { } , 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-07-27 21:35:27 +02:00
return _extends$9 ( { } , 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-07-27 21:35:27 +02:00
return _extends$9 ( { } , state , {
2020-02-10 16:49:45 +01:00
repostLoading : false ,
repostError : error
} ) ;
} ;
reducers [ CLEAR _REPOST _ERROR ] = state => {
2020-07-27 21:35:27 +02:00
return _extends$9 ( { } , 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-07-27 21:35:27 +02:00
return Object . assign ( { } , state , _extends$9 ( { } , state , {
2020-05-07 13:41:56 +02:00
reflectingById : reflectingById
} ) ) ;
} ;
reducers [ UPDATE _FILES _REFLECTING ] = ( state , action ) => {
const newReflectingById = action . data ;
2020-07-27 21:35:27 +02:00
return Object . assign ( { } , state , _extends$9 ( { } , state , {
2020-05-07 13:41:56 +02:00
reflectingById : newReflectingById
} ) ) ;
} ;
reducers [ TOGGLE _CHECKING _REFLECTING ] = ( state , action ) => {
const checkingReflecting = action . data ;
2020-07-27 21:35:27 +02:00
return Object . assign ( { } , state , _extends$9 ( { } , state , {
2020-05-07 13:41:56 +02:00
checkingReflecting
} ) ) ;
} ;
reducers [ TOGGLE _CHECKING _PENDING ] = ( state , action ) => {
const checking = action . data ;
2020-07-27 21:35:27 +02:00
return Object . assign ( { } , state , _extends$9 ( { } , 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-07-27 21:35:27 +02:00
return _extends$9 ( { } , 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-07-27 21:35:27 +02:00
return _extends$9 ( { } , 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-07-27 21:35:27 +02:00
return _extends$9 ( { } , state , {
2020-05-18 22:40:33 +02:00
byId ,
myPurchases ,
purchaseUriSuccess : true
} ) ;
} ;
reducers [ PURCHASE _URI _FAILED ] = state => {
2020-07-27 21:35:27 +02:00
return _extends$9 ( { } , 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-07-27 21:35:27 +02:00
return _extends$9 ( { } , 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-07-27 21:35:27 +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-05-21 21:18:07 +02:00
2020-06-29 23:02:19 +02:00
const reducers$1 = { } ;
2020-07-14 18:43:45 +02:00
const defaultState$1 = {
2019-07-01 21:49:51 +02:00
positions : { }
} ;
reducers$1 [ SET _CONTENT _POSITION ] = ( state , action ) => {
const { claimId , outpoint , position } = action . data ;
2020-07-27 21:35:27 +02:00
return _extends$a ( { } , state , {
positions : _extends$a ( { } , state . positions , {
[ claimId ] : _extends$a ( { } , state . positions [ claimId ] , {
2019-07-01 21:49:51 +02:00
[ outpoint ] : position
} )
} )
2019-05-21 21:18:07 +02:00
} ) ;
} ;
2020-07-14 18:43:45 +02:00
function contentReducer ( state = defaultState$1 , 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-07-14 18:43:45 +02:00
const defaultState$2 = {
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-07-14 18:43:45 +02:00
function fileInfoReducer ( state = defaultState$2 , 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-07-14 18:43:45 +02:00
// util for creating reducers
// based off of redux-actions
// https://redux-actions.js.org/docs/api/handleAction.html#handleactions
2020-06-23 20:48:30 +02:00
2020-07-14 18:43:45 +02:00
// 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-07-27 21:35:27 +02:00
var _extends$b = Object . assign || function ( target ) { for ( var i = 1 ; i < arguments . length ; i ++ ) { var source = arguments [ i ] ; for ( var key in source ) { if ( Object . prototype . hasOwnProperty . call ( source , key ) ) { target [ key ] = source [ key ] ; } } } return target ; } ;
2020-07-14 18:43:45 +02:00
const defaultState$3 = {
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-07-27 21:35:27 +02:00
return _extends$b ( { } , state , {
2019-04-03 19:12:51 +02:00
toasts : newToasts
} ) ;
} ,
[ DISMISS _TOAST ] : state => {
const newToasts = state . toasts . slice ( ) ;
newToasts . shift ( ) ;
2020-07-27 21:35:27 +02:00
return _extends$b ( { } , 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-07-27 21:35:27 +02:00
return _extends$b ( { } , 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-07-27 21:35:27 +02:00
return _extends$b ( { } , 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-07-27 21:35:27 +02:00
return _extends$b ( { } , 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-07-27 21:35:27 +02:00
return _extends$b ( { } , state , {
2019-04-03 19:12:51 +02:00
errors : newErrors
} ) ;
} ,
[ DISMISS _ERROR ] : state => {
const newErrors = state . errors . slice ( ) ;
newErrors . shift ( ) ;
2020-07-27 21:35:27 +02:00
return _extends$b ( { } , state , {
2019-04-03 19:12:51 +02:00
errors : newErrors
} ) ;
}
2020-07-14 18:43:45 +02:00
} , defaultState$3 ) ;
2019-07-01 21:49:51 +02:00
2020-07-27 21:35:27 +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-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-07-14 18:43:45 +02:00
const defaultState$4 = {
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 ,
2021-03-29 02:53:51 +02:00
remoteFileUrl : undefined ,
2019-07-01 21:49:51 +02:00
contentIsFree : true ,
fee : {
amount : 1 ,
currency : 'LBC'
} ,
title : '' ,
thumbnail _url : '' ,
thumbnailPath : '' ,
uploadThumbnailStatus : API _DOWN ,
2021-05-11 05:02:48 +02:00
thumbnailError : undefined ,
2019-07-01 21:49:51 +02:00
description : '' ,
2020-01-15 01:17:25 +01:00
language : '' ,
2021-03-05 21:36:07 +01:00
releaseTime : undefined ,
2021-04-30 10:22:28 +02:00
releaseTimeEdited : undefined ,
2019-07-01 21:49:51 +02:00
nsfw : false ,
channel : CHANNEL _ANONYMOUS ,
channelId : '' ,
name : '' ,
nameError : undefined ,
2020-09-18 16:05:28 +02:00
bid : 0.01 ,
2019-07-01 21:49:51 +02:00
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-03-10 03:10:30 +01: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-07-27 21:35:27 +02:00
return _extends$c ( { } , state , data ) ;
2019-07-01 21:49:51 +02:00
} ,
2020-07-27 21:35:27 +02:00
[ CLEAR _PUBLISH ] : state => _extends$c ( { } , defaultState$4 , {
2021-02-24 21:33:22 +01:00
uri : undefined ,
2020-08-14 12:32:36 +02:00
channel : state . channel ,
2020-03-31 16:05:12 +02:00
bid : state . bid ,
2020-11-16 23:35:25 +01:00
optimize : state . optimize ,
language : state . language
2020-03-02 07:28:36 +01:00
} ) ,
2020-07-27 21:35:27 +02:00
[ PUBLISH _START ] : state => _extends$c ( { } , state , {
2019-07-01 21:49:51 +02:00
publishing : true ,
publishSuccess : false
} ) ,
2020-07-27 21:35:27 +02:00
[ PUBLISH _FAIL ] : state => _extends$c ( { } , state , {
2019-07-01 21:49:51 +02:00
publishing : false
} ) ,
2020-07-27 21:35:27 +02:00
[ PUBLISH _SUCCESS ] : state => _extends$c ( { } , 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-07-27 21:35:27 +02:00
return _extends$c ( { } , defaultState$4 , publishData , {
2019-07-01 21:49:51 +02:00
editingURI : uri ,
uri : shortUri
} ) ;
}
2020-07-14 18:43:45 +02:00
} , defaultState$4 ) ;
2019-04-03 19:12:51 +02:00
2020-07-27 21:35:27 +02:00
var _extends$d = Object . assign || function ( target ) { for ( var i = 1 ; i < arguments . length ; i ++ ) { var source = arguments [ i ] ; for ( var key in source ) { if ( Object . prototype . hasOwnProperty . call ( source , key ) ) { target [ key ] = source [ key ] ; } } } return target ; } ;
2019-07-01 21:49:51 +02:00
2019-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-10-12 15:26:31 +02:00
const defaultState$5 = {
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 : { } ,
2020-12-30 23:25:57 +01:00
utxoCounts : { } ,
fetchingUtxoCounts : false ,
fetchingUtxoError : undefined ,
consolidatingUtxos : false ,
2021-02-03 23:52:01 +01:00
pendingConsolidateTxid : null ,
2021-01-27 16:01:55 +01:00
massClaimingTips : false ,
2021-02-03 23:52:01 +01:00
pendingMassClaimTxid : null ,
2020-04-10 14:16:27 +02:00
txoPage : { } ,
2021-03-18 15:04:46 +01:00
fetchId : '' ,
2020-04-10 14:16:27 +02:00
fetchingTxos : false ,
fetchingTxosError : undefined ,
2020-04-01 20:26:38 +02:00
pendingSupportTransactions : { } ,
2021-02-03 23:52:01 +01:00
pendingTxos : [ ] ,
2020-12-30 23:25:57 +01:00
2020-04-01 20:26:38 +02:00
abandonClaimSupportError : undefined
2019-04-03 19:12:51 +02:00
} ;
2019-05-10 07:02:03 +02:00
const walletReducer = handleActions ( {
2020-10-12 15:26:31 +02:00
[ FETCH _TRANSACTIONS _STARTED ] : state => _extends$d ( { } , 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-10-12 15:26:31 +02:00
const byId = _extends$d ( { } , 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-10-12 15:26:31 +02:00
return _extends$d ( { } , state , {
2019-05-10 07:02:03 +02:00
transactions : byId ,
fetchingTransactions : false
} ) ;
} ,
2019-04-03 19:12:51 +02:00
2021-03-18 15:04:46 +01:00
[ FETCH _TXO _PAGE _STARTED ] : ( state , action ) => {
2020-10-12 15:26:31 +02:00
return _extends$d ( { } , state , {
2021-03-18 15:04:46 +01:00
fetchId : action . data ,
2020-04-10 14:16:27 +02:00
fetchingTxos : true ,
fetchingTxosError : undefined
} ) ;
} ,
[ FETCH _TXO _PAGE _COMPLETED ] : ( state , action ) => {
2021-03-18 15:04:46 +01:00
if ( state . fetchId !== action . data . fetchId ) {
// Leave 'state' and 'fetchingTxos' alone. The latter would ensure
// the spiner would continue spinning for the latest transaction.
return _extends$d ( { } , state ) ;
}
2020-10-12 15:26:31 +02:00
return _extends$d ( { } , state , {
2021-03-18 15:04:46 +01:00
txoPage : action . data . result ,
fetchId : '' ,
2020-04-10 14:16:27 +02:00
fetchingTxos : false
} ) ;
} ,
[ FETCH _TXO _PAGE _FAILED ] : ( state , action ) => {
2020-10-12 15:26:31 +02:00
return _extends$d ( { } , state , {
2020-04-10 14:16:27 +02:00
txoPage : { } ,
2021-03-18 15:04:46 +01:00
fetchId : '' ,
2020-04-10 14:16:27 +02:00
fetchingTxos : false ,
fetchingTxosError : action . data
} ) ;
} ,
2020-12-30 23:25:57 +01:00
[ FETCH _UTXO _COUNT _STARTED ] : state => {
return _extends$d ( { } , state , {
fetchingUtxoCounts : true ,
fetchingUtxoError : undefined
} ) ;
} ,
[ FETCH _UTXO _COUNT _COMPLETED ] : ( state , action ) => {
return _extends$d ( { } , state , {
utxoCounts : action . data ,
fetchingUtxoCounts : false
} ) ;
} ,
[ FETCH _UTXO _COUNT _FAILED ] : ( state , action ) => {
return _extends$d ( { } , state , {
utxoCounts : { } ,
fetchingUtxoCounts : false ,
fetchingUtxoError : action . data
} ) ;
} ,
[ DO _UTXO _CONSOLIDATE _STARTED ] : state => {
return _extends$d ( { } , state , {
consolidatingUtxos : true
} ) ;
} ,
[ DO _UTXO _CONSOLIDATE _COMPLETED ] : ( state , action ) => {
2021-02-03 23:52:01 +01:00
const { txid } = action . data ;
2020-12-30 23:25:57 +01:00
return _extends$d ( { } , state , {
2021-02-03 23:52:01 +01:00
consolidatingUtxos : false ,
pendingConsolidateTxid : txid
2020-12-30 23:25:57 +01:00
} ) ;
} ,
[ DO _UTXO _CONSOLIDATE _FAILED ] : ( state , action ) => {
return _extends$d ( { } , state , {
consolidatingUtxos : false
} ) ;
} ,
2021-01-27 16:01:55 +01:00
[ TIP _CLAIM _MASS _STARTED ] : state => {
return _extends$d ( { } , state , {
massClaimingTips : true
} ) ;
} ,
[ TIP _CLAIM _MASS _COMPLETED ] : ( state , action ) => {
2021-02-03 23:52:01 +01:00
const { txid } = action . data ;
2021-01-27 16:01:55 +01:00
return _extends$d ( { } , state , {
2021-02-03 23:52:01 +01:00
massClaimingTips : false ,
pendingMassClaimTxid : txid
2021-01-27 16:01:55 +01:00
} ) ;
} ,
[ TIP _CLAIM _MASS _FAILED ] : ( state , action ) => {
return _extends$d ( { } , state , {
massClaimingTips : false
} ) ;
} ,
2020-12-30 23:25:57 +01:00
[ PENDING _CONSOLIDATED _TXOS _UPDATED ] : ( state , action ) => {
2021-02-03 23:52:01 +01:00
const { pendingTxos , pendingMassClaimTxid , pendingConsolidateTxid } = state ;
2020-12-30 23:25:57 +01:00
const { txids , remove } = action . data ;
if ( remove ) {
const newTxos = pendingTxos . filter ( txo => ! txids . includes ( txo ) ) ;
2021-02-03 23:52:01 +01:00
const newPendingMassClaimTxid = txids . includes ( pendingMassClaimTxid ) ? undefined : pendingMassClaimTxid ;
const newPendingConsolidateTxid = txids . includes ( pendingConsolidateTxid ) ? undefined : pendingConsolidateTxid ;
return _extends$d ( { } , state , {
pendingTxos : newTxos ,
pendingMassClaimTxid : newPendingMassClaimTxid ,
pendingConsolidateTxid : newPendingConsolidateTxid
} ) ;
2020-12-30 23:25:57 +01:00
} else {
const newPendingSet = new Set ( [ ... pendingTxos , ... txids ] ) ;
2021-02-03 23:52:01 +01:00
return _extends$d ( { } , state , { pendingTxos : Array . from ( newPendingSet ) } ) ;
2020-12-30 23:25:57 +01:00
}
} ,
2020-04-10 14:16:27 +02:00
[ UPDATE _TXO _FETCH _PARAMS ] : ( state , action ) => {
2020-10-12 15:26:31 +02:00
return _extends$d ( { } , state , {
2020-04-10 14:16:27 +02:00
txoFetchParams : action . data
} ) ;
} ,
2020-10-12 15:26:31 +02:00
[ FETCH _SUPPORTS _STARTED ] : state => _extends$d ( { } , 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-10-12 15:26:31 +02:00
return _extends$d ( { } , 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-10-12 15:26:31 +02:00
return _extends$d ( { } , 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-10-12 15:26:31 +02:00
return _extends$d ( { } , state , {
2019-05-14 06:50:21 +02:00
supports : byOutpoint ,
2021-01-04 16:54:17 +01:00
abandoningSupportsByOutpoint : 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-10-12 15:26:31 +02:00
return _extends$d ( { } , 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-10-12 15:26:31 +02:00
return _extends$d ( { } , 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 ) => {
2020-12-30 23:25:57 +01:00
const {
claimId ,
type ,
txid ,
effective
} = action . data ;
2020-03-25 03:46:35 +01:00
const pendingtxs = Object . assign ( { } , state . pendingSupportTransactions ) ;
pendingtxs [ claimId ] = { txid , type , effective } ;
2020-10-12 15:26:31 +02:00
return _extends$d ( { } , state , {
2020-04-01 20:26:38 +02:00
pendingSupportTransactions : pendingtxs ,
abandonClaimSupportError : undefined
} ) ;
} ,
[ ABANDON _CLAIM _SUPPORT _FAILED ] : ( state , action ) => {
2020-10-12 15:26:31 +02:00
return _extends$d ( { } , 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-10-12 15:26:31 +02:00
return _extends$d ( { } , state , {
2020-03-25 03:46:35 +01:00
pendingSupportTransactions : action . data
} ) ;
} ,
2020-10-12 15:26:31 +02:00
[ GET _NEW _ADDRESS _STARTED ] : state => _extends$d ( { } , 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-10-12 15:26:31 +02:00
return _extends$d ( { } , state , { gettingNewAddress : false , receiveAddress : address } ) ;
2019-05-10 07:02:03 +02:00
} ,
2019-04-03 19:12:51 +02:00
2020-10-12 15:26:31 +02:00
[ UPDATE _BALANCE ] : ( state , action ) => _extends$d ( { } , 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-10-12 15:26:31 +02:00
[ CHECK _ADDRESS _IS _MINE _STARTED ] : state => _extends$d ( { } , state , {
2019-05-10 07:02:03 +02:00
checkingAddressOwnership : true
} ) ,
2019-04-03 19:12:51 +02:00
2020-10-12 15:26:31 +02:00
[ CHECK _ADDRESS _IS _MINE _COMPLETED ] : state => _extends$d ( { } , 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-10-12 15:26:31 +02:00
const newDraft = _extends$d ( { } , oldDraft , { amount : parseFloat ( action . data . amount ) } ) ;
2019-04-03 19:12:51 +02:00
2020-10-12 15:26:31 +02:00
return _extends$d ( { } , 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-10-12 15:26:31 +02:00
const newDraft = _extends$d ( { } , oldDraft , { address : action . data . address } ) ;
2019-04-03 19:12:51 +02:00
2020-10-12 15:26:31 +02:00
return _extends$d ( { } , 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-10-12 15:26:31 +02:00
const newDraftTransaction = _extends$d ( { } , state . draftTransaction , { sending : true } ) ;
2019-04-03 19:12:51 +02:00
2020-10-12 15:26:31 +02:00
return _extends$d ( { } , 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-10-12 15:26:31 +02:00
return _extends$d ( { } , state , { draftTransaction : newDraftTransaction } ) ;
2019-05-10 07:02:03 +02:00
} ,
2019-04-03 19:12:51 +02:00
2020-10-12 15:26:31 +02:00
[ SUPPORT _TRANSACTION _STARTED ] : state => _extends$d ( { } , state , {
2019-05-10 07:02:03 +02:00
sendingSupport : true
} ) ,
2019-04-03 19:12:51 +02:00
2020-10-12 15:26:31 +02:00
[ SUPPORT _TRANSACTION _COMPLETED ] : state => _extends$d ( { } , state , {
2019-05-10 07:02:03 +02:00
sendingSupport : false
} ) ,
2019-04-03 19:12:51 +02:00
2020-10-12 15:26:31 +02:00
[ SUPPORT _TRANSACTION _FAILED ] : ( state , action ) => _extends$d ( { } , state , {
2019-05-10 07:02:03 +02:00
error : action . data . error ,
sendingSupport : false
} ) ,
2019-04-03 19:12:51 +02:00
2020-10-12 15:26:31 +02:00
[ CLEAR _SUPPORT _TRANSACTION ] : state => _extends$d ( { } , state , {
2019-10-30 08:55:15 +01:00
sendingSupport : false
} ) ,
2020-10-12 15:26:31 +02:00
[ WALLET _STATUS _COMPLETED ] : ( state , action ) => _extends$d ( { } , state , {
2019-05-10 07:02:03 +02:00
walletIsEncrypted : action . result
} ) ,
2019-04-03 19:12:51 +02:00
2020-10-12 15:26:31 +02:00
[ WALLET _ENCRYPT _START ] : state => _extends$d ( { } , state , {
2019-05-10 07:02:03 +02:00
walletEncryptPending : true ,
walletEncryptSucceded : null ,
walletEncryptResult : null
} ) ,
2019-04-03 19:12:51 +02:00
2020-10-12 15:26:31 +02:00
[ WALLET _ENCRYPT _COMPLETED ] : ( state , action ) => _extends$d ( { } , 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-10-12 15:26:31 +02:00
[ WALLET _ENCRYPT _FAILED ] : ( state , action ) => _extends$d ( { } , 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-10-12 15:26:31 +02:00
[ WALLET _DECRYPT _START ] : state => _extends$d ( { } , state , {
2019-05-10 07:02:03 +02:00
walletDecryptPending : true ,
walletDecryptSucceded : null ,
walletDecryptResult : null
} ) ,
2019-04-03 19:12:51 +02:00
2020-10-12 15:26:31 +02:00
[ WALLET _DECRYPT _COMPLETED ] : ( state , action ) => _extends$d ( { } , 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-10-12 15:26:31 +02:00
[ WALLET _DECRYPT _FAILED ] : ( state , action ) => _extends$d ( { } , 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-10-12 15:26:31 +02:00
[ WALLET _UNLOCK _START ] : state => _extends$d ( { } , state , {
2019-05-10 07:02:03 +02:00
walletUnlockPending : true ,
walletUnlockSucceded : null ,
walletUnlockResult : null
} ) ,
2019-04-03 19:12:51 +02:00
2020-10-12 15:26:31 +02:00
[ WALLET _UNLOCK _COMPLETED ] : ( state , action ) => _extends$d ( { } , state , {
2019-05-10 07:02:03 +02:00
walletUnlockPending : false ,
walletUnlockSucceded : true ,
walletUnlockResult : action . result
} ) ,
2020-10-12 15:26:31 +02:00
[ WALLET _UNLOCK _FAILED ] : ( state , action ) => _extends$d ( { } , state , {
2019-05-10 07:02:03 +02:00
walletUnlockPending : false ,
walletUnlockSucceded : false ,
walletUnlockResult : action . result
} ) ,
2020-10-12 15:26:31 +02:00
[ WALLET _LOCK _START ] : state => _extends$d ( { } , state , {
2019-05-10 07:02:03 +02:00
walletLockPending : false ,
walletLockSucceded : null ,
walletLockResult : null
} ) ,
2020-10-12 15:26:31 +02:00
[ WALLET _LOCK _COMPLETED ] : ( state , action ) => _extends$d ( { } , state , {
2019-05-10 07:02:03 +02:00
walletLockPending : false ,
walletLockSucceded : true ,
walletLockResult : action . result
} ) ,
2020-10-12 15:26:31 +02:00
[ WALLET _LOCK _FAILED ] : ( state , action ) => _extends$d ( { } , state , {
2019-05-10 07:02:03 +02:00
walletLockPending : false ,
walletLockSucceded : false ,
walletLockResult : action . result
} ) ,
2020-10-12 15:26:31 +02:00
[ SET _TRANSACTION _LIST _FILTER ] : ( state , action ) => _extends$d ( { } , state , {
2019-05-10 07:02:03 +02:00
transactionListFilter : action . data
} ) ,
2020-10-12 15:26:31 +02:00
[ UPDATE _CURRENT _HEIGHT ] : ( state , action ) => _extends$d ( { } , state , {
2019-05-10 07:02:03 +02:00
latestBlock : action . data
2019-12-18 17:47:18 +01:00
} ) ,
2020-10-12 15:26:31 +02:00
[ WALLET _RESTART ] : state => _extends$d ( { } , state , {
2019-12-18 17:47:18 +01:00
walletReconnecting : true
} ) ,
2020-10-12 15:26:31 +02:00
[ WALLET _RESTART _COMPLETED ] : state => _extends$d ( { } , state , {
2019-12-18 17:47:18 +01:00
walletReconnecting : false
2019-05-10 07:02:03 +02:00
} )
2020-10-12 15:26:31 +02:00
} , defaultState$5 ) ;
2019-06-10 04:45:47 +02:00
2021-05-07 00:41:02 +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 ; } ;
const getTimestamp$1 = ( ) => {
return Math . floor ( Date . now ( ) / 1000 ) ;
} ;
const defaultState$6 = {
builtin : {
watchlater : {
2021-05-26 17:36:17 +02:00
items : [ ] ,
2021-05-07 00:41:02 +02:00
id : WATCH _LATER _ID ,
name : 'Watch Later' ,
updatedAt : getTimestamp$1 ( ) ,
type : COL _TYPE _PLAYLIST
} ,
favorites : {
2021-05-26 17:36:17 +02:00
items : [ ] ,
2021-05-07 00:41:02 +02:00
id : FAVORITES _ID ,
name : 'Favorites' ,
type : COL _TYPE _PLAYLIST ,
updatedAt : getTimestamp$1 ( )
}
} ,
resolved : { } ,
unpublished : { } , // sync
edited : { } ,
pending : { } ,
saved : [ ] ,
isResolvingCollectionById : { } ,
error : null
} ;
const collectionsReducer = handleActions ( {
[ COLLECTION _NEW ] : ( state , action ) => {
const { entry : params } = action . data ; // { id:, items: Array<string>}
// entry
const newListTemplate = {
id : params . id ,
name : params . name ,
items : [ ] ,
updatedAt : getTimestamp$1 ( ) ,
type : params . type
} ;
const newList = Object . assign ( { } , newListTemplate , _extends$e ( { } , params ) ) ;
const { unpublished : lists } = state ;
const newLists = Object . assign ( { } , lists , { [ params . id ] : newList } ) ;
return _extends$e ( { } , state , {
unpublished : newLists
} ) ;
} ,
[ COLLECTION _DELETE ] : ( state , action ) => {
const { id , collectionKey } = action . data ;
const { edited : editList , unpublished : unpublishedList , pending : pendingList } = state ;
const newEditList = Object . assign ( { } , editList ) ;
const newUnpublishedList = Object . assign ( { } , unpublishedList ) ;
const newPendingList = Object . assign ( { } , pendingList ) ;
if ( collectionKey && state [ collectionKey ] && state [ collectionKey ] [ id ] ) {
const newList = Object . assign ( { } , state [ collectionKey ] ) ;
delete newList [ id ] ;
return _extends$e ( { } , state , {
[ collectionKey ] : newList
} ) ;
} else {
if ( newEditList [ id ] ) {
delete newEditList [ id ] ;
} else if ( newUnpublishedList [ id ] ) {
delete newUnpublishedList [ id ] ;
} else if ( newPendingList [ id ] ) {
delete newPendingList [ id ] ;
}
}
return _extends$e ( { } , state , {
edited : newEditList ,
unpublished : newUnpublishedList ,
pending : newPendingList
} ) ;
} ,
[ COLLECTION _PENDING ] : ( state , action ) => {
const { localId , claimId } = action . data ;
2021-08-03 21:28:26 +02:00
const {
resolved : resolvedList ,
edited : editList ,
unpublished : unpublishedList ,
pending : pendingList
} = state ;
2021-05-07 00:41:02 +02:00
const newEditList = Object . assign ( { } , editList ) ;
2021-08-03 21:28:26 +02:00
const newResolvedList = Object . assign ( { } , resolvedList ) ;
2021-05-07 00:41:02 +02:00
const newUnpublishedList = Object . assign ( { } , unpublishedList ) ;
const newPendingList = Object . assign ( { } , pendingList ) ;
if ( localId ) {
2021-05-26 17:36:17 +02:00
// new publish
newPendingList [ claimId ] = Object . assign ( { } , newUnpublishedList [ localId ] || { } ) ;
delete newUnpublishedList [ localId ] ;
2021-05-07 00:41:02 +02:00
} else {
2021-05-26 17:36:17 +02:00
// edit update
2021-08-03 21:28:26 +02:00
newPendingList [ claimId ] = Object . assign ( { } , newEditList [ claimId ] || newResolvedList [ claimId ] ) ;
2021-05-26 17:36:17 +02:00
delete newEditList [ claimId ] ;
2021-05-07 00:41:02 +02:00
}
return _extends$e ( { } , state , {
edited : newEditList ,
unpublished : newUnpublishedList ,
pending : newPendingList
} ) ;
} ,
[ COLLECTION _EDIT ] : ( state , action ) => {
const { id , collectionKey , collection } = action . data ;
if ( BUILTIN _LISTS . includes ( id ) ) {
const { builtin : lists } = state ;
return _extends$e ( { } , state , {
[ collectionKey ] : _extends$e ( { } , lists , { [ id ] : collection } )
} ) ;
}
if ( collectionKey === 'edited' ) {
const { edited : lists } = state ;
return _extends$e ( { } , state , {
edited : _extends$e ( { } , lists , { [ id ] : collection } )
} ) ;
}
const { unpublished : lists } = state ;
return _extends$e ( { } , state , {
unpublished : _extends$e ( { } , lists , { [ id ] : collection } )
} ) ;
} ,
[ COLLECTION _ERROR ] : ( state , action ) => {
return Object . assign ( { } , state , {
error : action . data . message
} ) ;
} ,
[ COLLECTION _ITEMS _RESOLVE _STARTED ] : ( state , action ) => {
const { ids } = action . data ;
const { isResolvingCollectionById } = state ;
const newResolving = Object . assign ( { } , isResolvingCollectionById ) ;
ids . forEach ( id => {
newResolving [ id ] = true ;
} ) ;
return Object . assign ( { } , state , _extends$e ( { } , state , {
error : '' ,
isResolvingCollectionById : newResolving
} ) ) ;
} ,
[ USER _STATE _POPULATE ] : ( state , action ) => {
2021-08-01 22:58:45 +02:00
const {
builtinCollections ,
savedCollections ,
unpublishedCollections ,
editedCollections
} = action . data ;
2021-05-07 00:41:02 +02:00
return _extends$e ( { } , state , {
2021-08-01 22:58:45 +02:00
edited : editedCollections || state . edited ,
2021-06-01 14:12:02 +02:00
unpublished : unpublishedCollections || state . unpublished ,
builtin : builtinCollections || state . builtin ,
saved : savedCollections || state . saved
2021-05-07 00:41:02 +02:00
} ) ;
} ,
[ COLLECTION _ITEMS _RESOLVE _COMPLETED ] : ( state , action ) => {
const { resolvedCollections , failedCollectionIds } = action . data ;
const { pending , edited , isResolvingCollectionById , resolved } = state ;
const newPending = Object . assign ( { } , pending ) ;
const newEdited = Object . assign ( { } , edited ) ;
const newResolved = Object . assign ( { } , resolved , resolvedCollections ) ;
const resolvedIds = Object . keys ( resolvedCollections ) ;
const newResolving = Object . assign ( { } , isResolvingCollectionById ) ;
if ( resolvedCollections && Object . keys ( resolvedCollections ) . length ) {
resolvedIds . forEach ( resolvedId => {
if ( newEdited [ resolvedId ] ) {
if ( newEdited [ resolvedId ] [ 'updatedAt' ] < resolvedCollections [ resolvedId ] [ 'updatedAt' ] ) {
delete newEdited [ resolvedId ] ;
}
}
delete newResolving [ resolvedId ] ;
if ( newPending [ resolvedId ] ) {
delete newPending [ resolvedId ] ;
}
} ) ;
}
if ( failedCollectionIds && Object . keys ( failedCollectionIds ) . length ) {
failedCollectionIds . forEach ( failedId => {
delete newResolving [ failedId ] ;
} ) ;
}
return Object . assign ( { } , state , _extends$e ( { } , state , {
pending : newPending ,
resolved : newResolved ,
edited : newEdited ,
isResolvingCollectionById : newResolving
} ) ) ;
} ,
[ COLLECTION _ITEMS _RESOLVE _FAILED ] : ( state , action ) => {
const { ids } = action . data ;
const { isResolvingCollectionById } = state ;
const newResolving = Object . assign ( { } , isResolvingCollectionById ) ;
ids . forEach ( id => {
delete newResolving [ id ] ;
} ) ;
return Object . assign ( { } , state , _extends$e ( { } , state , {
isResolvingCollectionById : newResolving ,
error : action . data . message
} ) ) ;
}
} , defaultState$6 ) ;
2020-01-21 06:46:14 +01:00
//
2020-01-13 23:00:04 +01:00
2021-05-07 00:41:02 +02:00
const selectState$5 = state => state . content || { } ;
2019-04-03 19:12:51 +02:00
2021-05-07 00:41:02 +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 ;
} ) ;
2021-05-07 00:41:02 +02:00
var _extends$f = Object . assign || function ( target ) { for ( var i = 1 ; i < arguments . length ; i ++ ) { var source = arguments [ i ] ; for ( var key in source ) { if ( Object . prototype . hasOwnProperty . call ( source , key ) ) { target [ key ] = source [ key ] ; } } } return target ; } ;
2019-04-03 19:12:51 +02:00
2021-05-07 00:41:02 +02:00
const selectState$6 = state => state . notifications || { } ;
2019-04-03 19:12:51 +02:00
2021-05-07 00:41:02 +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 ] ;
2021-05-07 00:41:02 +02:00
return _extends$f ( {
2019-04-03 19:12:51 +02:00
id
} , params ) ;
}
return null ;
} ) ;
2021-05-07 00:41:02 +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 ;
} ) ;
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 ;
2021-05-07 00:41:02 +02:00
exports . COLLECTIONS _CONSTS = collections ;
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-03-10 03:10:30 +01: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 . 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 ;
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 ;
2021-05-07 00:41:02 +02:00
exports . collectionsReducer = collectionsReducer ;
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-04-03 19:12:51 +02:00
exports . doBalanceSubscribe = doBalanceSubscribe ;
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 ;
2020-07-03 00:03:55 +02:00
exports . doClearChannelErrors = doClearChannelErrors ;
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 ;
2021-05-12 21:11:04 +02:00
exports . doCollectionDelete = doCollectionDelete ;
2021-05-07 00:41:02 +02:00
exports . doCollectionEdit = doCollectionEdit ;
exports . doCollectionPublish = doCollectionPublish ;
exports . doCollectionPublishUpdate = doCollectionPublishUpdate ;
2019-04-23 19:22:14 +02:00
exports . doCreateChannel = doCreateChannel ;
2019-04-03 19:12:51 +02:00
exports . doDismissError = doDismissError ;
exports . doDismissToast = doDismissToast ;
exports . doError = doError ;
2019-04-23 19:22:14 +02:00
exports . doFetchChannelListMine = doFetchChannelListMine ;
2019-04-03 19:12:51 +02:00
exports . doFetchClaimListMine = doFetchClaimListMine ;
exports . doFetchClaimsByChannel = doFetchClaimsByChannel ;
2021-05-07 00:41:02 +02:00
exports . doFetchCollectionListMine = doFetchCollectionListMine ;
2019-04-03 19:12:51 +02:00
exports . doFetchFileInfo = doFetchFileInfo ;
2020-04-25 22:31:53 +02:00
exports . doFetchFileInfos = doFetchFileInfos ;
2021-05-07 00:41:02 +02:00
exports . doFetchItemsInCollection = doFetchItemsInCollection ;
exports . doFetchItemsInCollections = doFetchItemsInCollections ;
2019-04-03 19:12:51 +02:00
exports . doFetchTransactions = doFetchTransactions ;
2020-04-10 14:16:27 +02:00
exports . doFetchTxoPage = doFetchTxoPage ;
2020-12-30 23:25:57 +01:00
exports . doFetchUtxoCounts = doFetchUtxoCounts ;
2019-05-21 21:18:07 +02:00
exports . doFileGet = doFileGet ;
2019-04-03 19:12:51 +02:00
exports . doFileList = doFileList ;
exports . doGetNewAddress = doGetNewAddress ;
2019-09-12 21:06:49 +02:00
exports . doImportChannel = doImportChannel ;
2021-05-07 00:41:02 +02:00
exports . doLocalCollectionCreate = doLocalCollectionCreate ;
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 ;
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 ;
2021-01-27 16:01:55 +01:00
exports . doTipClaimMass = doTipClaimMass ;
2019-04-03 19:12:51 +02:00
exports . doToast = doToast ;
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 ;
2020-04-10 14:16:27 +02:00
exports . doUpdateTxoPageParams = doUpdateTxoPageParams ;
2019-07-01 21:49:51 +02:00
exports . doUploadThumbnail = doUploadThumbnail ;
2020-12-30 23:25:57 +01:00
exports . doUtxoConsolidate = doUtxoConsolidate ;
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 ;
2021-07-15 21:46:31 +02:00
exports . isURIEqual = isURIEqual ;
2019-04-03 19:12:51 +02:00
exports . isURIValid = isURIValid ;
2020-07-24 16:40:29 +02:00
exports . makeSelectAbandoningClaimById = makeSelectAbandoningClaimById ;
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 ;
2020-10-14 20:07:00 +02:00
exports . makeSelectChannelPermUrlForClaimUri = makeSelectChannelPermUrlForClaimUri ;
2021-03-05 19:32:27 +01:00
exports . makeSelectClaimForClaimId = makeSelectClaimForClaimId ;
2019-04-03 19:12:51 +02:00
exports . makeSelectClaimForUri = makeSelectClaimForUri ;
2021-03-17 19:39:18 +01:00
exports . makeSelectClaimHasSource = makeSelectClaimHasSource ;
2021-05-07 00:41:02 +02:00
exports . makeSelectClaimIdForUri = makeSelectClaimIdForUri ;
2021-06-23 16:43:17 +02:00
exports . makeSelectClaimIdIsPending = makeSelectClaimIdIsPending ;
2021-05-07 00:41:02 +02:00
exports . makeSelectClaimIdsForCollectionId = makeSelectClaimIdsForCollectionId ;
2019-04-03 19:12:51 +02:00
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 ;
2021-03-25 23:49:48 +01:00
exports . makeSelectClaimIsStreamPlaceholder = makeSelectClaimIsStreamPlaceholder ;
2021-07-05 18:02:06 +02:00
exports . makeSelectClaimUrlInCollection = makeSelectClaimUrlInCollection ;
2020-05-08 22:47:33 +02:00
exports . makeSelectClaimWasPurchased = makeSelectClaimWasPurchased ;
2019-04-03 19:12:51 +02:00
exports . makeSelectClaimsInChannelForPage = makeSelectClaimsInChannelForPage ;
2021-05-07 00:41:02 +02:00
exports . makeSelectCollectionForId = makeSelectCollectionForId ;
exports . makeSelectCollectionForIdHasClaimUrl = makeSelectCollectionForIdHasClaimUrl ;
exports . makeSelectCollectionIsMine = makeSelectCollectionIsMine ;
2019-04-03 19:12:51 +02:00
exports . makeSelectContentPositionForUri = makeSelectContentPositionForUri ;
exports . makeSelectContentTypeForUri = makeSelectContentTypeForUri ;
2021-05-12 21:11:04 +02:00
exports . makeSelectCountForCollectionId = makeSelectCountForCollectionId ;
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 ;
2021-05-07 00:41:02 +02:00
exports . makeSelectEditedCollectionForId = makeSelectEditedCollectionForId ;
2020-12-11 05:03:32 +01:00
exports . makeSelectEffectiveAmountForUri = makeSelectEffectiveAmountForUri ;
2019-04-03 19:12:51 +02:00
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 ;
2021-06-07 22:21:31 +02:00
exports . makeSelectIndexForUrlInCollection = makeSelectIndexForUrlInCollection ;
2020-07-24 16:40:29 +02:00
exports . makeSelectIsAbandoningClaimForUri = makeSelectIsAbandoningClaimForUri ;
2021-05-07 00:41:02 +02:00
exports . makeSelectIsResolvingCollectionForId = makeSelectIsResolvingCollectionForId ;
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-10-14 20:07:00 +02:00
exports . makeSelectMyChannelPermUrlForName = makeSelectMyChannelPermUrlForName ;
2021-05-07 00:41:02 +02:00
exports . makeSelectMyPublishedCollectionForId = makeSelectMyPublishedCollectionForId ;
2020-05-08 22:47:33 +02:00
exports . makeSelectMyPurchasesForPage = makeSelectMyPurchasesForPage ;
2019-09-25 23:37:21 +02:00
exports . makeSelectMyStreamUrlsForPage = makeSelectMyStreamUrlsForPage ;
2021-05-07 00:41:02 +02:00
exports . makeSelectNameForCollectionId = makeSelectNameForCollectionId ;
2021-06-07 22:21:31 +02:00
exports . makeSelectNextUrlForCollectionAndUrl = makeSelectNextUrlForCollectionAndUrl ;
2019-04-03 19:12:51 +02:00
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 ;
2020-12-14 01:17:16 +01:00
exports . makeSelectPendingClaimForUri = makeSelectPendingClaimForUri ;
2021-05-07 00:41:02 +02:00
exports . makeSelectPendingCollectionForId = makeSelectPendingCollectionForId ;
2019-09-04 17:57:48 +02:00
exports . makeSelectPermanentUrlForUri = makeSelectPermanentUrlForUri ;
2021-08-25 14:01:50 +02:00
exports . makeSelectPreviousUrlForCollectionAndUrl = makeSelectPreviousUrlForCollectionAndUrl ;
2019-07-05 04:20:56 +02:00
exports . makeSelectPublishFormValue = makeSelectPublishFormValue ;
2021-05-07 00:41:02 +02:00
exports . makeSelectPublishedCollectionForId = makeSelectPublishedCollectionForId ;
2020-05-07 13:41:56 +02:00
exports . makeSelectReflectingClaimForUri = makeSelectReflectingClaimForUri ;
2019-10-03 23:14:35 +02:00
exports . makeSelectSearchDownloadUrlsCount = makeSelectSearchDownloadUrlsCount ;
exports . makeSelectSearchDownloadUrlsForPage = makeSelectSearchDownloadUrlsForPage ;
2019-07-08 20:28:14 +02:00
exports . makeSelectShortUrlForUri = makeSelectShortUrlForUri ;
2021-03-09 07:23:25 +01:00
exports . makeSelectStakedLevelForChannelUri = makeSelectStakedLevelForChannelUri ;
2019-05-21 21:18:07 +02:00
exports . makeSelectStreamingUrlForUri = makeSelectStreamingUrlForUri ;
2019-08-15 08:13:50 +02:00
exports . makeSelectSupportsForUri = makeSelectSupportsForUri ;
2020-10-27 20:42:53 +01:00
exports . makeSelectTagInClaimOrChannelForUri = makeSelectTagInClaimOrChannelForUri ;
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 ;
2021-03-09 07:23:25 +01:00
exports . makeSelectTotalStakedAmountForChannelUri = makeSelectTotalStakedAmountForChannelUri ;
2021-05-07 00:41:02 +02:00
exports . makeSelectUnpublishedCollectionForId = makeSelectUnpublishedCollectionForId ;
2019-08-02 08:21:28 +02:00
exports . makeSelectUriIsStreamable = makeSelectUriIsStreamable ;
2021-05-07 00:41:02 +02:00
exports . makeSelectUrlsForCollectionId = makeSelectUrlsForCollectionId ;
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 ;
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 ;
exports . selectBlocks = selectBlocks ;
2021-05-07 00:41:02 +02:00
exports . selectBuiltinCollections = selectBuiltinCollections ;
2019-04-03 19:12:51 +02:00
exports . selectChannelClaimCounts = selectChannelClaimCounts ;
2019-09-12 21:06:49 +02:00
exports . selectChannelImportPending = selectChannelImportPending ;
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 ;
2021-05-07 00:41:02 +02:00
exports . selectCreateCollectionError = selectCreateCollectionError ;
2019-08-27 06:42:52 +02:00
exports . selectCreatingChannel = selectCreatingChannel ;
2021-05-07 00:41:02 +02:00
exports . selectCreatingCollection = selectCreatingCollection ;
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 ;
2021-05-07 00:41:02 +02:00
exports . selectFetchingMyCollections = selectFetchingMyCollections ;
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-04-03 19:12:51 +02:00
exports . selectGettingNewAddress = selectGettingNewAddress ;
exports . selectHasTransactions = selectHasTransactions ;
2020-12-30 23:25:57 +01:00
exports . selectIsConsolidatingUtxos = selectIsConsolidatingUtxos ;
2019-04-03 19:12:51 +02:00
exports . selectIsFetchingClaimListMine = selectIsFetchingClaimListMine ;
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 ;
2020-12-30 23:25:57 +01:00
exports . selectIsFetchingUtxoCounts = selectIsFetchingUtxoCounts ;
2021-01-27 16:01:55 +01:00
exports . selectIsMassClaimingTips = selectIsMassClaimingTips ;
2019-07-01 21:49:51 +02:00
exports . selectIsResolvingPublishUris = selectIsResolvingPublishUris ;
2019-04-03 19:12:51 +02:00
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 ;
2021-05-07 00:41:02 +02:00
exports . selectMyCollectionIds = selectMyCollectionIds ;
exports . selectMyEditedCollections = selectMyEditedCollections ;
exports . selectMyPublishedCollections = selectMyPublishedCollections ;
exports . selectMyPublishedMixedCollections = selectMyPublishedMixedCollections ;
exports . selectMyPublishedPlaylistCollections = selectMyPublishedPlaylistCollections ;
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 ;
2021-05-07 00:41:02 +02:00
exports . selectMyUnpublishedCollections = selectMyUnpublishedCollections ;
2021-03-24 00:55:16 +01:00
exports . selectPendingClaims = selectPendingClaims ;
2021-02-03 23:52:01 +01:00
exports . selectPendingConsolidateTxid = selectPendingConsolidateTxid ;
2020-12-04 01:25:41 +01:00
exports . selectPendingIds = selectPendingIds ;
2021-02-03 23:52:01 +01:00
exports . selectPendingMassClaimTxid = selectPendingMassClaimTxid ;
2020-12-30 23:25:57 +01:00
exports . selectPendingOtherTransactions = selectPendingOtherTransactions ;
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 ;
2021-05-07 00:41:02 +02:00
exports . selectResolvedCollections = selectResolvedCollections ;
2019-04-03 19:12:51 +02:00
exports . selectResolvingUris = selectResolvingUris ;
2021-05-07 00:41:02 +02:00
exports . selectSavedCollectionIds = selectSavedCollectionIds ;
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 ;
2021-04-17 14:50:03 +02:00
exports . selectTransactionsFile = selectTransactionsFile ;
2020-04-10 14:16:27 +02:00
exports . selectTxoItemCount = selectTxoItemCount ;
exports . selectTxoPage = selectTxoPage ;
exports . selectTxoPageNumber = selectTxoPageNumber ;
exports . selectTxoPageParams = selectTxoPageParams ;
2019-09-15 13:00:14 +02:00
exports . selectUpdateChannelError = selectUpdateChannelError ;
2021-05-07 00:41:02 +02:00
exports . selectUpdateCollectionError = selectUpdateCollectionError ;
2019-09-15 13:00:14 +02:00
exports . selectUpdatingChannel = selectUpdatingChannel ;
2021-05-07 00:41:02 +02:00
exports . selectUpdatingCollection = selectUpdatingCollection ;
2019-04-03 19:12:51 +02:00
exports . selectUrisLoading = selectUrisLoading ;
2020-12-30 23:25:57 +01:00
exports . selectUtxoCounts = selectUtxoCounts ;
2019-04-03 19:12:51 +02:00
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 ;
2021-07-15 21:46:31 +02:00
exports . splitBySeparator = splitBySeparator ;
2019-04-03 19:12:51 +02:00
exports . toQueryString = toQueryString ;
exports . walletReducer = walletReducer ;