Skip to content

Commit

Permalink
fix(web/editor): OAuth Account connection polling
Browse files Browse the repository at this point in the history
  • Loading branch information
RezaRahemtola committed Oct 9, 2023
1 parent 1a0f08f commit d5617bd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
2 changes: 2 additions & 0 deletions backend/back/src/workflows/workflows.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ export class WorkflowsService {
isAction ? "Action" : "Reaction"
} ${areaId} with service ${areaServiceId} not found for workflow area ${id}.`,
);
// TODO Dorian: Clean this
let serviceUserConnection: {
scopes: any[];
} = await queryRunner.manager.findOne(UserConnection, {
Expand All @@ -323,6 +324,7 @@ export class WorkflowsService {
scopes: true,
},
});
// TODO Dorian: Remove next line
if (!serviceUserConnection && areaServiceId === "timer") serviceUserConnection = { scopes: [] };
if (!serviceUserConnection) throw new NotFoundException(`User connection for ${areaServiceId} not found.`);
const scopeIds = serviceUserConnection.scopes.map(({ id }) => id);
Expand Down
21 changes: 10 additions & 11 deletions frontend/web/layouts/editor/EditorSelectEventAndAccount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,27 +42,26 @@ const EditorSelectEventAndAccount = ({
}, [selectedEventId]);

useEffect(() => {
if (!accountConnectionInProgress) return () => {};
const accountConnectionCheck = setInterval(() => {
(async () => {
if (accountConnectionInProgress) {
const chosenArea = areaChoices.find((area) => area.id === selectedEventId)!;
const connectService = await services.connections.connect(
workflowArea.areaService!.id,
chosenArea.serviceScopesNeeded,
);
const chosenArea = areaChoices.find((area) => area.id === selectedEventId)!;
const connectService = await services.connections.connect(
workflowArea.areaService!.id,
chosenArea.serviceScopesNeeded,
);

if (connectService.data && connectService.data.oauthUrl === null) {
setConnectAccountUrl(null);
setAccountConnectionInProgress(false);
}
if (connectService.data && connectService.data.oauthUrl === null) {
setConnectAccountUrl(null);
setAccountConnectionInProgress(false);
}
})();
}, 1000);

return () => {
clearInterval(accountConnectionCheck);
};
}, []);
}, [accountConnectionInProgress]);

return (
<EditorStepCardWrapper title={title} actions={actions}>
Expand Down

0 comments on commit d5617bd

Please sign in to comment.