more flow
This commit is contained in:
parent
11a4524c4c
commit
98df8b265f
25 changed files with 77 additions and 43 deletions
|
@ -24,7 +24,7 @@ module.name_mapper='^modal\(.*\)$' -> '<PROJECT_ROOT>/ui/modal\1'
|
|||
module.name_mapper='^app\(.*\)$' -> '<PROJECT_ROOT>/ui/app\1'
|
||||
module.name_mapper='^native\(.*\)$' -> '<PROJECT_ROOT>/ui/native\1'
|
||||
module.name_mapper='^analytics\(.*\)$' -> '<PROJECT_ROOT>/ui/analytics\1'
|
||||
module.name_mapper='^recsys\(.*\)$' -> '<PROJECT_ROOT>/ui/recsys\1'
|
||||
module.name_mapper='^recsys\(.*\)$' -> '<PROJECT_ROOT>/extras/recsys\1'
|
||||
module.name_mapper='^rewards\(.*\)$' -> '<PROJECT_ROOT>/ui/rewards\1'
|
||||
module.name_mapper='^i18n\(.*\)$' -> '<PROJECT_ROOT>/ui/i18n\1'
|
||||
module.name_mapper='^effects\(.*\)$' -> '<PROJECT_ROOT>/ui/effects\1'
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
import { Lbryio } from 'lbryinc';
|
||||
import * as ACTIONS from 'constants/action_types';
|
||||
|
||||
export const doFetchViewCount = (claimIdCsv: string) => dispatch => {
|
||||
export const doFetchViewCount = (claimIdCsv: string) => (dispatch: Dispatch) => {
|
||||
dispatch({ type: ACTIONS.FETCH_VIEW_COUNT_STARTED });
|
||||
|
||||
return Lbryio.call('file', 'view_count', { claim_id: claimIdCsv })
|
||||
|
@ -15,7 +15,7 @@ export const doFetchViewCount = (claimIdCsv: string) => dispatch => {
|
|||
});
|
||||
};
|
||||
|
||||
export const doFetchSubCount = (claimId: string) => dispatch => {
|
||||
export const doFetchSubCount = (claimId: string) => (dispatch: Dispatch) => {
|
||||
dispatch({ type: ACTIONS.FETCH_SUB_COUNT_STARTED });
|
||||
|
||||
return Lbryio.call('subscription', 'sub_count', { claim_id: claimId })
|
||||
|
|
|
@ -55,7 +55,7 @@ reducers[ACTIONS.UPDATE_UPLOAD_PROGRESS] = (state: TvState, action) => {
|
|||
return { ...state, currentUploads };
|
||||
};
|
||||
|
||||
export function webReducer(state = defaultState, action) {
|
||||
export function webReducer(state: TvState = defaultState, action: any) {
|
||||
const handler = reducers[action.type];
|
||||
if (handler) return handler(state, action);
|
||||
return state;
|
||||
|
|
3
extras/recsys/index.js
Normal file
3
extras/recsys/index.js
Normal file
|
@ -0,0 +1,3 @@
|
|||
import Recsys from './recsys';
|
||||
|
||||
export { Recsys };
|
|
@ -253,7 +253,7 @@ function ChannelForm(props: Props) {
|
|||
let nameError;
|
||||
if (!name && name !== undefined) {
|
||||
nameError = __('A name is required for your url');
|
||||
} else if (!isNameValid(name, false)) {
|
||||
} else if (!isNameValid(name)) {
|
||||
nameError = INVALID_NAME_ERROR;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import { AVATAR_DEFAULT } from 'config';
|
|||
|
||||
type Props = {
|
||||
thumbnail: ?string,
|
||||
uri: ?string,
|
||||
uri: string,
|
||||
className?: string,
|
||||
thumbnailPreview: ?string,
|
||||
obscure?: boolean,
|
||||
|
|
|
@ -175,13 +175,14 @@ function ClaimMenuList(props: Props) {
|
|||
|
||||
function handleFollow() {
|
||||
const subscriptionHandler = isSubscribed ? doChannelUnsubscribe : doChannelSubscribe;
|
||||
|
||||
if (channelName) {
|
||||
subscriptionHandler({
|
||||
channelName: '@' + channelName,
|
||||
uri: contentChannelUri,
|
||||
notificationsDisabled: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function handleToggleMute() {
|
||||
if (channelIsMuted) {
|
||||
|
@ -203,7 +204,7 @@ function ClaimMenuList(props: Props) {
|
|||
if (!isChannel) {
|
||||
const signingChannelName = contentSigningChannel && contentSigningChannel.name;
|
||||
|
||||
const uriObject: { streamName: string, streamClaimId: string, channelName?: string } = {
|
||||
const uriObject: LbryUrlObj = {
|
||||
streamName: claim.name,
|
||||
streamClaimId: claim.claim_id,
|
||||
};
|
||||
|
|
|
@ -12,7 +12,7 @@ type Props = {
|
|||
claim: ?Claim,
|
||||
pending?: boolean,
|
||||
type: string,
|
||||
beginPublish: (string) => void,
|
||||
beginPublish: (?string) => void,
|
||||
isLivestream: boolean,
|
||||
};
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ function FileActions(props: Props) {
|
|||
// We will select the claim id before they publish
|
||||
let editUri;
|
||||
if (claimIsMine) {
|
||||
const uriObject: { streamName: string, streamClaimId: string, channelName?: string } = {
|
||||
const uriObject: LbryUrlObj = {
|
||||
streamName: claim.name,
|
||||
streamClaimId: claim.claim_id,
|
||||
};
|
||||
|
|
|
@ -73,7 +73,7 @@ export default function FileRenderFloating(props: Props) {
|
|||
const playingUriSource = playingUri && playingUri.source;
|
||||
const isComment = playingUriSource === 'comment';
|
||||
const isMobile = useIsMobile();
|
||||
const mainFilePlaying = !isFloating && isURIEqual(uri, primaryUri);
|
||||
const mainFilePlaying = !isFloating && primaryUri && isURIEqual(uri, primaryUri);
|
||||
|
||||
const [fileViewerRect, setFileViewerRect] = useState();
|
||||
const [desktopPlayStartTime, setDesktopPlayStartTime] = useState();
|
||||
|
|
|
@ -57,12 +57,19 @@ function Invited(props: Props) {
|
|||
|
||||
// always follow if it's a channel
|
||||
useEffect(() => {
|
||||
if (fullUri && !isSubscribed) {
|
||||
if (fullUri && !isSubscribed && fullUri) {
|
||||
let channelName;
|
||||
try {
|
||||
const { claimName } = parseURI(fullUri);
|
||||
channelName = claimName;
|
||||
} catch (e) {}
|
||||
if (channelName) {
|
||||
channelSubscribe({
|
||||
channelName: parseURI(fullUri).claimName,
|
||||
channelName: channelName,
|
||||
uri: fullUri,
|
||||
});
|
||||
}
|
||||
}
|
||||
}, [fullUri, isSubscribed, channelSubscribe]);
|
||||
|
||||
useEffect(() => {
|
||||
|
|
|
@ -107,10 +107,12 @@ export default function Notification(props: Props) {
|
|||
}
|
||||
|
||||
let channelName;
|
||||
if (channelUrl) {
|
||||
try {
|
||||
const { claimName } = parseURI(channelUrl);
|
||||
channelName = claimName;
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
const notificationTitle = notification_parameters.device.title;
|
||||
const titleSplit = notificationTitle.split(' ');
|
||||
|
|
|
@ -8,7 +8,7 @@ import Card from 'component/common/card';
|
|||
import { useIsMobile, useIsMediumScreen } from 'effects/use-screensize';
|
||||
import Button from 'component/button';
|
||||
import classnames from 'classnames';
|
||||
import RecSys from 'extras/recsys/recsys';
|
||||
import RecSys from 'recsys';
|
||||
|
||||
const VIEW_ALL_RELATED = 'view_all_related';
|
||||
const VIEW_MORE_FROM = 'view_more_from';
|
||||
|
|
|
@ -115,7 +115,7 @@ type Props = {
|
|||
welcomeVersion: number,
|
||||
hasNavigated: boolean,
|
||||
setHasNavigated: () => void,
|
||||
setReferrer: (string) => void,
|
||||
setReferrer: (?string) => void,
|
||||
hasUnclaimedRefereeReward: boolean,
|
||||
homepageData: any,
|
||||
};
|
||||
|
|
|
@ -18,7 +18,7 @@ type Props = {
|
|||
doResolveUris: (Array<string>) => void,
|
||||
hideLink?: boolean,
|
||||
setChannelActive: (boolean) => void,
|
||||
beginPublish: (string) => void,
|
||||
beginPublish: (?string) => void,
|
||||
pendingIds: Array<string>,
|
||||
isResolvingWinningUri: boolean,
|
||||
winningClaim: ?Claim,
|
||||
|
@ -44,8 +44,6 @@ export default function SearchTopClaim(props: Props) {
|
|||
let winningUriIsChannel;
|
||||
try {
|
||||
const { isChannel, streamName, channelName } = parseURI(uriFromQuery);
|
||||
const { isChannel: winnerIsChannel } = parseURI(winningUri);
|
||||
winningUriIsChannel = winnerIsChannel;
|
||||
if (!isChannel) {
|
||||
channelUriFromQuery = `lbry://@${query}`;
|
||||
name = streamName;
|
||||
|
@ -54,6 +52,13 @@ export default function SearchTopClaim(props: Props) {
|
|||
}
|
||||
} catch (e) {}
|
||||
|
||||
if (winningUri) {
|
||||
try {
|
||||
const { isChannel: winnerIsChannel } = parseURI(winningUri);
|
||||
winningUriIsChannel = winnerIsChannel;
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
React.useEffect(() => {
|
||||
setChannelActive && winningUriIsChannel && setChannelActive(true);
|
||||
}, [setChannelActive, winningUriIsChannel]);
|
||||
|
@ -111,7 +116,11 @@ export default function SearchTopClaim(props: Props) {
|
|||
<I18nMessage
|
||||
tokens={{
|
||||
repost: (
|
||||
<Button button="link" onClick={() => push(`/$/${PAGES.REPOST_NEW}?to=${name}`)} label={__('Repost')} />
|
||||
<Button
|
||||
button="link"
|
||||
onClick={() => push(`/$/${PAGES.REPOST_NEW}${name ? `?to=${name}` : ''}`)}
|
||||
label={__('Repost')}
|
||||
/>
|
||||
),
|
||||
publish: (
|
||||
<span>
|
||||
|
|
|
@ -45,8 +45,18 @@ export default function SubscribeButton(props: Props) {
|
|||
const uiNotificationsEnabled = (user && user.experimental_ui) || ENABLE_UI_NOTIFICATIONS;
|
||||
|
||||
const { channelName: rawChannelName } = parseURI(uri);
|
||||
const { channelName } = parseURI(permanentUrl);
|
||||
const claimName = '@' + channelName;
|
||||
|
||||
let channelName;
|
||||
|
||||
if (permanentUrl) {
|
||||
try {
|
||||
const { channelName: name } = parseURI(permanentUrl);
|
||||
if (name) {
|
||||
channelName = name;
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
const claimName = channelName && '@' + channelName;
|
||||
|
||||
const subscriptionHandler = isSubscribed ? doChannelUnsubscribe : doChannelSubscribe;
|
||||
const subscriptionLabel = isSubscribed
|
||||
|
@ -86,7 +96,7 @@ export default function SubscribeButton(props: Props) {
|
|||
);
|
||||
}
|
||||
|
||||
return permanentUrl ? (
|
||||
return permanentUrl && claimName ? (
|
||||
<div className="button-group">
|
||||
<Button
|
||||
ref={buttonRef}
|
||||
|
|
|
@ -231,7 +231,7 @@ function ChannelPage(props: Props) {
|
|||
<ChannelThumbnail className="channel__thumbnail--channel-page" uri={uri} allowGifs hideStakedIndicator />
|
||||
<h1 className="channel__title">
|
||||
<TruncatedText lines={2} showTooltip>
|
||||
{title || '@' + channelName}
|
||||
{title || (channelName && '@' + channelName)}
|
||||
</TruncatedText>
|
||||
<ChannelStakedIndicator uri={uri} large />
|
||||
</h1>
|
||||
|
|
|
@ -157,7 +157,7 @@ function ShowPage(props: Props) {
|
|||
/>
|
||||
<Button
|
||||
button="secondary"
|
||||
onClick={() => push(`/$/${PAGES.REPOST_NEW}${contentName ? `to=${contentName}` : ''}`)}
|
||||
onClick={() => push(`/$/${PAGES.REPOST_NEW}${contentName ? `?to=${contentName}` : ''}`)}
|
||||
label={__('Repost Something')}
|
||||
/>
|
||||
</div>
|
||||
|
|
|
@ -82,7 +82,7 @@ export default function YoutubeSync(props: Props) {
|
|||
function handleChannelChange(e) {
|
||||
const { value } = e.target;
|
||||
setChannel(value);
|
||||
if (!isNameValid(value, 'false')) {
|
||||
if (!isNameValid(value)) {
|
||||
setNameError(INVALID_NAME_ERROR);
|
||||
} else {
|
||||
setNameError();
|
||||
|
|
|
@ -121,7 +121,7 @@ function handleClaimAction(state: State, action: any): State {
|
|||
let newResolvingUrls = new Set(state.resolvingUris);
|
||||
let myClaimIds = new Set(state.myClaims);
|
||||
|
||||
Object.entries(resolveInfo).forEach(([url, resolveResponse]: [string, ResolveResponse]) => {
|
||||
Object.entries(resolveInfo).forEach(([url, resolveResponse]) => {
|
||||
// $FlowFixMe
|
||||
const { claimsInChannel, stream, channel: channelFromResolve, collection } = resolveResponse;
|
||||
const channel = channelFromResolve || (stream && stream.signing_channel);
|
||||
|
|
|
@ -99,10 +99,9 @@ export default handleActions(
|
|||
} else {
|
||||
const parsedSubscriptions = subscriptions.map((uri) => {
|
||||
const { channelName } = parseURI(uri);
|
||||
|
||||
return {
|
||||
uri,
|
||||
channelName: `@${channelName}`,
|
||||
channelName: channelName ? `@${channelName}` : '',
|
||||
};
|
||||
});
|
||||
newSubscriptions = parsedSubscriptions;
|
||||
|
|
|
@ -289,10 +289,11 @@ export function GetLinksData(
|
|||
streamTypes: null,
|
||||
channelIds: subscribedChannels.map((subscription: Subscription) => {
|
||||
const { channelClaimId } = parseURI(subscription.uri);
|
||||
return channelClaimId;
|
||||
if (channelClaimId) return channelClaimId;
|
||||
}),
|
||||
},
|
||||
};
|
||||
// $FlowFixMe flow thinks this might not be Array<string>
|
||||
rowData.push(RECENT_FROM_FOLLOWING);
|
||||
}
|
||||
if (isHomepage && !CUSTOM_HOMEPAGE) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// @flow
|
||||
// Disabled flow in this copy. This copy is for uncompiled web server ES5 require()s.
|
||||
require('proxy-polyfill');
|
||||
|
||||
const CHECK_DAEMON_STARTED_TRY_NUMBER = 200;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// @flow
|
||||
// Disabled flow in this copy. This copy is for uncompiled web server ES5 require()s.
|
||||
|
||||
const isProduction = process.env.NODE_ENV === 'production';
|
||||
const channelNameMinLength = 1;
|
||||
const claimIdMaxLength = 40;
|
||||
|
|
|
@ -79,6 +79,7 @@ let baseConfig = {
|
|||
homepages: process.env.CUSTOM_HOMEPAGE === 'true' ? path.resolve(__dirname, 'custom/homepages/v2/index.js') : ('homepages/index.js'),
|
||||
memes: process.env.CUSTOM_HOMEPAGE === 'true' ? path.resolve(__dirname, 'custom/homepages/meme/index.js') : path.resolve(__dirname, 'homepages/meme/index.js'),
|
||||
lbryinc: 'extras/lbryinc',
|
||||
recsys: 'extras/recsys',
|
||||
// Build optimizations for 'redux-persist-transform-filter'
|
||||
'redux-persist-transform-filter': 'redux-persist-transform-filter/index.js',
|
||||
'lodash.get': 'lodash-es/get',
|
||||
|
|
Loading…
Reference in a new issue