Skip to content

Commit 59ce547

Browse files
authored
Merge pull request #276 from avinxshKD/fix/ua-sniffing
Refactor: Replace UA sniffing with feature detection
2 parents d007afe + fb62ad6 commit 59ce547

2 files changed

Lines changed: 6 additions & 8 deletions

File tree

src/component/fileBrowser.jsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,10 @@ const LocalFileBrowser = ({ superState, dispatcher }) => {
2020
const [fileState, setFileState] = useState([]);
2121

2222
useEffect(() => {
23-
// if (navigator.userAgent.indexOf('Edg') !== -1 || navigator.userAgent.indexOf('Chrome') !== -1) {
24-
// setDirButton(true);
25-
// }
26-
// Force fallback to webkitdirectory to allow custom popup flow
27-
setDirButton(false);
23+
if ('showDirectoryPicker' in window) {
24+
setDirButton(true);
25+
}
26+
2827
dispatcher({ type: T.SET_FILE_REF, payload: fileRef });
2928
}, []);
3029

src/graph-builder/graph-core/5-load-save.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ class GraphLoadSave extends GraphUndoRedo {
111111
const str = graphmlBuilder(this.jsonifyGraph());
112112
const bytes = new TextEncoder().encode(str);
113113
const blob = new Blob([bytes], { type: 'application/json;charset=utf-8' });
114-
if (navigator.userAgent.indexOf('Edg') !== -1 || navigator.userAgent.indexOf('Chrome') !== -1) {
114+
if ('showSaveFilePicker' in window) {
115115
const options = {
116116
types: [
117117
{
@@ -152,8 +152,7 @@ class GraphLoadSave extends GraphUndoRedo {
152152
}
153153

154154
async saveWithoutFileHandle() {
155-
const { userAgent } = navigator;
156-
if (userAgent.match(/firefox|fxios/i)) {
155+
if (!('showSaveFilePicker' in window)) {
157156
toast.info('Switch to Edge/Chrome!');
158157
return;
159158
}

0 commit comments

Comments
 (0)