per sub download work

This commit is contained in:
zeppi 2022-05-05 17:28:01 -04:00
parent deb3d5bdc3
commit aba062ae43
10 changed files with 144 additions and 31 deletions

View file

@ -16,4 +16,7 @@ declare type SubscriptionState = {
following: Array<Following>,
loading: boolean,
firstRunCompleted: boolean,
downloadEnabledByUrl: any,
downloadQueue: Array<string>,
lastReleaseBySubUrl: any,
};

View file

@ -2054,4 +2054,28 @@ export const icons = {
<path d="M12.5,23.24v-1A10.74,10.74,0,0,1,23.24,11.52" />
</g>
),
[ICONS.HOST]: buildIcon(
<g>
<path d="M9 22.5 12 9l3 13.5" />
<circle cx={12} cy={7.657} r={1.25} />
<path
fillRule="evenodd"
clipRule="evenodd"
d="M4 7.657c0-2.21.895-4.21 2.343-5.657l1.06 1.06A6.48 6.48 0 0 0 5.5 7.658a6.48 6.48 0 0 0 1.904 4.596l-1.06 1.06A7.975 7.975 0 0 1 4 7.658Zm13.657 5.657A7.975 7.975 0 0 0 20 7.657c0-2.21-.895-4.21-2.343-5.657l-1.06 1.06A6.48 6.48 0 0 1 18.5 7.658a6.48 6.48 0 0 1-1.904 4.596l1.06 1.06Z"
/>
<path
fillRule="evenodd"
clipRule="evenodd"
d="M7 7.657c0-1.38.56-2.63 1.464-3.536l1.061 1.061A3.49 3.49 0 0 0 8.5 7.657c0 .966.392 1.841 1.025 2.475l-1.06 1.06A4.984 4.984 0 0 1 7 7.657Zm8.536 3.535A4.984 4.984 0 0 0 17 7.657c0-1.38-.56-2.63-1.464-3.536l-1.061 1.061A3.49 3.49 0 0 1 15.5 7.657a3.49 3.49 0 0 1-1.025 2.475l1.06 1.06Z"
/>
<path d="M2 22h20" />
</g>
),
[ICONS.NO_HOST]: buildIcon(
<g>
<path d="M9 22.5 12 9l3 13.5" />
<circle cx={12} cy={7.657} r={1.25} />
<path d="M2 22h20" />
</g>
),
};

View file

@ -325,6 +325,10 @@ export const CHECK_SUBSCRIPTION_STARTED = 'CHECK_SUBSCRIPTION_STARTED';
export const CHECK_SUBSCRIPTION_COMPLETED = 'CHECK_SUBSCRIPTION_COMPLETED';
export const CHECK_SUBSCRIPTIONS_SUBSCRIBE = 'CHECK_SUBSCRIPTIONS_SUBSCRIBE';
export const SET_VIEW_MODE = 'SET_VIEW_MODE';
export const SUBSCRIPTION_DOWNLOAD_ADD = 'SUBSCRIPTION_DOWNLOAD_ADD';
export const SUBSCRIPTION_DOWNLOAD_REMOVE = 'SUBSCRIPTION_DOWNLOAD_REMOVE';
export const SUBSCRIPTION_RELEASE_UPDATE = 'SUBSCRIPTION_RELEASE_UPDATE';
export const SUBSCRIPTION_DOWNLOAD_TOGGLE = 'SUBSCRIPTION_DOWNLOAD_TOGGLE';
// Publishing
export const CLEAR_PUBLISH = 'CLEAR_PUBLISH';

View file

@ -186,3 +186,5 @@ export const MYSTERIES = 'Mysteries';
export const TECHNOLOGY = 'Technology';
export const EMOJI = 'Emoji';
export const STICKER = 'Sticker';
export const HOST = 'Host';
export const NO_HOST = 'NoHost';

View file

@ -26,7 +26,6 @@ import I18nMessage from 'component/i18nMessage';
import TruncatedText from 'component/common/truncated-text';
// $FlowFixMe cannot resolve ...
import PlaceholderTx from 'static/img/placeholderTx.gif';
import { FormField } from 'component/common/form-components/form-field';
export const PAGE_VIEW_QUERY = `view`;
export const DISCUSSION_PAGE = `discussion`;
@ -293,7 +292,6 @@ function ChannelPage(props: Props) {
<Tab disabled={editing}>{__('Playlists')}</Tab>
<Tab>{editing ? __('Editing Your Channel') : __('About --[tab title in Channel Page]--')}</Tab>
<Tab disabled={editing}>{__('Community')}</Tab>
<Tab disabled={editing}>{__('Subscription')}</Tab>
</TabList>
<TabPanels>
<TabPanel>
@ -324,27 +322,6 @@ function ChannelPage(props: Props) {
<TabPanel>
{(discussionWasMounted || currentView === PAGE.DISCUSSION) && <ChannelDiscussion uri={uri} />}
</TabPanel>
<TabPanel>
<div className="card">
<section className="section card--section">
<Fragment>
<div className="media__info-text">
<label>{__('New Content Notifications')}</label>
<FormField name={'notify'} type={'checkbox'} checked />
</div>
<div className="media__info-text">
<label>{__('Download and Host new content')}</label>
<FormField name={'host'} type={'checkbox'} checked />
</div>
<div className="media__info-text">
<label>{__('Items to Host')}</label>
<FormField name={'host_count'} type={'number'} value={3} />
</div>
</Fragment>
</section>
</div>
</TabPanel>
</TabPanels>
</Tabs>
)}

View file

@ -6,6 +6,7 @@ import { doClaimRewardType } from 'redux/actions/rewards';
import { parseURI } from 'util/lbryURI';
import { doAlertWaitingForSync } from 'redux/actions/app';
import { doToast } from 'redux/actions/notifications';
import { makeSelectNotificationsDisabled, selectSubscriptionUris } from '../selectors/subscriptions';
type SubscriptionArgs = {
channelName: string,
@ -85,3 +86,59 @@ export function doChannelUnsubscribe(subscription: SubscriptionArgs, followToast
return dispatch(doToggleSubscription(subscription, followToast, true));
};
}
export function doAddUriToDownloadQueue(uri: string) {
return (dispatch: Dispatch) => {
return {
type: ACTIONS.SUBSCRIPTION_DOWNLOAD_ADD,
data: uri,
};
};
}
export function doRemoveUriFromDownloadQueue(uri: string) {
return (dispatch: Dispatch) => {
return {
type: ACTIONS.SUBSCRIPTION_DOWNLOAD_REMOVE,
data: uri,
};
};
}
export function doUpdateLastReleaseForUri(uri: string, timestamp: number) {
return (dispatch: Dispatch) => {
return dispatch({
type: ACTIONS.SUBSCRIPTION_RELEASE_UPDATE,
data: { uri, timestamp },
});
};
}
export function doSubscriptionDownloadEnableForUri(uri: string, enable: boolean) {
return (dispatch: Dispatch) => {
return dispatch({
type: ACTIONS.SUBSCRIPTION_DOWNLOAD_TOGGLE,
data: { uri, enable },
});
};
}
export function doCheckSubscribedPublishes() {
// finish this
return async (dispatch: Dispatch, getState: GetState) => {
const state = getState();
// for sub in subs, if notify+ or download+, getnewpublishes()
const subs = selectSubscriptionUris(state);
for (const sub in subs) {
// $FlowFixMe
const hasNotify = makeSelectNotificationsDisabled(sub.uri)(state); // eslint-disable-line
// const shouldDownload =
// doFileGet(uri)
}
// ./lbrynet claim search --channel_id="9d4c31875f534dc1f989db6c13b92ab1aab85ecf" --release_time=">1647101965" --order_by="release_time"
// add most recent release time
// add to downloads,
// add notifications,
};
}

View file

@ -6,9 +6,11 @@ import { handleActions } from 'util/redux-utils';
const defaultState: SubscriptionState = {
subscriptions: [], // Deprecated
following: [],
autoDownloads: {},
loading: false,
firstRunCompleted: false,
downloadEnabledByUrl: {},
downloadQueue: [],
lastReleaseBySubUrl: {},
};
/*
@ -72,6 +74,41 @@ export default handleActions(
...state,
viewMode: action.data,
}),
[ACTIONS.SUBSCRIPTION_DOWNLOAD_ADD]: (state: SubscriptionState, action): SubscriptionState => {
const { downloadQueue } = state;
const uri = action.data;
const newDownloadQueue = downloadQueue.concat(uri);
return {
...state,
downloadUrisQueued: newDownloadQueue,
};
},
[ACTIONS.SUBSCRIPTION_DOWNLOAD_REMOVE]: (state: SubscriptionState, action): SubscriptionState => {
const { downloadQueue } = state;
const uri = action.data;
const newDownloadQueue = downloadQueue.filter((f) => f !== uri);
return {
...state,
downloadUrisQueued: newDownloadQueue,
};
},
[ACTIONS.SUBSCRIPTION_RELEASE_UPDATE]: (state: SubscriptionState, action): SubscriptionState => {
const { lastReleaseBySubUrl } = state;
const { uri, timestamp } = action.data;
lastReleaseBySubUrl[uri] = timestamp;
return {
...state,
lastReleaseBySubUrl,
};
},
[ACTIONS.SUBSCRIPTION_DOWNLOAD_TOGGLE]: (state: SubscriptionState, action): SubscriptionState => {
const { downloadEnabledByUrl } = state;
const { uri, enable } = action.data;
downloadEnabledByUrl[uri] = enable;
return Object.assign({}, state, { downloadEnabledByUrl });
},
[ACTIONS.SYNC_STATE_POPULATE]: (
state: SubscriptionState,
action: { data: { subscriptions: ?Array<string>, following: ?Array<Subscription> } }

View file

@ -30,6 +30,8 @@ export const selectFollowing = createSelector(selectState, (state) => state.foll
// Fetching list of users subscriptions
export const selectIsFetchingSubscriptions = createSelector(selectState, (state) => state.loading);
export const selectDownloadEnabledByUrl = createSelector(selectState, (state) => state.downloadEnabledByUrl);
// The current view mode on the subscriptions page
export const selectViewMode = createSelector(selectState, (state) => state.viewMode);
@ -154,3 +156,8 @@ export const makeSelectNotificationsDisabled = (uri) =>
return true;
}
);
export const makeSelectDownloadEnabled = (uri) =>
createSelector(selectDownloadEnabledByUrl, (downloadEnabledByUrl) => {
return downloadEnabledByUrl[uri] || false;
});

View file

@ -663,16 +663,18 @@ svg + .button__label {
.button:first-child:not(:only-child) {
border-top-right-radius: 0;
border-bottom-right-radius: 0;
margin-right: 1px;
}
.button:nth-child(2) {
.button:not(:first-child):not(:last-child) {
border-top-right-radius: 0;
border-bottom-right-radius: 0;
border-top-left-radius: 0;
border-bottom-left-radius: 0;
}
.button:last-child:not(:only-child) {
border-top-left-radius: 0;
border-bottom-left-radius: 0;
margin-left: 1px;
&:hover {
fill: var(--color-text) !important;
}
}
.button--file-action {

View file

@ -19,7 +19,7 @@ $actions-z-index: 2;
}
}
}
.button-following:last-of-type {
.button-following:not(first-of-type) {
margin-left: 2px;
}
}