Skip to content

Commit

Permalink
Merge pull request #3 from haithamassoli/main
Browse files Browse the repository at this point in the history
features-fixes/Messages overflow automatically Dismissed/added more repeated Every Minute/Axios
  • Loading branch information
SABER-MOHAMED authored Feb 23, 2023
2 parents fe11cb6 + bd19d87 commit 5332f3e
Show file tree
Hide file tree
Showing 3 changed files with 189 additions and 41 deletions.
57 changes: 30 additions & 27 deletions extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,7 @@ const getRandomHadith = async () => {
return hadith;
};

/**
* @param {vscode.ExtensionContext} context
*/

function activate(context) {
let disposable = vscode.commands.registerCommand(
"hadith.getHadith",
async function () {
getRandomHadith()
.then(function (response) {
vscode.window.showInformationMessage(response);
})
.catch((error) => {
console.log("error11: ", error);
vscode.window.showInformationMessage(
"✨ إِنَّ اللَّهَ وَمَلائِكَتَهُ يُصَلُّونَ عَلَى النَّبِيِّ يَا أَيُّهَا الَّذِينَ آمَنُوا صَلُّوا عَلَيْهِ وَسَلِّمُوا تَسْلِيمًا"
);
});
}
);

function activate() {
const repeatedEveryMinute = vscode.workspace
.getConfiguration("hadith")
.get("repeatedEveryMinute");
Expand All @@ -62,16 +42,39 @@ function activate(context) {
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, convertMinutesToMs)
);
progress.report({ increment: 100, message: "Done!" });
}
);
})
.catch((error) => {
vscode.window.showInformationMessage(
"✨ إِنَّ اللَّهَ وَمَلائِكَتَهُ يُصَلُّونَ عَلَى النَّبِيِّ يَا أَيُّهَا الَّذِينَ آمَنُوا صَلُّوا عَلَيْهِ وَسَلِّمُوا تَسْلِيمًا"
.catch(() => {
vscode.window.withProgress(
{
location: vscode.ProgressLocation.Notification,
title:
"✨ إِنَّ اللَّهَ وَمَلائِكَتَهُ يُصَلُّونَ عَلَى النَّبِيِّ يَا أَيُّهَا الَّذِينَ آمَنُوا صَلُّوا عَلَيْهِ وَسَلِّمُوا تَسْلِيمًا",
cancellable: true,
},
async (progress) => {
progress.report({ increment: 0 });
await new Promise((resolve) =>
setTimeout(resolve, convertMinutesToMs)
);
progress.report({ increment: 100, message: "Done!" });
}
);
});
}, convertMinutesToMs);

context.subscriptions.push(disposable);
}

function deactivate() {}
Expand Down
146 changes: 144 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 15 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "hadith",
"displayName": "Hadith",
"description": "Get a Hadith from the Sunnah while you're coding 💻 keep in touch with the Sayings and Teachings of the Prophet Muhammed (ﷺ) 🕌💚",
"version": "0.1.2",
"version": "0.1.3",
"license": "MIT",
"icon": "images/icon.png",
"repository": {
Expand Down Expand Up @@ -44,18 +44,18 @@
],
"configuration": {
"type": "object",
"title": "Hadith configuration",
"title": "Hadith",
"properties": {
"hadith.repeatedEveryMinute": {
"type": "number",
"default": "20",
"default": 20,
"enum": [
"10",
"20",
"30",
"40",
"50",
"60"
10,
20,
30,
40,
50,
60
],
"description": "Select time between Hadith notifications."
},
Expand All @@ -77,14 +77,17 @@
"test": "node ./test/runTest.js"
},
"devDependencies": {
"@types/vscode": "^1.75.0",
"@types/glob": "^8.0.1",
"@types/mocha": "^10.0.1",
"@types/node": "16.x",
"@types/vscode": "^1.75.0",
"@vscode/test-electron": "^2.2.2",
"eslint": "^8.33.0",
"glob": "^8.1.0",
"mocha": "^10.1.0",
"typescript": "^4.9.4",
"@vscode/test-electron": "^2.2.2"
"typescript": "^4.9.4"
},
"dependencies": {
"axios": "^0.27.2"
}
}

0 comments on commit 5332f3e

Please sign in to comment.