Compare commits

..

3 commits

Author SHA1 Message Date
zeppi
34b20795e3 cleanup 2021-08-22 16:22:40 -04:00
zeppi
d45317807e fix background collection update 2021-08-22 15:52:44 -04:00
zeppi
e83153804d add isBackgroundUpdate to collection update 2021-08-19 14:22:22 -04:00
11 changed files with 63 additions and 180 deletions

83
dist/bundle.es.js vendored
View file

@ -2,12 +2,9 @@
Object.defineProperty(exports, '__esModule', { value: true });
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
require('proxy-polyfill');
var uuid = require('uuid');
var reselect = require('reselect');
var fromEntries = _interopDefault(require('@ungap/from-entries'));
const MINIMUM_PUBLISH_BID = 0.00000001;
@ -719,7 +716,7 @@ const INSTANT_PURCHASE_MAX = 'instant_purchase_max';
const THEME = 'theme';
const THEMES = 'themes';
const AUTOMATIC_DARK_MODE_ENABLED = 'automatic_dark_mode_enabled';
const AUTOPLAY_MEDIA = 'autoplay';
const AUTOPLAY = 'autoplay';
const AUTOPLAY_NEXT = 'autoplay_next';
const OS_NOTIFICATIONS_ENABLED = 'os_notifications_enabled';
const AUTO_DOWNLOAD = 'auto_download';
@ -770,7 +767,7 @@ var settings = /*#__PURE__*/Object.freeze({
THEME: THEME,
THEMES: THEMES,
AUTOMATIC_DARK_MODE_ENABLED: AUTOMATIC_DARK_MODE_ENABLED,
AUTOPLAY_MEDIA: AUTOPLAY_MEDIA,
AUTOPLAY: AUTOPLAY,
AUTOPLAY_NEXT: AUTOPLAY_NEXT,
OS_NOTIFICATIONS_ENABLED: OS_NOTIFICATIONS_ENABLED,
AUTO_DOWNLOAD: AUTO_DOWNLOAD,
@ -1040,7 +1037,7 @@ var daemon_settings = /*#__PURE__*/Object.freeze({
const SDK_SYNC_KEYS = [LBRYUM_SERVERS, SHARE_USAGE_DATA];
// CLIENT
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, LANGUAGE];
const CLIENT_SYNC_KEYS = [SHOW_MATURE, HIDE_REPOSTS, SHOW_ANONYMOUS, INSTANT_PURCHASE_ENABLED, INSTANT_PURCHASE_MAX, THEME, AUTOPLAY, HIDE_BALANCE, HIDE_SPLASH_ANIMATION, FLOATING_PLAYER, DARK_MODE_TIMES, AUTOMATIC_DARK_MODE_ENABLED];
var shared_preferences = /*#__PURE__*/Object.freeze({
SDK_SYNC_KEYS: SDK_SYNC_KEYS,
@ -3651,7 +3648,7 @@ const makeSelectCollectionIsMine = id => reselect.createSelector(selectMyCollect
const selectMyPublishedCollections = reselect.createSelector(selectResolvedCollections, selectPendingCollections, selectMyEditedCollections, selectMyCollectionIds, (resolved, pending, edited, myIds) => {
// all resolved in myIds, plus those in pending and edited
const myPublishedCollections = fromEntries(Object.entries(pending).concat(Object.entries(resolved).filter(([key, val]) => myIds.includes(key) &&
const myPublishedCollections = Object.fromEntries(Object.entries(pending).concat(Object.entries(resolved).filter(([key, val]) => myIds.includes(key) &&
// $FlowFixMe
!pending[key])));
// now add in edited:
@ -3662,7 +3659,7 @@ const selectMyPublishedCollections = reselect.createSelector(selectResolvedColle
});
const selectMyPublishedMixedCollections = reselect.createSelector(selectMyPublishedCollections, published => {
const myCollections = fromEntries(
const myCollections = Object.fromEntries(
// $FlowFixMe
Object.entries(published).filter(([key, collection]) => {
// $FlowFixMe
@ -3672,7 +3669,7 @@ const selectMyPublishedMixedCollections = reselect.createSelector(selectMyPublis
});
const selectMyPublishedPlaylistCollections = reselect.createSelector(selectMyPublishedCollections, published => {
const myCollections = fromEntries(
const myCollections = Object.fromEntries(
// $FlowFixMe
Object.entries(published).filter(([key, collection]) => {
// $FlowFixMe
@ -3687,7 +3684,7 @@ const makeSelectMyPublishedCollectionForId = id => reselect.createSelector(selec
// selectResolvedCollections,
// selectSavedCollectionIds,
// (resolved, myIds) => {
// const mySavedCollections = fromEntries(
// const mySavedCollections = Object.fromEntries(
// Object.entries(resolved).filter(([key, val]) => myIds.includes(key))
// );
// return mySavedCollections;
@ -3730,51 +3727,23 @@ const makeSelectClaimIdsForCollectionId = id => reselect.createSelector(makeSele
return ids;
});
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);
const makeSelectIndexForUrlInCollection = (url, id) => reselect.createSelector(makeSelectUrlsForCollectionId(id), makeSelectClaimForUri(url), (urls, claim) => {
const index = urls && urls.findIndex(u => u === url);
if (index > -1) {
return index;
} else if (claim) {
const index = listUrls && listUrls.findIndex(u => u === claim.permanent_url);
const index = urls && urls.findIndex(u => u === claim.permanent_url);
if (index > -1) return index;
return claim;
}
return null;
});
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;
const makeSelectNextUrlForCollectionAndUrl = (id, url) => reselect.createSelector(makeSelectIndexForUrlInCollection(url, id), selectClaimsByUri, makeSelectUrlsForCollectionId(id), (index, claims, urls) => {
if (index > -1) {
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;
// We'll get the next playble url
let remainingUrls = listUrls.slice(index + 1);
if (!remainingUrls.length && loopList) {
remainingUrls = listUrls.slice(0);
}
const nextUrl = remainingUrls && remainingUrls[0];
const remainingUrls = urls.slice(index + 1);
const nextUrl = remainingUrls.find(u => claims[u].value.stream_type && (claims[u].value.stream_type === 'video' || claims[u].value.stream_type === 'audio'));
return nextUrl || null;
} else {
return null;
@ -3790,13 +3759,7 @@ const makeSelectCountForCollectionId = id => reselect.createSelector(makeSelectC
if (collection.itemCount !== undefined) {
return collection.itemCount;
}
let itemCount = 0;
collection.items.map(item => {
if (item) {
itemCount += 1;
}
});
return itemCount;
return collection.items.length;
}
return null;
});
@ -4520,8 +4483,7 @@ function doCollectionPublishUpdate(options, isBackgroundUpdate) {
locations: [],
blocking: true,
claim_id: options.claim_id,
clear_claims: true,
replace: true
clear_claims: true
};
if (isBackgroundUpdate && updateParams.claim_id) {
@ -4535,10 +4497,6 @@ function doCollectionPublishUpdate(options, isBackgroundUpdate) {
updateParams['tags'] = options.tags.map(tag => tag.name);
}
if (options.channel_id) {
updateParams['channel_id'] = options.channel_id;
}
return new Promise(resolve => {
dispatch({
type: COLLECTION_PUBLISH_UPDATE_STARTED
@ -5633,7 +5591,7 @@ const doUpdatePublishForm = publishFormValue => dispatch => dispatch({
data: _extends$7({}, publishFormValue)
});
const doUploadThumbnail = (filePath, thumbnailBlob, fsAdapter, fs, path, cb) => dispatch => {
const doUploadThumbnail = (filePath, thumbnailBlob, fsAdapter, fs, path) => dispatch => {
const downMessage = __('Thumbnail upload service may be down, try again later.');
let thumbnail, fileExt, fileName, fileType;
@ -5667,17 +5625,13 @@ const doUploadThumbnail = (filePath, thumbnailBlob, fsAdapter, fs, path, cb) =>
method: 'POST',
body: data
}).then(res => res.text()).then(text => text.length ? JSON.parse(text) : {}).then(json => {
if (!json.success) return uploadError(json.message || downMessage);
if (cb) {
cb(json.data.serveUrl);
}
return dispatch({
return json.success ? dispatch({
type: UPDATE_PUBLISH_FORM,
data: {
uploadThumbnailStatus: COMPLETE,
thumbnail: json.data.serveUrl
}
});
}) : uploadError(json.message || downMessage);
}).catch(err => {
let message = err.message;
@ -8107,7 +8061,6 @@ exports.makeSelectPendingAmountByUri = makeSelectPendingAmountByUri;
exports.makeSelectPendingClaimForUri = makeSelectPendingClaimForUri;
exports.makeSelectPendingCollectionForId = makeSelectPendingCollectionForId;
exports.makeSelectPermanentUrlForUri = makeSelectPermanentUrlForUri;
exports.makeSelectPreviousUrlForCollectionAndUrl = makeSelectPreviousUrlForCollectionAndUrl;
exports.makeSelectPublishFormValue = makeSelectPublishFormValue;
exports.makeSelectPublishedCollectionForId = makeSelectPublishedCollectionForId;
exports.makeSelectReflectingClaimForUri = makeSelectReflectingClaimForUri;

View file

@ -1,5 +0,0 @@
// @flow
declare module '@ungap/from-entries' {
declare module.exports: any;
}

View file

@ -1,5 +0,0 @@
// @flow
declare module '@ungap/from-entries' {
declare module.exports: any;
}

View file

@ -29,7 +29,6 @@
"test": "jest"
},
"dependencies": {
"@ungap/from-entries": "^0.2.1",
"proxy-polyfill": "0.1.6",
"reselect": "^3.0.0",
"uuid": "^8.3.1"

View file

@ -23,7 +23,7 @@ export const INSTANT_PURCHASE_MAX = 'instant_purchase_max';
export const THEME = 'theme';
export const THEMES = 'themes';
export const AUTOMATIC_DARK_MODE_ENABLED = 'automatic_dark_mode_enabled';
export const AUTOPLAY_MEDIA = 'autoplay';
export const AUTOPLAY = 'autoplay';
export const AUTOPLAY_NEXT = 'autoplay_next';
export const OS_NOTIFICATIONS_ENABLED = 'os_notifications_enabled';
export const AUTO_DOWNLOAD = 'auto_download';

View file

@ -21,12 +21,10 @@ export const CLIENT_SYNC_KEYS = [
SETTINGS.INSTANT_PURCHASE_ENABLED,
SETTINGS.INSTANT_PURCHASE_MAX,
SETTINGS.THEME,
SETTINGS.AUTOPLAY_MEDIA,
SETTINGS.AUTOPLAY_NEXT,
SETTINGS.AUTOPLAY,
SETTINGS.HIDE_BALANCE,
SETTINGS.HIDE_SPLASH_ANIMATION,
SETTINGS.FLOATING_PLAYER,
SETTINGS.DARK_MODE_TIMES,
SETTINGS.AUTOMATIC_DARK_MODE_ENABLED,
SETTINGS.LANGUAGE,
];

View file

@ -183,7 +183,6 @@ export {
makeSelectCountForCollectionId,
makeSelectIsResolvingCollectionForId,
makeSelectIndexForUrlInCollection,
makeSelectPreviousUrlForCollectionAndUrl,
makeSelectNextUrlForCollectionAndUrl,
makeSelectCollectionForIdHasClaimUrl,
} from 'redux/selectors/collections';

View file

@ -79,7 +79,7 @@ export function doResolveUris(
const collectionIds: Array<string> = [];
return Lbry.resolve({ urls: urisToResolve, ...options }).then(
async(result: ResolveResponse) => {
async (result: ResolveResponse) => {
let repostedResults = {};
const repostsToResolve = [];
const fallbackResolveInfo = {
@ -651,7 +651,7 @@ export function doClaimSearch(
}
) {
const query = createNormalizedClaimSearchKey(options);
return async(dispatch: Dispatch) => {
return async (dispatch: Dispatch) => {
dispatch({
type: ACTIONS.CLAIM_SEARCH_STARTED,
data: { query: query },
@ -842,7 +842,6 @@ export function doCollectionPublishUpdate(
tags?: Array<Tag>,
languages?: Array<string>,
claims?: Array<string>,
channel_id?: string,
},
isBackgroundUpdate?: boolean
) {
@ -854,33 +853,30 @@ export function doCollectionPublishUpdate(
blocking?: true,
title?: string,
thumbnail_url?: string,
channel_id?: string,
description?: string,
claim_id: string,
tags?: Array<string>,
languages?: Array<string>,
claims?: Array<string>,
clear_claims: boolean,
replace?: boolean,
} = isBackgroundUpdate
? {
blocking: true,
claim_id: options.claim_id,
clear_claims: true,
}
blocking: true,
claim_id: options.claim_id,
clear_claims: true,
}
: {
bid: creditsToString(options.bid),
title: options.title,
thumbnail_url: options.thumbnail_url,
description: options.description,
tags: [],
languages: options.languages || [],
locations: [],
blocking: true,
claim_id: options.claim_id,
clear_claims: true,
replace: true,
};
bid: creditsToString(options.bid),
title: options.title,
thumbnail_url: options.thumbnail_url,
description: options.description,
tags: [],
languages: options.languages || [],
locations: [],
blocking: true,
claim_id: options.claim_id,
clear_claims: true,
};
if (isBackgroundUpdate && updateParams.claim_id) {
const state = getState();
@ -893,10 +889,6 @@ export function doCollectionPublishUpdate(
updateParams['tags'] = options.tags.map(tag => tag.name);
}
if (options.channel_id) {
updateParams['channel_id'] = options.channel_id;
}
return new Promise(resolve => {
dispatch({
type: ACTIONS.COLLECTION_PUBLISH_UPDATE_STARTED,

View file

@ -69,8 +69,7 @@ export const doUploadThumbnail = (
thumbnailBlob?: File,
fsAdapter?: any,
fs?: any,
path?: any,
cb?: (string) => void
path?: any
) => (dispatch: Dispatch) => {
const downMessage = __('Thumbnail upload service may be down, try again later.');
let thumbnail, fileExt, fileName, fileType;
@ -113,17 +112,15 @@ export const doUploadThumbnail = (
.then(res => res.text())
.then(text => (text.length ? JSON.parse(text) : {}))
.then(json => {
if (!json.success) return uploadError(json.message || downMessage);
if (cb) {
cb(json.data.serveUrl);
}
return dispatch({
type: ACTIONS.UPDATE_PUBLISH_FORM,
data: {
uploadThumbnailStatus: THUMBNAIL_STATUSES.COMPLETE,
thumbnail: json.data.serveUrl,
},
});
return json.success
? dispatch({
type: ACTIONS.UPDATE_PUBLISH_FORM,
data: {
uploadThumbnailStatus: THUMBNAIL_STATUSES.COMPLETE,
thumbnail: json.data.serveUrl,
},
})
: uploadError(json.message || downMessage);
})
.catch(err => {
let message = err.message;

View file

@ -1,5 +1,4 @@
// @flow
import fromEntries from '@ungap/from-entries';
import { createSelector } from 'reselect';
import {
selectMyCollectionIds,
@ -80,7 +79,7 @@ export const selectMyPublishedCollections = createSelector(
selectMyCollectionIds,
(resolved, pending, edited, myIds) => {
// all resolved in myIds, plus those in pending and edited
const myPublishedCollections = fromEntries(
const myPublishedCollections = Object.fromEntries(
Object.entries(pending).concat(
Object.entries(resolved).filter(
([key, val]) =>
@ -101,7 +100,7 @@ export const selectMyPublishedCollections = createSelector(
export const selectMyPublishedMixedCollections = createSelector(
selectMyPublishedCollections,
published => {
const myCollections = fromEntries(
const myCollections = Object.fromEntries(
// $FlowFixMe
Object.entries(published).filter(([key, collection]) => {
// $FlowFixMe
@ -115,7 +114,7 @@ export const selectMyPublishedMixedCollections = createSelector(
export const selectMyPublishedPlaylistCollections = createSelector(
selectMyPublishedCollections,
published => {
const myCollections = fromEntries(
const myCollections = Object.fromEntries(
// $FlowFixMe
Object.entries(published).filter(([key, collection]) => {
// $FlowFixMe
@ -136,7 +135,7 @@ export const makeSelectMyPublishedCollectionForId = (id: string) =>
// selectResolvedCollections,
// selectSavedCollectionIds,
// (resolved, myIds) => {
// const mySavedCollections = fromEntries(
// const mySavedCollections = Object.fromEntries(
// Object.entries(resolved).filter(([key, val]) => myIds.includes(key))
// );
// return mySavedCollections;
@ -213,18 +212,14 @@ export const makeSelectClaimIdsForCollectionId = (id: string) =>
export const makeSelectIndexForUrlInCollection = (url: string, id: string) =>
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);
(urls, claim) => {
const index = urls && urls.findIndex(u => u === url);
if (index > -1) {
return index;
} else if (claim) {
const index = listUrls && listUrls.findIndex(u => u === claim.permanent_url);
const index = urls && urls.findIndex(u => u === claim.permanent_url);
if (index > -1) return index;
return claim;
}
@ -232,49 +227,20 @@ export const makeSelectIndexForUrlInCollection = (url: string, id: string) =>
}
);
export const makeSelectPreviousUrlForCollectionAndUrl = (id: string, url: string) =>
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;
let nextUrl;
if (index === 0 && loopList) {
nextUrl = listUrls[listUrls.length - 1];
} else {
nextUrl = listUrls[index - 1];
}
return nextUrl || null;
} else {
return null;
}
}
);
export const makeSelectNextUrlForCollectionAndUrl = (id: string, url: string) =>
createSelector(
state => state.content.shuffleList,
state => state.content.loopList,
makeSelectIndexForUrlInCollection(url, id),
selectClaimsByUri,
makeSelectUrlsForCollectionId(id),
(shuffleState, loopState, index, urls) => {
const loopList = loopState && loopState.collectionId === id && loopState.loop;
const shuffleUrls = shuffleState && shuffleState.collectionId === id && shuffleState.newUrls;
(index, claims, urls) => {
if (index > -1) {
const listUrls = shuffleUrls || urls;
// We'll get the next playble url
let remainingUrls = listUrls.slice(index + 1);
if (!remainingUrls.length && loopList) {
remainingUrls = listUrls.slice(0);
}
const nextUrl = remainingUrls && remainingUrls[0];
const remainingUrls = urls.slice(index + 1);
const nextUrl = remainingUrls.find(
u =>
claims[u].value.stream_type &&
(claims[u].value.stream_type === 'video' || claims[u].value.stream_type === 'audio')
);
return nextUrl || null;
} else {
return null;
@ -298,13 +264,7 @@ export const makeSelectCountForCollectionId = (id: string) =>
if (collection.itemCount !== undefined) {
return collection.itemCount;
}
let itemCount = 0;
collection.items.map(item => {
if (item) {
itemCount += 1;
}
});
return itemCount;
return collection.items.length;
}
return null;
}

View file

@ -1411,11 +1411,6 @@
dependencies:
"@types/yargs-parser" "*"
"@ungap/from-entries@^0.2.1":
version "0.2.1"
resolved "https://registry.yarnpkg.com/@ungap/from-entries/-/from-entries-0.2.1.tgz#7e86196b8b2e99d73106a8f25c2a068326346354"
integrity sha512-CAqefTFAfnUPwYqsWHXpOxHaq1Zo5UQ3m9Zm2p09LggGe57rqHoBn3c++xcoomzXKynAUuiBMDUCQvKMnXjUpA==
abab@^1.0.4:
version "1.0.4"
resolved "https://registry.yarnpkg.com/abab/-/abab-1.0.4.tgz#5faad9c2c07f60dd76770f71cf025b62a63cfd4e"