Skip to content

πŸ“¨ The ultimate agentic social media scheduling tool πŸ€–

feat: fix duplicate modals

Nevo David700f3c5ccb57
diff --git a/apps/frontend/src/components/launches/calendar.tsx b/apps/frontend/src/components/launches/calendar.tsx
index 0a3879280..92cd9b57c 100644
--- a/apps/frontend/src/components/launches/calendar.tsx
+++ b/apps/frontend/src/components/launches/calendar.tsx
@@ -53,7 +53,6 @@ import { AddEditModal } from '@gitroom/frontend/components/new-launch/add.edit.m
import { deleteDialog } from '@gitroom/react/helpers/delete.dialog';
import { useVariables } from '@gitroom/react/helpers/variable.context';
import { stripHtmlValidation } from '@gitroom/helpers/utils/strip.html.validation';
-import { ModalWrapperComponent } from '../new-launch/modal.wrapper.component';
import { newDayjs } from '@gitroom/frontend/components/layout/set.timezone';
// Extend dayjs with necessary plugins
@@ -464,6 +463,7 @@ export const CalendarColumn: FC<{
? ExistingDataContextProvider
: Fragment;
modal.openModal({
+ id: 'add-edit-modal',
closeOnClickOutside: false,
removeLayout: true,
closeOnEscape: false,
@@ -553,6 +553,7 @@ export const CalendarColumn: FC<{
classNames: {
modal: 'w-[100%] max-w-[1400px] text-textColor',
},
+ id: 'add-edit-modal',
children: (
<AddEditModal
allIntegrations={integrations.map((p) => ({
diff --git a/apps/frontend/src/components/launches/generator/generator.tsx b/apps/frontend/src/components/launches/generator/generator.tsx
index 97a4e0d83..5003407e1 100644
--- a/apps/frontend/src/components/launches/generator/generator.tsx
+++ b/apps/frontend/src/components/launches/generator/generator.tsx
@@ -158,6 +158,7 @@ const FirstStep: FC = (props) => {
classNames: {
modal: 'w-[100%] max-w-[1400px] bg-transparent text-textColor',
},
+ id: 'add-edit-modal',
children: (
<AddEditModal
allIntegrations={integrations.map((p) => ({
diff --git a/apps/frontend/src/components/launches/menu/menu.tsx b/apps/frontend/src/components/launches/menu/menu.tsx
index 836d3575a..55b3b7689 100644
--- a/apps/frontend/src/components/launches/menu/menu.tsx
+++ b/apps/frontend/src/components/launches/menu/menu.tsx
@@ -174,6 +174,7 @@ export const Menu: FC<{
classNames: {
modal: 'w-[100%] max-w-[1400px] bg-transparent text-textColor',
},
+ id: 'add-edit-modal',
children: (
<AddEditModal
allIntegrations={integrations.map((p) => ({
diff --git a/apps/frontend/src/components/launches/new.post.tsx b/apps/frontend/src/components/launches/new.post.tsx
index 457e325ed..2bd3b35bb 100644
--- a/apps/frontend/src/components/launches/new.post.tsx
+++ b/apps/frontend/src/components/launches/new.post.tsx
@@ -56,6 +56,7 @@ export const NewPost = () => {
classNames: {
modal: 'w-[100%] max-w-[1400px] bg-transparent text-textColor',
},
+ id: 'add-edit-modal',
children: (
<AddEditModal
allIntegrations={integrations.map((p) => ({
diff --git a/apps/frontend/src/components/layout/new-modal.tsx b/apps/frontend/src/components/layout/new-modal.tsx
index 96b5c62ec..2e868393b 100644
--- a/apps/frontend/src/components/layout/new-modal.tsx
+++ b/apps/frontend/src/components/layout/new-modal.tsx
@@ -45,13 +45,17 @@ interface State extends ModalManagerStoreInterface {
const useModalStore = create<State>((set) => ({
modalManager: [],
- openModal: (params) =>
+ openModal: (params) => {
+ const newId = params.id || makeId(20);
set((state) => ({
modalManager: [
...state.modalManager,
- { id: params.id || makeId(20), ...params },
+ ...(!state.modalManager.some((p) => p.id === newId)
+ ? [{ id: newId, ...params }]
+ : []),
],
- })),
+ }));
+ },
closeById: (id) =>
set((state) => ({
modalManager: state.modalManager.filter((modal) => modal.id !== id),
diff --git a/apps/frontend/src/components/sets/sets.tsx b/apps/frontend/src/components/sets/sets.tsx
index 0f8e65a08..df07d7e21 100644
--- a/apps/frontend/src/components/sets/sets.tsx
+++ b/apps/frontend/src/components/sets/sets.tsx
@@ -98,6 +98,7 @@ export const Sets: FC = () => {
withCloseButton: false,
removeLayout: true,
askClose: true,
+ id: 'add-edit-modal',
children: (
<AddEditModal
allIntegrations={integrations.map((p: any) => ({