add action, reducer and selector for saving media position (#120)

This commit is contained in:
Akinwale Ariwodola 2019-03-20 14:54:36 +01:00 committed by GitHub
parent d37d1e7bf5
commit 0d4079f370
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 214 additions and 26 deletions

185
dist/bundle.js vendored
View file

@ -89,8 +89,8 @@ return /******/ (function(modules) { // webpackBootstrap
Object.defineProperty(exports, "__esModule", { Object.defineProperty(exports, "__esModule", {
value: true value: true
}); });
exports.selectTransactionListFilter = exports.selectWalletUnlockResult = exports.selectWalletUnlockSucceeded = exports.selectWalletUnlockPending = exports.selectWalletDecryptResult = exports.selectWalletDecryptSucceeded = exports.selectWalletDecryptPending = exports.selectWalletEncryptResult = exports.selectWalletEncryptSucceeded = exports.selectWalletEncryptPending = exports.selectWalletState = exports.selectWalletIsEncrypted = exports.selectBlocks = exports.selectDraftTransactionError = exports.selectDraftTransactionAddress = exports.selectDraftTransactionAmount = exports.selectDraftTransaction = exports.selectGettingNewAddress = exports.selectReceiveAddress = exports.selectIsSendingSupport = exports.selectIsFetchingTransactions = exports.selectHasTransactions = exports.selectRecentTransactions = exports.selectTransactionItems = exports.selectTransactionsById = exports.selectBalance = exports.makeSelectBlockDate = exports.makeSelectQueryWithOptions = exports.selectSearchSuggestions = exports.selectSearchBarFocused = exports.selectWunderBarAddress = exports.selectSearchUrisByQuery = exports.selectIsSearching = exports.selectSearchOptions = exports.selectSearchValue = exports.selectSearchQuery = exports.makeSelectSearchUris = exports.selectSearchState = exports.selectActiveHistoryEntry = exports.selectHistoryStack = exports.selectHistoryIndex = exports.selectIsForwardDisabled = exports.selectIsBackDisabled = exports.selectPathAfterAuth = exports.selectPageTitle = exports.selectHeaderLinks = exports.selectCurrentParams = exports.selectCurrentPage = exports.selectCurrentPath = exports.makeSelectCurrentParam = exports.computePageFromPath = exports.selectFileListPublishedSort = exports.selectFileListDownloadedSort = exports.selectSearchDownloadUris = exports.selectTotalDownloadProgress = exports.selectDownloadingFileInfos = exports.selectFileInfosDownloaded = exports.selectUrisLoading = exports.selectDownloadingByOutpoint = exports.selectIsFetchingFileListDownloadedOrPublished = exports.selectIsFetchingFileList = exports.selectFileInfosByOutpoint = exports.makeSelectLoadingForUri = exports.makeSelectDownloadingForUri = exports.makeSelectFileInfoForUri = exports.selectCurrentChannelPage = exports.selectChannelClaimCounts = exports.selectPlayingUri = exports.selectFetchingTrendingUris = exports.selectTrendingUris = exports.selectFetchingFeaturedUris = exports.selectFeaturedUris = exports.selectResolvingUris = exports.selectMyChannelClaims = exports.selectFetchingMyChannels = exports.selectMyClaimsOutpoints = undefined; exports.selectTransactionListFilter = exports.selectWalletUnlockResult = exports.selectWalletUnlockSucceeded = exports.selectWalletUnlockPending = exports.selectWalletDecryptResult = exports.selectWalletDecryptSucceeded = exports.selectWalletDecryptPending = exports.selectWalletEncryptResult = exports.selectWalletEncryptSucceeded = exports.selectWalletEncryptPending = exports.selectWalletState = exports.selectWalletIsEncrypted = exports.selectBlocks = exports.selectDraftTransactionError = exports.selectDraftTransactionAddress = exports.selectDraftTransactionAmount = exports.selectDraftTransaction = exports.selectGettingNewAddress = exports.selectReceiveAddress = exports.selectIsSendingSupport = exports.selectIsFetchingTransactions = exports.selectHasTransactions = exports.selectRecentTransactions = exports.selectTransactionItems = exports.selectTransactionsById = exports.selectBalance = exports.makeSelectBlockDate = exports.makeSelectQueryWithOptions = exports.selectSearchSuggestions = exports.selectSearchBarFocused = exports.selectWunderBarAddress = exports.selectSearchUrisByQuery = exports.selectIsSearching = exports.selectSearchOptions = exports.selectSearchValue = exports.selectSearchQuery = exports.makeSelectSearchUris = exports.selectSearchState = exports.selectActiveHistoryEntry = exports.selectHistoryStack = exports.selectHistoryIndex = exports.selectIsForwardDisabled = exports.selectIsBackDisabled = exports.selectPathAfterAuth = exports.selectPageTitle = exports.selectHeaderLinks = exports.selectCurrentParams = exports.selectCurrentPage = exports.selectCurrentPath = exports.makeSelectCurrentParam = exports.computePageFromPath = exports.selectFileListPublishedSort = exports.selectFileListDownloadedSort = exports.selectSearchDownloadUris = exports.selectTotalDownloadProgress = exports.selectDownloadingFileInfos = exports.selectFileInfosDownloaded = exports.selectUrisLoading = exports.selectDownloadingByOutpoint = exports.selectIsFetchingFileListDownloadedOrPublished = exports.selectIsFetchingFileList = exports.selectFileInfosByOutpoint = exports.makeSelectLoadingForUri = exports.makeSelectDownloadingForUri = exports.makeSelectFileInfoForUri = exports.selectCurrentChannelPage = exports.selectChannelClaimCounts = exports.selectPlayingUri = exports.selectFetchingTrendingUris = exports.selectTrendingUris = exports.selectFetchingFeaturedUris = exports.selectFeaturedUris = exports.selectResolvingUris = exports.selectMyChannelClaims = exports.selectFetchingMyChannels = exports.selectMyClaimsOutpoints = exports.selectAllMyClaimsByOutpoint = exports.selectMyClaimsWithoutChannels = exports.selectMyClaims = undefined;
exports.selectAllMyClaimsByOutpoint = exports.selectMyClaimsWithoutChannels = exports.selectMyClaims = exports.selectPendingClaims = exports.selectIsFetchingClaimListMine = exports.selectAllFetchingChannelClaims = exports.selectMyActiveClaims = exports.selectAbandoningIds = exports.selectMyClaimsRaw = exports.selectAllClaimsByChannel = exports.selectClaimsByUri = exports.selectClaimsById = exports.selectPendingById = exports.makeSelectClaimsInChannelForCurrentPageState = exports.makeSelectPendingByUri = exports.makeSelectClaimIsPending = exports.makeSelectChannelForClaimUri = exports.makeSelectFirstRecommendedFileForUri = exports.makeSelectRecommendedContentForUri = exports.makeSelectNsfwCountForChannel = exports.makeSelectNsfwCountFromUris = exports.makeSelectTotalPagesForChannel = exports.makeSelectTotalItemsForChannel = exports.makeSelectIsUriResolving = exports.makeSelectContentTypeForUri = exports.makeSelectTitleForUri = exports.makeSelectMetadataForUri = exports.makeSelectClaimsInChannelForPage = exports.makeSelectClaimsInChannelForCurrentPage = exports.makeSelectFetchingChannelClaims = exports.makeSelectClaimIsMine = exports.makeSelectClaimForUri = exports.selectError = exports.selectToast = exports.walletReducer = exports.searchReducer = exports.notificationsReducer = exports.fileInfoReducer = exports.claimsReducer = exports.creditsToString = exports.formatFullPrice = exports.formatCredits = exports.toQueryString = exports.parseQueryParams = exports.batchActions = exports.doUpdateBlockHeight = exports.doSetTransactionListFilter = exports.doWalletStatus = exports.doWalletUnlock = exports.doWalletDecrypt = exports.doWalletEncrypt = exports.doSendTip = exports.doSetDraftTransactionAddress = exports.doSetDraftTransactionAmount = exports.doSendDraftTransaction = exports.doCheckAddressIsMine = exports.doGetNewAddress = exports.doFetchBlock = exports.doFetchTransactions = exports.doBalanceSubscribe = exports.doUpdateBalance = exports.doUpdateSearchOptions = exports.setSearchApi = exports.doBlurSearchInput = exports.doFocusSearchInput = exports.doUpdateSearchQuery = exports.doSearch = exports.doSetFileListSort = exports.doFetchFileInfosAndPublishedClaims = exports.doFileList = exports.doFetchFileInfo = exports.doResolveUri = exports.doResolveUris = exports.doAbandonClaim = exports.doFetchClaimListMine = exports.doFetchClaimCountByChannel = exports.doFetchClaimsByChannel = exports.doDismissError = exports.doError = exports.doDismissToast = exports.doToast = exports.convertToShareLink = exports.isNameValid = exports.isURIClaimable = exports.isURIValid = exports.normalizeURI = exports.buildURI = exports.parseURI = exports.regexAddress = exports.regexInvalidURI = exports.Lbry = exports.PAGES = exports.SORT_OPTIONS = exports.TRANSACTIONS = exports.SETTINGS = exports.SEARCH_OPTIONS = exports.SEARCH_TYPES = exports.THUMBNAIL_STATUSES = exports.ACTIONS = exports.Toast = undefined; exports.selectPendingClaims = exports.selectIsFetchingClaimListMine = exports.selectAllFetchingChannelClaims = exports.selectMyActiveClaims = exports.selectAbandoningIds = exports.selectMyClaimsRaw = exports.selectAllClaimsByChannel = exports.selectClaimsByUri = exports.selectClaimsById = exports.selectPendingById = exports.makeSelectClaimsInChannelForCurrentPageState = exports.makeSelectPendingByUri = exports.makeSelectClaimIsPending = exports.makeSelectChannelForClaimUri = exports.makeSelectFirstRecommendedFileForUri = exports.makeSelectRecommendedContentForUri = exports.makeSelectNsfwCountForChannel = exports.makeSelectNsfwCountFromUris = exports.makeSelectTotalPagesForChannel = exports.makeSelectTotalItemsForChannel = exports.makeSelectIsUriResolving = exports.makeSelectContentTypeForUri = exports.makeSelectTitleForUri = exports.makeSelectMetadataForUri = exports.makeSelectClaimsInChannelForPage = exports.makeSelectClaimsInChannelForCurrentPage = exports.makeSelectFetchingChannelClaims = exports.makeSelectClaimIsMine = exports.makeSelectClaimForUri = exports.selectError = exports.selectToast = exports.makeSelectContentPositionForUri = exports.contentReducer = exports.walletReducer = exports.searchReducer = exports.notificationsReducer = exports.fileInfoReducer = exports.claimsReducer = exports.creditsToString = exports.formatFullPrice = exports.formatCredits = exports.toQueryString = exports.parseQueryParams = exports.batchActions = exports.doUpdateBlockHeight = exports.doSetTransactionListFilter = exports.doWalletStatus = exports.doWalletUnlock = exports.doWalletDecrypt = exports.doWalletEncrypt = exports.doSendTip = exports.doSetDraftTransactionAddress = exports.doSetDraftTransactionAmount = exports.doSendDraftTransaction = exports.doCheckAddressIsMine = exports.doGetNewAddress = exports.doFetchBlock = exports.doFetchTransactions = exports.doBalanceSubscribe = exports.doUpdateBalance = exports.savePosition = exports.doUpdateSearchOptions = exports.setSearchApi = exports.doBlurSearchInput = exports.doFocusSearchInput = exports.doUpdateSearchQuery = exports.doSearch = exports.doSetFileListSort = exports.doFetchFileInfosAndPublishedClaims = exports.doFileList = exports.doFetchFileInfo = exports.doResolveUri = exports.doResolveUris = exports.doAbandonClaim = exports.doFetchClaimListMine = exports.doFetchClaimCountByChannel = exports.doFetchClaimsByChannel = exports.doDismissError = exports.doError = exports.doDismissToast = exports.doToast = exports.convertToShareLink = exports.isNameValid = exports.isURIClaimable = exports.isURIValid = exports.normalizeURI = exports.buildURI = exports.parseURI = exports.regexAddress = exports.regexInvalidURI = exports.Lbry = exports.PAGES = exports.SORT_OPTIONS = exports.TRANSACTIONS = exports.SETTINGS = exports.SEARCH_OPTIONS = exports.SEARCH_TYPES = exports.THUMBNAIL_STATUSES = exports.ACTIONS = exports.Toast = undefined;
var _Notification = __webpack_require__(1); var _Notification = __webpack_require__(1);
@ -290,6 +290,15 @@ Object.defineProperty(exports, 'doUpdateSearchOptions', {
} }
}); });
var _content = __webpack_require__(29);
Object.defineProperty(exports, 'savePosition', {
enumerable: true,
get: function get() {
return _content.savePosition;
}
});
var _wallet = __webpack_require__(19); var _wallet = __webpack_require__(19);
Object.defineProperty(exports, 'doUpdateBalance', { Object.defineProperty(exports, 'doUpdateBalance', {
@ -434,7 +443,7 @@ Object.defineProperty(exports, 'creditsToString', {
} }
}); });
var _claims2 = __webpack_require__(29); var _claims2 = __webpack_require__(30);
Object.defineProperty(exports, 'claimsReducer', { Object.defineProperty(exports, 'claimsReducer', {
enumerable: true, enumerable: true,
@ -443,7 +452,7 @@ Object.defineProperty(exports, 'claimsReducer', {
} }
}); });
var _file_info2 = __webpack_require__(30); var _file_info2 = __webpack_require__(31);
Object.defineProperty(exports, 'fileInfoReducer', { Object.defineProperty(exports, 'fileInfoReducer', {
enumerable: true, enumerable: true,
@ -452,7 +461,7 @@ Object.defineProperty(exports, 'fileInfoReducer', {
} }
}); });
var _notifications2 = __webpack_require__(33); var _notifications2 = __webpack_require__(34);
Object.defineProperty(exports, 'notificationsReducer', { Object.defineProperty(exports, 'notificationsReducer', {
enumerable: true, enumerable: true,
@ -461,7 +470,7 @@ Object.defineProperty(exports, 'notificationsReducer', {
} }
}); });
var _search2 = __webpack_require__(35); var _search2 = __webpack_require__(36);
Object.defineProperty(exports, 'searchReducer', { Object.defineProperty(exports, 'searchReducer', {
enumerable: true, enumerable: true,
@ -470,7 +479,7 @@ Object.defineProperty(exports, 'searchReducer', {
} }
}); });
var _wallet2 = __webpack_require__(36); var _wallet2 = __webpack_require__(37);
Object.defineProperty(exports, 'walletReducer', { Object.defineProperty(exports, 'walletReducer', {
enumerable: true, enumerable: true,
@ -479,7 +488,25 @@ Object.defineProperty(exports, 'walletReducer', {
} }
}); });
var _notifications3 = __webpack_require__(37); var _content2 = __webpack_require__(38);
Object.defineProperty(exports, 'contentReducer', {
enumerable: true,
get: function get() {
return _content2.contentReducer;
}
});
var _content3 = __webpack_require__(39);
Object.defineProperty(exports, 'makeSelectContentPositionForUri', {
enumerable: true,
get: function get() {
return _content3.makeSelectContentPositionForUri;
}
});
var _notifications3 = __webpack_require__(40);
Object.defineProperty(exports, 'selectToast', { Object.defineProperty(exports, 'selectToast', {
enumerable: true, enumerable: true,
@ -1155,11 +1182,11 @@ var _action_types = __webpack_require__(2);
var ACTIONS = _interopRequireWildcard(_action_types); var ACTIONS = _interopRequireWildcard(_action_types);
var _thumbnail_upload_statuses = __webpack_require__(38); var _thumbnail_upload_statuses = __webpack_require__(41);
var THUMBNAIL_STATUSES = _interopRequireWildcard(_thumbnail_upload_statuses); var THUMBNAIL_STATUSES = _interopRequireWildcard(_thumbnail_upload_statuses);
var _settings = __webpack_require__(39); var _settings = __webpack_require__(42);
var SETTINGS = _interopRequireWildcard(_settings); var SETTINGS = _interopRequireWildcard(_settings);
@ -1167,11 +1194,11 @@ var _transaction_types = __webpack_require__(21);
var TRANSACTIONS = _interopRequireWildcard(_transaction_types); var TRANSACTIONS = _interopRequireWildcard(_transaction_types);
var _sort_options = __webpack_require__(31); var _sort_options = __webpack_require__(32);
var SORT_OPTIONS = _interopRequireWildcard(_sort_options); var SORT_OPTIONS = _interopRequireWildcard(_sort_options);
var _pages = __webpack_require__(32); var _pages = __webpack_require__(33);
var PAGES = _interopRequireWildcard(_pages); var PAGES = _interopRequireWildcard(_pages);
@ -4812,6 +4839,33 @@ function handleFetchResponse(response) {
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.savePosition = savePosition;
var _action_types = __webpack_require__(2);
var ACTIONS = _interopRequireWildcard(_action_types);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function savePosition(claimId /*: string*/, outpoint /*: string*/, position /*: number*/) {
return function (dispatch) {
dispatch({
type: ACTIONS.SET_CONTENT_POSITION,
data: { claimId: claimId, outpoint: outpoint, position: position }
});
};
}
/***/ }),
/* 30 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { Object.defineProperty(exports, "__esModule", {
value: true value: true
}); });
@ -5095,7 +5149,7 @@ function claimsReducer() {
} }
/***/ }), /***/ }),
/* 30 */ /* 31 */
/***/ (function(module, exports, __webpack_require__) { /***/ (function(module, exports, __webpack_require__) {
"use strict"; "use strict";
@ -5113,11 +5167,11 @@ var _action_types = __webpack_require__(2);
var ACTIONS = _interopRequireWildcard(_action_types); var ACTIONS = _interopRequireWildcard(_action_types);
var _sort_options = __webpack_require__(31); var _sort_options = __webpack_require__(32);
var SORT_OPTIONS = _interopRequireWildcard(_sort_options); var SORT_OPTIONS = _interopRequireWildcard(_sort_options);
var _pages = __webpack_require__(32); var _pages = __webpack_require__(33);
var PAGES = _interopRequireWildcard(_pages); var PAGES = _interopRequireWildcard(_pages);
@ -5337,7 +5391,7 @@ function fileInfoReducer() {
} }
/***/ }), /***/ }),
/* 31 */ /* 32 */
/***/ (function(module, exports, __webpack_require__) { /***/ (function(module, exports, __webpack_require__) {
"use strict"; "use strict";
@ -5352,7 +5406,7 @@ var TITLE = exports.TITLE = 'title';
var FILENAME = exports.FILENAME = 'filename'; var FILENAME = exports.FILENAME = 'filename';
/***/ }), /***/ }),
/* 32 */ /* 33 */
/***/ (function(module, exports, __webpack_require__) { /***/ (function(module, exports, __webpack_require__) {
"use strict"; "use strict";
@ -5384,7 +5438,7 @@ var HISTORY = exports.HISTORY = 'user_history';
var WALLET = exports.WALLET = 'wallet'; var WALLET = exports.WALLET = 'wallet';
/***/ }), /***/ }),
/* 33 */ /* 34 */
/***/ (function(module, exports, __webpack_require__) { /***/ (function(module, exports, __webpack_require__) {
"use strict"; "use strict";
@ -5403,7 +5457,7 @@ var _action_types = __webpack_require__(2);
var ACTIONS = _interopRequireWildcard(_action_types); var ACTIONS = _interopRequireWildcard(_action_types);
var _reduxUtils = __webpack_require__(34); var _reduxUtils = __webpack_require__(35);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
@ -5492,7 +5546,7 @@ var notificationsReducer = (0, _reduxUtils.handleActions)((_handleActions = {},
exports.notificationsReducer = notificationsReducer; exports.notificationsReducer = notificationsReducer;
/***/ }), /***/ }),
/* 34 */ /* 35 */
/***/ (function(module, exports, __webpack_require__) { /***/ (function(module, exports, __webpack_require__) {
"use strict"; "use strict";
@ -5525,7 +5579,7 @@ var handleActions = exports.handleActions = function handleActions(actionMap, de
}; };
/***/ }), /***/ }),
/* 35 */ /* 36 */
/***/ (function(module, exports, __webpack_require__) { /***/ (function(module, exports, __webpack_require__) {
"use strict"; "use strict";
@ -5544,7 +5598,7 @@ var _action_types = __webpack_require__(2);
var ACTIONS = _interopRequireWildcard(_action_types); var ACTIONS = _interopRequireWildcard(_action_types);
var _reduxUtils = __webpack_require__(34); var _reduxUtils = __webpack_require__(35);
var _search = __webpack_require__(16); var _search = __webpack_require__(16);
@ -5630,7 +5684,7 @@ var searchReducer = exports.searchReducer = (0, _reduxUtils.handleActions)((_han
}), _handleActions), defaultState); }), _handleActions), defaultState);
/***/ }), /***/ }),
/* 36 */ /* 37 */
/***/ (function(module, exports, __webpack_require__) { /***/ (function(module, exports, __webpack_require__) {
"use strict"; "use strict";
@ -5973,7 +6027,86 @@ function walletReducer() {
} }
/***/ }), /***/ }),
/* 37 */ /* 38 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
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; };
exports.contentReducer = contentReducer;
var _action_types = __webpack_require__(2);
var ACTIONS = _interopRequireWildcard(_action_types);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
var reducers = {};
var defaultState = {
positions: {}
};
reducers[ACTIONS.SET_CONTENT_POSITION] = function (state, action) {
var _action$data = action.data,
claimId = _action$data.claimId,
outpoint = _action$data.outpoint,
position = _action$data.position;
return _extends({}, state, {
positions: _extends({}, state.positions, _defineProperty({}, claimId, _extends({}, state.positions[claimId], _defineProperty({}, outpoint, position))))
});
};
function contentReducer() {
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultState;
var action = arguments[1];
var handler = reducers[action.type];
if (handler) return handler(state, action);
return state;
}
/***/ }),
/* 39 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.makeSelectContentPositionForUri = exports.selectState = undefined;
var _reselect = __webpack_require__(14);
var _claims = __webpack_require__(12);
var selectState = exports.selectState = function selectState(state /*: any*/) {
return state.content || {};
};
var makeSelectContentPositionForUri = exports.makeSelectContentPositionForUri = function makeSelectContentPositionForUri(uri /*: string*/) {
return (0, _reselect.createSelector)(selectState, (0, _claims.makeSelectClaimForUri)(uri), function (state, claim) {
if (!claim) {
return null;
}
var outpoint = claim.txid + ':' + claim.nout;
var id = claim.claim_id;
return state.positions[id] ? state.positions[id][outpoint] : null;
});
};
/***/ }),
/* 40 */
/***/ (function(module, exports, __webpack_require__) { /***/ (function(module, exports, __webpack_require__) {
"use strict"; "use strict";
@ -6019,7 +6152,7 @@ var selectError = exports.selectError = (0, _reselect.createSelector)(selectStat
}); });
/***/ }), /***/ }),
/* 38 */ /* 41 */
/***/ (function(module, exports, __webpack_require__) { /***/ (function(module, exports, __webpack_require__) {
"use strict"; "use strict";
@ -6035,7 +6168,7 @@ var COMPLETE = exports.COMPLETE = 'complete';
var MANUAL = exports.MANUAL = 'manual'; var MANUAL = exports.MANUAL = 'manual';
/***/ }), /***/ }),
/* 39 */ /* 42 */
/***/ (function(module, exports, __webpack_require__) { /***/ (function(module, exports, __webpack_require__) {
"use strict"; "use strict";

View file

@ -66,6 +66,8 @@ export {
doUpdateSearchOptions, doUpdateSearchOptions,
} from 'redux/actions/search'; } from 'redux/actions/search';
export { savePosition } from 'redux/actions/content';
export { export {
doUpdateBalance, doUpdateBalance,
doBalanceSubscribe, doBalanceSubscribe,
@ -96,8 +98,11 @@ export { fileInfoReducer } from 'redux/reducers/file_info';
export { notificationsReducer } from 'redux/reducers/notifications'; export { notificationsReducer } from 'redux/reducers/notifications';
export { searchReducer } from 'redux/reducers/search'; export { searchReducer } from 'redux/reducers/search';
export { walletReducer } from 'redux/reducers/wallet'; export { walletReducer } from 'redux/reducers/wallet';
export { contentReducer } from 'redux/reducers/content';
// selectors // selectors
export { makeSelectContentPositionForUri } from 'redux/selectors/content';
export { selectToast, selectError } from 'redux/selectors/notifications'; export { selectToast, selectError } from 'redux/selectors/notifications';
export { export {

View file

@ -0,0 +1,10 @@
import * as ACTIONS from 'constants/action_types';
export function savePosition(claimId: string, outpoint: string, position: number) {
return dispatch => {
dispatch({
type: ACTIONS.SET_CONTENT_POSITION,
data: { claimId, outpoint, position },
});
};
}

View file

@ -0,0 +1,26 @@
import * as ACTIONS from 'constants/action_types';
const reducers = {};
const defaultState = {
positions: {},
};
reducers[ACTIONS.SET_CONTENT_POSITION] = (state, action) => {
const { claimId, outpoint, position } = action.data;
return {
...state,
positions: {
...state.positions,
[claimId]: {
...state.positions[claimId],
[outpoint]: position,
},
},
};
};
export function contentReducer(state = defaultState, action) {
const handler = reducers[action.type];
if (handler) return handler(state, action);
return state;
}

View file

@ -0,0 +1,14 @@
import { createSelector } from 'reselect';
import { makeSelectClaimForUri } from 'redux/selectors/claims';
export const selectState = (state: any) => state.content || {};
export const makeSelectContentPositionForUri = (uri: string) =>
createSelector(selectState, makeSelectClaimForUri(uri), (state, claim) => {
if (!claim) {
return null;
}
const outpoint = `${claim.txid}:${claim.nout}`;
const id = claim.claim_id;
return state.positions[id] ? state.positions[id][outpoint] : null;
});