Leszek Wiesner 4 years ago
parent
commit
d5c62468f5

+ 4 - 3
packages/joy-media/src/Upload.tsx

@@ -9,14 +9,14 @@ import { ApiProps } from '@polkadot/react-api/types';
 import { I18nProps } from '@polkadot/react-components/types';
 import { SubmittableResult } from '@polkadot/api';
 import { Option } from '@polkadot/types/codec';
-import { withMulti } from '@polkadot/react-api';
+import { withMulti, withApi } from '@polkadot/react-api';
 import { formatNumber } from '@polkadot/util';
 import { AccountId } from '@polkadot/types/interfaces';
 
 import translate from './translate';
 import { fileNameWoExt } from './utils';
 import { ContentId, DataObject } from '@joystream/types/media';
-import { MyAccountProps, withMembershipRequired } from '@polkadot/joy-utils/MyAccount';
+import { withMembershipRequired } from '@polkadot/joy-utils/MyAccount';
 import { DiscoveryProviderProps, withDiscoveryProvider } from './DiscoveryProvider';
 import TxButton from '@polkadot/joy-utils/TxButton';
 import IpfsHash from 'ipfs-only-hash';
@@ -27,7 +27,7 @@ import { JoyInfo } from '@polkadot/joy-utils/JoyStatus';
 const MAX_FILE_SIZE_MB = 500;
 const MAX_FILE_SIZE_BYTES = MAX_FILE_SIZE_MB * 1024 * 1024;
 
-type Props = ApiProps & I18nProps & MyAccountProps & DiscoveryProviderProps & {
+type Props = ApiProps & I18nProps & DiscoveryProviderProps & {
   channelId: ChannelId
   history?: History
   match: {
@@ -314,6 +314,7 @@ class Component extends React.PureComponent<Props, State> {
 export const UploadWithRouter = withMulti(
   Component,
   translate,
+  withApi,
   withMembershipRequired,
   withDiscoveryProvider
 )

+ 3 - 3
packages/joy-media/src/transport.ts

@@ -160,9 +160,9 @@ export abstract class MediaTransport extends Transport {
 
   abstract allMusicAlbums(): Promise<MusicAlbumType[]>
 
-  async videosByChannelId(channelId: ChannelId, limit?: number): Promise<VideoType[]> {
+  async videosByChannelId(channelId: ChannelId, limit?: number, additionalFilter?: (x: VideoType) => boolean): Promise<VideoType[]> {
     let videos = (await this.allVideos())
-      .filter(x => channelId && channelId.eq(x.channelId))
+      .filter(x => channelId && channelId.eq(x.channelId) && (additionalFilter || (() => true))(x))
       .sort(x => -1 * x.id)
 
     if (limit && limit > 0) {
@@ -226,7 +226,7 @@ export abstract class MediaTransport extends Transport {
       .find(x =>
         insensitiveEq(x.value, 'Public')
       )?.id
-    
+
     const idsOfCuratedCS = (await this.allCurationStatuses())
       .filter(x =>
         insensitiveEq(x.value, 'Under review') ||

+ 1 - 1
packages/joy-media/src/video/PlayVideo.view.tsx

@@ -19,7 +19,7 @@ export const PlayVideoView = MediaView<Props>({
 
     const channelId = new ChannelId(video.channelId)
     const channel = await transport.channelById(channelId)
-    const moreChannelVideos = (await transport.videosByChannelId(channelId, 5)).filter(x => x.id !== video.id)
+    const moreChannelVideos = (await transport.videosByChannelId(channelId, 5, x => x.id !== video.id));
     const featuredVideos = await transport.featuredVideos()
     const mediaObject = video.object