From e89a033592d9e92ee50035210a69c82ed69dd926 Mon Sep 17 00:00:00 2001 From: haithamassoli Date: Wed, 22 Feb 2023 11:16:18 +0300 Subject: [PATCH 1/5] delete unused code --- extension.js | 26 ++------------------------ package.json | 3 +-- 2 files changed, 3 insertions(+), 26 deletions(-) diff --git a/extension.js b/extension.js index add21b9..9947203 100644 --- a/extension.js +++ b/extension.js @@ -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"); @@ -64,14 +44,12 @@ function activate(context) { .then(function (response) { vscode.window.showInformationMessage(response, "X"); }) - .catch((error) => { + .catch(() => { vscode.window.showInformationMessage( "✨ إِنَّ اللَّهَ وَمَلائِكَتَهُ يُصَلُّونَ عَلَى النَّبِيِّ يَا أَيُّهَا الَّذِينَ آمَنُوا صَلُّوا عَلَيْهِ وَسَلِّمُوا تَسْلِيمًا" ); }); }, convertMinutesToMs); - - context.subscriptions.push(disposable); } function deactivate() {} diff --git a/package.json b/package.json index 5120766..2d34fa7 100644 --- a/package.json +++ b/package.json @@ -25,8 +25,7 @@ "Islam" ], "activationEvents": [ - "*", - "onCommand:hadith.getHadith" + "*" ], "main": "./extension.js", "contributes": { From 2bd23b9a4846871ae576523d10b172f08cb92afb Mon Sep 17 00:00:00 2001 From: haithamassoli Date: Wed, 22 Feb 2023 11:18:16 +0300 Subject: [PATCH 2/5] fix repeatedEveryMinute and change it to number --- package.json | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 2d34fa7..fd4fee4 100644 --- a/package.json +++ b/package.json @@ -39,17 +39,18 @@ ], "configuration": { "type": "object", - "title": "Hadith configuration", + "title": "Hadith", "properties": { "hadith.repeatedEveryMinute": { "type": "number", - "default": "1", + "default": 20, "enum": [ - "20", - "30", - "40", - "50", - "60" + 10, + 20, + 30, + 40, + 50, + 60 ], "description": "Select time between Hadith notifications." }, From d6463f14fe526736b068f21854301ec2080b1ffe Mon Sep 17 00:00:00 2001 From: haithamassoli Date: Wed, 22 Feb 2023 11:20:45 +0300 Subject: [PATCH 3/5] 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); From 914689e902d531f2bd575787e0d7ce03942938b9 Mon Sep 17 00:00:00 2001 From: haithamassoli Date: Wed, 22 Feb 2023 11:28:14 +0300 Subject: [PATCH 4/5] fix convertMinutesToMs --- extension.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extension.js b/extension.js index e95a56e..eec3388 100644 --- a/extension.js +++ b/extension.js @@ -51,7 +51,7 @@ function activate() { async (progress) => { progress.report({ increment: 0 }); await new Promise((resolve) => - setTimeout(resolve, convertMinuteToMs) + setTimeout(resolve, convertMinutesToMs) ); progress.report({ increment: 100, message: "Done!" }); } @@ -68,7 +68,7 @@ function activate() { async (progress) => { progress.report({ increment: 0 }); await new Promise((resolve) => - setTimeout(resolve, convertMinuteToMs) + setTimeout(resolve, convertMinutesToMs) ); progress.report({ increment: 100, message: "Done!" }); } From eefd820b524a3c25ededd478c668b84de7308c04 Mon Sep 17 00:00:00 2001 From: haithamassoli Date: Wed, 22 Feb 2023 11:36:56 +0300 Subject: [PATCH 5/5] install axios --- package-lock.json | 146 +++++++++++++++++++++++++++++++++++++++++++++- package.json | 9 ++- 2 files changed, 150 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7e2949f..4e72840 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,15 @@ { "name": "hadith", - "version": "0.0.1", + "version": "0.0.6", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "hadith", - "version": "0.0.1", + "version": "0.0.6", + "dependencies": { + "axios": "^0.27.2" + }, "devDependencies": { "@types/glob": "^8.0.1", "@types/mocha": "^10.0.1", @@ -272,6 +275,20 @@ "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", "dev": true }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" + }, + "node_modules/axios": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.27.2.tgz", + "integrity": "sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==", + "dependencies": { + "follow-redirects": "^1.14.9", + "form-data": "^4.0.0" + } + }, "node_modules/balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", @@ -478,6 +495,17 @@ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "dev": true }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -539,6 +567,14 @@ "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", "dev": true }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "engines": { + "node": ">=0.4.0" + } + }, "node_modules/diff": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz", @@ -855,6 +891,38 @@ "integrity": "sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ==", "dev": true }, + "node_modules/follow-redirects": { + "version": "1.15.2", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", + "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, + "node_modules/form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -1288,6 +1356,25 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, "node_modules/minimatch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", @@ -2284,6 +2371,20 @@ "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", "dev": true }, + "asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" + }, + "axios": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.27.2.tgz", + "integrity": "sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==", + "requires": { + "follow-redirects": "^1.14.9", + "form-data": "^4.0.0" + } + }, "balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", @@ -2439,6 +2540,14 @@ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "dev": true }, + "combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "requires": { + "delayed-stream": "~1.0.0" + } + }, "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -2483,6 +2592,11 @@ "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", "dev": true }, + "delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==" + }, "diff": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz", @@ -2723,6 +2837,21 @@ "integrity": "sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ==", "dev": true }, + "follow-redirects": { + "version": "1.15.2", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", + "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==" + }, + "form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + } + }, "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -3047,6 +3176,19 @@ "is-unicode-supported": "^0.1.0" } }, + "mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==" + }, + "mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "requires": { + "mime-db": "1.52.0" + } + }, "minimatch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", diff --git a/package.json b/package.json index fd4fee4..c76d852 100644 --- a/package.json +++ b/package.json @@ -72,14 +72,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" } }