Browse Source

Fix channel payouts (#4105)

Fix channel payouts
attemka 1 year ago
parent
commit
498209397b

+ 5 - 0
packages/atlas/src/api/client/index.ts

@@ -88,6 +88,11 @@ const createApolloClient = () => {
             if (!parent.type) {
               return null
             }
+
+            if (parent.type.__typename === 'DataObjectTypeChannelPayoutsPayload') {
+              // if this is a payload file skip testing and just return first url.
+              return resolvedUrls[0]
+            }
             const distributorUrl = resolvedUrl.split(`/${atlasConfig.storage.assetPath}/${parent.id}`)[0]
 
             const assetTestPromise = testAssetDownload(resolvedUrl, parent.type)

+ 17 - 4
packages/atlas/src/api/queries/__generated__/channels.generated.tsx

@@ -8,6 +8,7 @@ import {
   ExtendedBasicChannelFieldsFragmentDoc,
   ExtendedFullChannelFieldsFragmentDoc,
   FullChannelFieldsFragmentDoc,
+  StorageDataObjectFieldsFragmentDoc,
 } from './fragments.generated'
 
 const defaultOptions = {} as const
@@ -570,9 +571,22 @@ export type GetPayloadDataByCommitmentQuery = {
           __typename?: 'ChannelPayoutsUpdatedEventData'
           payloadDataObject?: {
             __typename?: 'StorageDataObject'
-            isAccepted: boolean
+            id: string
             resolvedUrls: Array<string>
             resolvedUrl?: string | null
+            createdAt: Date
+            size: string
+            isAccepted: boolean
+            ipfsHash: string
+            storageBag: { __typename?: 'StorageBag'; id: string }
+            type?:
+              | { __typename: 'DataObjectTypeChannelAvatar' }
+              | { __typename: 'DataObjectTypeChannelCoverPhoto' }
+              | { __typename: 'DataObjectTypeChannelPayoutsPayload' }
+              | { __typename: 'DataObjectTypeVideoMedia' }
+              | { __typename: 'DataObjectTypeVideoSubtitle' }
+              | { __typename: 'DataObjectTypeVideoThumbnail' }
+              | null
           } | null
         }
       | { __typename?: 'ChannelRewardClaimedAndWithdrawnEventData' }
@@ -1340,14 +1354,13 @@ export const GetPayloadDataByCommitmentDocument = gql`
       data {
         ... on ChannelPayoutsUpdatedEventData {
           payloadDataObject {
-            isAccepted
-            resolvedUrls
-            resolvedUrl @client
+            ...StorageDataObjectFields
           }
         }
       }
     }
   }
+  ${StorageDataObjectFieldsFragmentDoc}
 `
 
 /**

+ 1 - 3
packages/atlas/src/api/queries/channels.graphql

@@ -140,9 +140,7 @@ query GetPayloadDataByCommitment($commitment: String!) {
     data {
       ... on ChannelPayoutsUpdatedEventData {
         payloadDataObject {
-          isAccepted
-          resolvedUrls
-          resolvedUrl @client
+          ...StorageDataObjectFields
         }
       }
     }

+ 7 - 1
packages/atlas/src/views/studio/MyPaymentsView/PaymentsOverview/PaymentsOverview.hooks.ts

@@ -91,7 +91,13 @@ export const useChannelPayout = (txCallback?: () => void) => {
         }
         return { reward, payloadUrl, commitment }
       } catch (error) {
-        SentryLogger.error("Couldn't get reward data", 'PaymentOverviewTab.hooks', error)
+        const errorMessage = error?.message
+        if (typeof errorMessage === 'string' && errorMessage.startsWith('No payout Proof exists for channel')) {
+          // This error will experience every user that don't have claimable reward. No need to send this to sentry or log it.
+          return
+        } else {
+          SentryLogger.error("Couldn't get reward data", 'PaymentOverviewTab.hooks', error)
+        }
       }
     },
     [getPayloadUrl, joystream, maxCashoutAllowed, minCashoutAllowed]