Skip to content

Commit

Permalink
Patched toasts (#112)
Browse files Browse the repository at this point in the history
  • Loading branch information
CalebGerman authored Jul 10, 2024
1 parent d1e035e commit 1bf096f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
6 changes: 6 additions & 0 deletions packages/changed-elements-react/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this package will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased](https://github.com/iTwin/changed-elements-react/tree/HEAD/packages/changed-elements-react)

## Fixes

* `VersionCompareSelectModal` V2 toast now fixed when opening and closing modal.

## [0.8.0](https://github.com/iTwin/changed-elements-react/tree/v0.8.0/packages/changed-elements-react) - 2024-06-28

## Minor changes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export function VersionCompareSelectDialogV2(props: VersionCompareSelectDialogV2
const [targetVersion, setTargetVersion] = useState<NamedVersion | undefined>(undefined);
const [currentVersion, setCurrentVersion] = useState<NamedVersion | undefined>(undefined);
const [result, setResult] = useState<NamedVersionLoaderState>();
const { isLoading }= useNamedVersionLoader(props.iModelConnection, iModelsClient, comparisonJobClient, setResult, getPendingJobs);
const { isLoading } = useNamedVersionLoader(props.iModelConnection, iModelsClient, comparisonJobClient, setResult, getPendingJobs);
useEffect(() => {
let isDisposed = false;
const getIsDisposed = () => {
Expand Down Expand Up @@ -91,7 +91,7 @@ export function VersionCompareSelectDialogV2(props: VersionCompareSelectDialogV2
isDisposed = true;
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [result]);
}, [isLoading]);
const _handleOk = async (): Promise<void> => {
if (comparisonJobClient && result?.namedVersions && targetVersion && currentVersion) {
const getIsDisposed = () => true;
Expand Down Expand Up @@ -151,6 +151,7 @@ export function VersionCompareSelectDialogV2(props: VersionCompareSelectDialogV2

const _handleCancel = (): void => {
props.onClose?.();
closedDialog();
VersionCompareUtils.outputVerbose(VersionCompareVerboseMessages.selectDialogClosed);
};

Expand Down Expand Up @@ -327,7 +328,7 @@ const pollUntilCurrentRunningJobsCompleteAndToast = async (args: PollForInProgre
let isConnectionClosed = false;
args.iModelConnection.onClose.addListener(() => { isConnectionClosed = true; });
const loopDelayInMilliseconds = 5000;
while (shouldProcessRunningJobs({ getDialogOpen: args.getDialogOpen, getRunningJobs: args.getRunningJobs, isConnectionClosed })) {
while (shouldProcessRunningJobs({ getRunningJobs: args.getRunningJobs, isConnectionClosed })) {
await new Promise((resolve) => setTimeout(resolve, loopDelayInMilliseconds));
for (const runningJob of args.getRunningJobs()) {
try {
Expand Down Expand Up @@ -364,11 +365,10 @@ const pollUntilCurrentRunningJobsCompleteAndToast = async (args: PollForInProgre
type ShouldProcessRunningJobArgs = {
isConnectionClosed: boolean;
getRunningJobs: () => JobAndNamedVersions[];
getDialogOpen: () => boolean;
};

const shouldProcessRunningJobs = (args: ShouldProcessRunningJobArgs) => {
return !args.getDialogOpen() && args.getRunningJobs().length > 0 && !args.isConnectionClosed;
return args.getRunningJobs().length > 0 && !args.isConnectionClosed;
};

type ConditionallyToastCompletionArgs = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ class MainFrontstageItemsProvider implements UiItemsProvider {
content: <ChangedElementsWidget useV2Widget
feedbackUrl="https://example.com"
iModelConnection={UiFramework.getIModelConnection()!}
enableComparisonJobUpdateToasts
manageNamedVersionsSlot={<ManageNamedVersions />}
/>,
}];
Expand Down

0 comments on commit 1bf096f

Please sign in to comment.