Skip to content

🎥 Make videos programmatically with React

yes this makes much more sense

Jonny Burgerce2e851a80d4
diff --git a/packages/studio/src/components/CompositionSelectorItem.tsx b/packages/studio/src/components/CompositionSelectorItem.tsx
index 5d20e0e99e..564dcac898 100644
--- a/packages/studio/src/components/CompositionSelectorItem.tsx
+++ b/packages/studio/src/components/CompositionSelectorItem.tsx
@@ -139,24 +139,33 @@ export const CompositionSelectorItem: React.FC<{
if (item.type === 'composition') {
return [
{
- id: '1',
+ id: 'duplicate',
keyHint: null,
- label: `Copy ID`,
+ label: `Duplicate composition...`,
leftItem: null,
onClick: () => {
- navigator.clipboard
- .writeText(item.composition.id)
- .catch((err) => {
+ applyCodemod({
+ codemod: {
+ type: 'duplicate-composition',
+ idToDuplicate: item.composition.id,
+ newId: `new-${item.composition.id}`,
+ },
+ })
+ .then((res) => {
+ if (!res.success) {
+ throw new Error(res.reason);
+ }
+
notificationCenter.current?.addNotification({
- content: `Could not copy to clipboard: ${err.message}`,
+ content: `Deleted ${item.composition.id}`,
created: Date.now(),
duration: 1000,
id: String(Math.random()),
});
})
- .then(() => {
+ .catch((err) => {
notificationCenter.current?.addNotification({
- content: 'Copied to clipboard',
+ content: `Could not delete composition: ${err.message}`,
created: Date.now(),
duration: 1000,
id: String(Math.random()),
@@ -168,17 +177,17 @@ export const CompositionSelectorItem: React.FC<{
type: 'item',
value: 'remove',
},
+
{
- id: '2',
+ id: 'delete',
keyHint: null,
- label: `Duplicate composition`,
+ label: `Delete composition`,
leftItem: null,
onClick: () => {
applyCodemod({
codemod: {
- type: 'duplicate-composition',
- idToDuplicate: item.composition.id,
- newId: `new-${item.composition.id}`,
+ type: 'delete-composition',
+ idToDelete: item.composition.id,
},
})
.then((res) => {
@@ -208,32 +217,28 @@ export const CompositionSelectorItem: React.FC<{
value: 'remove',
},
{
- id: '3',
+ type: 'divider',
+ id: 'copy-id-divider',
+ },
+ {
+ id: 'copy-id',
keyHint: null,
- label: `Delete composition`,
+ label: `Copy ID`,
leftItem: null,
onClick: () => {
- applyCodemod({
- codemod: {
- type: 'delete-composition',
- idToDelete: item.composition.id,
- },
- })
- .then((res) => {
- if (!res.success) {
- throw new Error(res.reason);
- }
-
+ navigator.clipboard
+ .writeText(item.composition.id)
+ .catch((err) => {
notificationCenter.current?.addNotification({
- content: `Deleted ${item.composition.id}`,
+ content: `Could not copy to clipboard: ${err.message}`,
created: Date.now(),
duration: 1000,
id: String(Math.random()),
});
})
- .catch((err) => {
+ .then(() => {
notificationCenter.current?.addNotification({
- content: `Could not delete composition: ${err.message}`,
+ content: 'Copied to clipboard',
created: Date.now(),
duration: 1000,
id: String(Math.random()),