Skip to content

Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.

voice navigation - navigator permissions

DanielŻuławski64a9860aa997
diff --git a/src/Web/Grand.Web/Views/Shared/Components/SearchBox/Default.cshtml b/src/Web/Grand.Web/Views/Shared/Components/SearchBox/Default.cshtml
index 7efac7137..2a1c7e457 100644
--- a/src/Web/Grand.Web/Views/Shared/Components/SearchBox/Default.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/Components/SearchBox/Default.cshtml
@@ -139,11 +139,8 @@
this.recognition.stop();
},
allowCheck() {
- var isSafari = navigator.vendor && navigator.vendor.indexOf('Apple') > -1 &&
- navigator.userAgent &&
- navigator.userAgent.indexOf('CriOS') == -1 &&
- navigator.userAgent.indexOf('FxiOS') == -1;
- if (!isSafari) {
+ var checkPermission = navigator.permissions
+ if (checkPermission) {
navigator.permissions.query(
{ name: 'microphone' }
).then(function (permissionStatus) {
@@ -161,15 +158,7 @@
searchbox.allowed = true;
}
}
- });
- } else {
- if (navigator.mediaDevices != undefined) {
- navigator.mediaDevices.getUserMedia({ audio: true }).then(function (stream) {
- searchbox.allowed = true;
- }).catch(function (err) {
- searchbox.allowed = false;
- })
- }
+ })
}
},
autocompleteVue() {
diff --git a/src/Web/Grand.Web/Views/Shared/Components/VoiceNavigation/Default.cshtml b/src/Web/Grand.Web/Views/Shared/Components/VoiceNavigation/Default.cshtml
index 8973c993b..10ee5a79f 100644
--- a/src/Web/Grand.Web/Views/Shared/Components/VoiceNavigation/Default.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/Components/VoiceNavigation/Default.cshtml
@@ -92,11 +92,8 @@
this.recognition.stop();
},
allowCheck() {
- var isSafari = navigator.vendor && navigator.vendor.indexOf('Apple') > -1 &&
- navigator.userAgent &&
- navigator.userAgent.indexOf('CriOS') == -1 &&
- navigator.userAgent.indexOf('FxiOS') == -1;
- if (!isSafari) {
+ var checkPermission = navigator.permissions
+ if (checkPermission) {
navigator.permissions.query(
{ name: 'microphone' }
).then(function (permissionStatus) {
@@ -114,15 +111,7 @@
voicenavigator.allowed = true;
}
}
- });
- } else {
- if (navigator.mediaDevices != undefined) {
- navigator.mediaDevices.getUserMedia({ audio: true }).then(function (stream) {
- voicenavigator.allowed = true;
- }).catch(function (err) {
- voicenavigator.allowed = false;
- })
- }
+ })
}
}
},