From 646caf5213c49689a85183f07666786f24d5e7e1 Mon Sep 17 00:00:00 2001 From: Nevo David Date: Mon, 23 Jun 2025 12:57:01 +0700 Subject: [PATCH] fix: X premium to upload longer videos --- apps/frontend/src/components/launches/add.edit.model.tsx | 3 ++- .../src/components/launches/helpers/use.values.ts | 6 ++++-- .../launches/providers/high.order.provider.tsx | 3 ++- .../src/components/launches/providers/x/x.provider.tsx | 9 +++++---- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/apps/frontend/src/components/launches/add.edit.model.tsx b/apps/frontend/src/components/launches/add.edit.model.tsx index efe8ff1a..32176cd0 100644 --- a/apps/frontend/src/components/launches/add.edit.model.tsx +++ b/apps/frontend/src/components/launches/add.edit.model.tsx @@ -413,7 +413,8 @@ export const AddEditModal: FC<{ if (key.checkValidity) { const check = await key.checkValidity( key?.value.map((p: any) => p.image || []), - key.settings + key.settings, + JSON.parse(key?.integration?.additionalSettings || '[]') ); if (typeof check === 'string') { toaster.show(check, 'warning'); diff --git a/apps/frontend/src/components/launches/helpers/use.values.ts b/apps/frontend/src/components/launches/helpers/use.values.ts index ec8ebf02..8f9d15e5 100644 --- a/apps/frontend/src/components/launches/helpers/use.values.ts +++ b/apps/frontend/src/components/launches/helpers/use.values.ts @@ -24,7 +24,8 @@ const finalInformation = {} as { path: string; }> >, - settings: any + settings: any, + additionalSettings: any, ) => Promise; maximumCharacters?: number; }; @@ -45,7 +46,8 @@ export const useValues = ( path: string; }> >, - settings: any + settings: any, + additionalSettings: any, ) => Promise, maximumCharacters?: number ) => { diff --git a/apps/frontend/src/components/launches/providers/high.order.provider.tsx b/apps/frontend/src/components/launches/providers/high.order.provider.tsx index 532ca44a..83647bc2 100644 --- a/apps/frontend/src/components/launches/providers/high.order.provider.tsx +++ b/apps/frontend/src/components/launches/providers/high.order.provider.tsx @@ -96,7 +96,8 @@ export const withProvider = function ( path: string; }> >, - settings: T + settings: T, + additionalSettings: any, ) => Promise, maximumCharacters?: number | ((settings: any) => number) ) { diff --git a/apps/frontend/src/components/launches/providers/x/x.provider.tsx b/apps/frontend/src/components/launches/providers/x/x.provider.tsx index 28515733..9573fc3a 100644 --- a/apps/frontend/src/components/launches/providers/x/x.provider.tsx +++ b/apps/frontend/src/components/launches/providers/x/x.provider.tsx @@ -61,7 +61,8 @@ export default withProvider( SettingsComponent, undefined, XDto, - async (posts) => { + async (posts, settings, additionalSettings: any) => { + const premium = additionalSettings?.find((p: any) => p?.title === 'Verified')?.value || false; if (posts.some((p) => p.length > 4)) { return 'There can be maximum 4 pictures in a post.'; } @@ -74,7 +75,7 @@ export default withProvider( } for (const load of posts.flatMap((p) => p.flatMap((a) => a.path))) { if (load.indexOf('mp4') > -1) { - const isValid = await checkVideoDuration(load); + const isValid = await checkVideoDuration(load, premium); if (!isValid) { return 'Video duration must be less than or equal to 140 seconds.'; } @@ -89,7 +90,7 @@ export default withProvider( return 280; } ); -const checkVideoDuration = async (url: string): Promise => { +const checkVideoDuration = async (url: string, isPremium = false): Promise => { return new Promise((resolve, reject) => { const video = document.createElement('video'); video.src = url; @@ -97,7 +98,7 @@ const checkVideoDuration = async (url: string): Promise => { video.onloadedmetadata = () => { // Check if the duration is less than or equal to 140 seconds const duration = video.duration; - if (duration <= 140) { + if ((!isPremium && duration <= 140) || isPremium) { resolve(true); // Video duration is acceptable } else { resolve(false); // Video duration exceeds 140 seconds