Skip to content

Commit 29dcd77

Browse files
author
DisboxApp
committed
Add experminetal cross-browser support.
1 parent 676106b commit 29dcd77

5 files changed

Lines changed: 66 additions & 48 deletions

File tree

package-lock.json

Lines changed: 16 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"bootstrap": "^5.1.3",
1717
"fetch-jsonp": "^1.2.1",
1818
"js-sha256": "^0.9.0",
19-
"native-file-system-adapter": "^2.0.1",
19+
"native-file-system-adapter": "^3.0.0",
2020
"react": "^17.0.2",
2121
"react-bootstrap": "^2.1.2",
2222
"react-dom": "^17.0.2",

src/App.js

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ import NavigationBar from './NavigationBar';
1515
import PathParts from './PathParts';
1616
import SearchBar from './SearchBar';
1717
import ThemeSwitch from './ThemeSwitch';
18-
19-
const EXTENSION_URL = "https://chrome.google.com/webstore/detail/disboxdownloader/jklpfhklkhbfgeencifbmkoiaokeieah";
18+
import ExtensionDialog from './ExtensionDialog.js';
2019

2120
const darkTheme = createTheme({
2221
palette: {
@@ -60,20 +59,8 @@ function App() {
6059
const [currentAction, setCurrentAction] = useState("");
6160
const [showProgress, setShowProgress] = useState(false);
6261
const [progressValue, setProgressValue] = useState(-1);
63-
const [showExtensionDialog, setShowExtensionDialog] = useState(false);
64-
6562

6663
useEffect(() => {
67-
try {
68-
chrome.runtime.sendMessage("jklpfhklkhbfgeencifbmkoiaokeieah", { message: {} }, response => {
69-
if (!response || !response.installed) {
70-
setShowExtensionDialog(true);
71-
}
72-
});
73-
} catch {
74-
setShowExtensionDialog(true);
75-
}
76-
7764
const webhookUrl = localStorage.getItem("webhookUrl");
7865
async function init() {
7966
if (webhookUrl) {
@@ -307,23 +294,7 @@ function App() {
307294
<NavigationBar />
308295
<ThemeProvider theme={theme ? darkTheme : lightTheme}>
309296
<CssBaseline />
310-
<Dialog open={showExtensionDialog} onClose={() => { setShowExtensionDialog(false) }}>
311-
<DialogTitle>Warning</DialogTitle>
312-
<DialogContent>
313-
<DialogContentText>
314-
Disbox recommends using the official Disbox chrome extension for
315-
better download speeds and increased security.
316-
</DialogContentText>
317-
</DialogContent>
318-
<DialogActions>
319-
<Button onClick={() => { setShowExtensionDialog(false) }}>Remind me later</Button>
320-
<Button variant="contained" onClick={() => {
321-
setShowExtensionDialog(false);
322-
window.open(EXTENSION_URL, "_blank").focus();
323-
}} >Install</Button>
324-
</DialogActions>
325-
</Dialog>
326-
297+
<ExtensionDialog/>
327298
<Snackbar
328299
message=""
329300
anchorOrigin={{ vertical: 'bottom', horizontal: 'right', }}
@@ -391,7 +362,7 @@ function App() {
391362
showColumnRightBorder={false}
392363
onCellEditCommit={onCellEditCommit}
393364
onCellDoubleClick={onCellDoubleClick}
394-
/>
365+
/>
395366
</div>
396367
</div>
397368
</ThemeProvider>

src/ExtensionDialog.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*global chrome*/
2+
import React, { useEffect, useState } from 'react';
3+
4+
import { Button, Dialog, DialogActions, DialogContent, DialogContentText, DialogTitle } from '@mui/material';
5+
6+
const EXTENSION_URL = "https://chrome.google.com/webstore/detail/disboxdownloader/jklpfhklkhbfgeencifbmkoiaokeieah";
7+
8+
var isChrome = /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor);
9+
10+
11+
export default function ExtensionDialog() {
12+
const [showExtensionDialog, setShowExtensionDialog] = useState(false);
13+
14+
useEffect(() => {
15+
try {
16+
chrome.runtime.sendMessage("jklpfhklkhbfgeencifbmkoiaokeieah", { message: {} }, response => {
17+
if (!response || !response.installed) {
18+
setShowExtensionDialog(true);
19+
}
20+
});
21+
} catch {
22+
setShowExtensionDialog(true);
23+
}
24+
}, []);
25+
26+
return (<Dialog open={showExtensionDialog} onClose={() => { setShowExtensionDialog(false) }}>
27+
<DialogTitle>Downloads may be slow</DialogTitle>
28+
<DialogContent>
29+
<DialogContentText>
30+
Disbox recommends using {!isChrome && "Google Chrome with"} the official Disbox Chrome extension for
31+
better download speeds and increased security.
32+
</DialogContentText>
33+
</DialogContent>
34+
<DialogActions>
35+
<Button onClick={() => { setShowExtensionDialog(false) }}>Remind me later</Button>
36+
<Button variant="contained" onClick={() => {
37+
setShowExtensionDialog(false);
38+
window.open(EXTENSION_URL, "_blank").focus();
39+
}} >Install</Button>
40+
</DialogActions>
41+
</Dialog>
42+
);
43+
}

src/file-utils.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import * as mime from 'react-native-mime-types';
22
import { FILE_DELIMITER } from "./disbox-file-manager";
3+
import { showSaveFilePicker } from "native-file-system-adapter";
4+
35

46
export function getMimeType(name) {
57
return mime.lookup(name) || 'application/octet-stream';
@@ -17,7 +19,7 @@ export async function pickLocationAsWritable(suggestedName) {
1719
accept: {[mimeType]: [extension] }
1820
}]
1921
}
20-
const fileHandler = await window.showSaveFilePicker(pickerConfig);
22+
const fileHandler = await showSaveFilePicker(pickerConfig);
2123
return await (await fileHandler.createWritable()).getWriter();
2224
}
2325

0 commit comments

Comments
 (0)