From d6463f14fe526736b068f21854301ec2080b1ffe Mon Sep 17 00:00:00 2001 From: haithamassoli Date: Wed, 22 Feb 2023 11:20:45 +0300 Subject: [PATCH] Messages overflow automatically Dismissed withProgress --- extension.js | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/extension.js b/extension.js index 9947203..e95a56e 100644 --- a/extension.js +++ b/extension.js @@ -42,11 +42,36 @@ function activate() { setInterval(async function () { getRandomHadith() .then(function (response) { - vscode.window.showInformationMessage(response, "X"); + vscode.window.withProgress( + { + location: vscode.ProgressLocation.Notification, + title: response, + cancellable: true, + }, + async (progress) => { + progress.report({ increment: 0 }); + await new Promise((resolve) => + setTimeout(resolve, convertMinuteToMs) + ); + progress.report({ increment: 100, message: "Done!" }); + } + ); }) .catch(() => { - vscode.window.showInformationMessage( - "✨ إِنَّ اللَّهَ وَمَلائِكَتَهُ يُصَلُّونَ عَلَى النَّبِيِّ يَا أَيُّهَا الَّذِينَ آمَنُوا صَلُّوا عَلَيْهِ وَسَلِّمُوا تَسْلِيمًا" + vscode.window.withProgress( + { + location: vscode.ProgressLocation.Notification, + title: + "✨ إِنَّ اللَّهَ وَمَلائِكَتَهُ يُصَلُّونَ عَلَى النَّبِيِّ يَا أَيُّهَا الَّذِينَ آمَنُوا صَلُّوا عَلَيْهِ وَسَلِّمُوا تَسْلِيمًا", + cancellable: true, + }, + async (progress) => { + progress.report({ increment: 0 }); + await new Promise((resolve) => + setTimeout(resolve, convertMinuteToMs) + ); + progress.report({ increment: 100, message: "Done!" }); + } ); }); }, convertMinutesToMs);