mirror of
https://github.com/finos/SymphonyElectron.git
synced 2025-02-25 18:55:29 -06:00
SDA-4675 - Debounce hide notification (#2205)
* SDA-4675 - Debounce hide notification * SDA-4675 - Add sequential function queue for showing notification * SDA-4675 - Add delay for notification position animation * SDA-4675 - Remove move top * SDA-4675 - Revert delay
This commit is contained in:
parent
c8508aa2ca
commit
d702a5580e
64
package-lock.json
generated
64
package-lock.json
generated
@ -27,6 +27,7 @@
|
||||
"shell-path": "^3.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@electron/fuses": "^1.8.0",
|
||||
"@types/cheerio": "^0.22.22",
|
||||
"@types/enzyme": "^3.10.7",
|
||||
"@types/fs-extra": "^9.0.0",
|
||||
@ -1330,6 +1331,69 @@
|
||||
"node": ">= 6"
|
||||
}
|
||||
},
|
||||
"node_modules/@electron/fuses": {
|
||||
"version": "1.8.0",
|
||||
"resolved": "https://repo.symphony.com/artifactory/api/npm/npm-virtual-dev/@electron/fuses/-/fuses-1.8.0.tgz",
|
||||
"integrity": "sha512-zx0EIq78WlY/lBb1uXlziZmDZI4ubcCXIMJ4uGjXzZW0nS19TjSPeXPAjzzTmKQlJUZm0SbmZhPKP7tuQ1SsEw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"chalk": "^4.1.1",
|
||||
"fs-extra": "^9.0.1",
|
||||
"minimist": "^1.2.5"
|
||||
},
|
||||
"bin": {
|
||||
"electron-fuses": "dist/bin.js"
|
||||
}
|
||||
},
|
||||
"node_modules/@electron/fuses/node_modules/chalk": {
|
||||
"version": "4.1.2",
|
||||
"resolved": "https://repo.symphony.com/artifactory/api/npm/npm-virtual-dev/chalk/-/chalk-4.1.2.tgz",
|
||||
"integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"ansi-styles": "^4.1.0",
|
||||
"supports-color": "^7.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/@electron/fuses/node_modules/fs-extra": {
|
||||
"version": "9.1.0",
|
||||
"resolved": "https://repo.symphony.com/artifactory/api/npm/npm-virtual-dev/fs-extra/-/fs-extra-9.1.0.tgz",
|
||||
"integrity": "sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"at-least-node": "^1.0.0",
|
||||
"graceful-fs": "^4.2.0",
|
||||
"jsonfile": "^6.0.1",
|
||||
"universalify": "^2.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/@electron/fuses/node_modules/jsonfile": {
|
||||
"version": "6.1.0",
|
||||
"resolved": "https://repo.symphony.com/artifactory/api/npm/npm-virtual-dev/jsonfile/-/jsonfile-6.1.0.tgz",
|
||||
"integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"universalify": "^2.0.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"graceful-fs": "^4.1.6"
|
||||
}
|
||||
},
|
||||
"node_modules/@electron/fuses/node_modules/universalify": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://repo.symphony.com/artifactory/api/npm/npm-virtual-dev/universalify/-/universalify-2.0.1.tgz",
|
||||
"integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@electron/get": {
|
||||
"version": "2.0.2",
|
||||
"dev": true,
|
||||
|
@ -70,7 +70,6 @@ export default class NotificationHandler {
|
||||
if (window && !window.isDestroyed()) {
|
||||
try {
|
||||
window.setPosition(parseInt(String(x), 10), parseInt(String(y), 10));
|
||||
window.moveTop();
|
||||
} catch (err) {
|
||||
console.warn(
|
||||
`Failed to set window position. x: ${x} y: ${y}. Contact the developers for more details`,
|
||||
@ -429,26 +428,29 @@ export default class NotificationHandler {
|
||||
newX: number,
|
||||
) {
|
||||
const [startX, startY] = notificationWindow.getPosition();
|
||||
const stepY = (newY - startY) / this.settings.animationSteps;
|
||||
const stepX = (newX - startX) / this.settings.animationSteps;
|
||||
const duration = this.settings.animationSteps;
|
||||
const startTime = Date.now();
|
||||
|
||||
let curStep = 1;
|
||||
const animationInterval = setInterval(() => {
|
||||
// Abort condition
|
||||
if (curStep === this.settings.animationSteps) {
|
||||
const animateStep = () => {
|
||||
const elapsed = Date.now() - startTime;
|
||||
const progress = Math.min(elapsed / duration, 1);
|
||||
|
||||
const currentX = startX + (newX - startX) * progress;
|
||||
const currentY = startY + (newY - startY) * progress;
|
||||
|
||||
// Set new position
|
||||
this.setWindowPosition(notificationWindow, currentX, currentY);
|
||||
|
||||
if (progress < 1) {
|
||||
setTimeout(animateStep, 16);
|
||||
} else {
|
||||
// Ensure final position is set
|
||||
this.setWindowPosition(notificationWindow, newX, newY);
|
||||
clearInterval(animationInterval);
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
// Move one step in both x and y directions
|
||||
this.setWindowPosition(
|
||||
notificationWindow,
|
||||
startX + curStep * stepX,
|
||||
startY + curStep * stepY,
|
||||
);
|
||||
curStep++;
|
||||
}, this.settings.animationStepMs);
|
||||
// Start the animation
|
||||
setTimeout(animateStep, 16);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -255,8 +255,6 @@ class Notification extends NotificationHandler {
|
||||
notificationSettings.height,
|
||||
true,
|
||||
);
|
||||
// Move notification to top
|
||||
notificationWindow.moveTop();
|
||||
|
||||
if (!data.sticky) {
|
||||
timeoutId = setTimeout(async () => {
|
||||
@ -590,7 +588,6 @@ class Notification extends NotificationHandler {
|
||||
windowId: notificationWindow.id,
|
||||
});
|
||||
this.activeNotifications.push(notificationWindow);
|
||||
notificationWindow.moveTop();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user