Skip to content

Commit 646caf5

Browse files
committed
fix: X premium to upload longer videos
1 parent cde4e25 commit 646caf5

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

apps/frontend/src/components/launches/add.edit.model.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,8 @@ export const AddEditModal: FC<{
413413
if (key.checkValidity) {
414414
const check = await key.checkValidity(
415415
key?.value.map((p: any) => p.image || []),
416-
key.settings
416+
key.settings,
417+
JSON.parse(key?.integration?.additionalSettings || '[]')
417418
);
418419
if (typeof check === 'string') {
419420
toaster.show(check, 'warning');

apps/frontend/src/components/launches/helpers/use.values.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ const finalInformation = {} as {
2424
path: string;
2525
}>
2626
>,
27-
settings: any
27+
settings: any,
28+
additionalSettings: any,
2829
) => Promise<string | true>;
2930
maximumCharacters?: number;
3031
};
@@ -45,7 +46,8 @@ export const useValues = (
4546
path: string;
4647
}>
4748
>,
48-
settings: any
49+
settings: any,
50+
additionalSettings: any,
4951
) => Promise<string | true>,
5052
maximumCharacters?: number
5153
) => {

apps/frontend/src/components/launches/providers/high.order.provider.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ export const withProvider = function <T extends object>(
9696
path: string;
9797
}>
9898
>,
99-
settings: T
99+
settings: T,
100+
additionalSettings: any,
100101
) => Promise<string | true>,
101102
maximumCharacters?: number | ((settings: any) => number)
102103
) {

apps/frontend/src/components/launches/providers/x/x.provider.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ export default withProvider(
6161
SettingsComponent,
6262
undefined,
6363
XDto,
64-
async (posts) => {
64+
async (posts, settings, additionalSettings: any) => {
65+
const premium = additionalSettings?.find((p: any) => p?.title === 'Verified')?.value || false;
6566
if (posts.some((p) => p.length > 4)) {
6667
return 'There can be maximum 4 pictures in a post.';
6768
}
@@ -74,7 +75,7 @@ export default withProvider(
7475
}
7576
for (const load of posts.flatMap((p) => p.flatMap((a) => a.path))) {
7677
if (load.indexOf('mp4') > -1) {
77-
const isValid = await checkVideoDuration(load);
78+
const isValid = await checkVideoDuration(load, premium);
7879
if (!isValid) {
7980
return 'Video duration must be less than or equal to 140 seconds.';
8081
}
@@ -89,15 +90,15 @@ export default withProvider(
8990
return 280;
9091
}
9192
);
92-
const checkVideoDuration = async (url: string): Promise<boolean> => {
93+
const checkVideoDuration = async (url: string, isPremium = false): Promise<boolean> => {
9394
return new Promise((resolve, reject) => {
9495
const video = document.createElement('video');
9596
video.src = url;
9697
video.preload = 'metadata';
9798
video.onloadedmetadata = () => {
9899
// Check if the duration is less than or equal to 140 seconds
99100
const duration = video.duration;
100-
if (duration <= 140) {
101+
if ((!isPremium && duration <= 140) || isPremium) {
101102
resolve(true); // Video duration is acceptable
102103
} else {
103104
resolve(false); // Video duration exceeds 140 seconds

0 commit comments

Comments
 (0)