Skip to content

Commit 3c37276

Browse files
committed
Revert "uploadOnce doesn't work on macOS"
This reverts commit ba55f57.
1 parent 18ea072 commit 3c37276

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

src/main/index.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ import { hostname, userInfo } from "os";
2020
import PQueue from "p-queue";
2121
import { basename, extname, resolve } from "path";
2222
import { pathToFileURL } from "url";
23+
2324
import { Watch, WatchV2, toWatchlistV2 } from "../watch-list";
25+
import { getUploadOnceAvailable } from "./platform";
2426

2527
(async () => {
2628
if (process.env.npm_lifecycle_event !== "start") {
@@ -99,6 +101,9 @@ import { Watch, WatchV2, toWatchlistV2 } from "../watch-list";
99101
},
100102
{ role: "quit" },
101103
{ type: "separator" },
104+
...(getUploadOnceAvailable() && gyazoAccessToken
105+
? [{ label: "Upload", click: uploadOnce }]
106+
: []),
102107
...(queueLength
103108
? [
104109
{
@@ -165,6 +170,15 @@ import { Watch, WatchV2, toWatchlistV2 } from "../watch-list";
165170
});
166171
};
167172

173+
const uploadOnce = async () => {
174+
const { filePaths } = await dialog.showOpenDialog({
175+
properties: ["openFile", "multiSelections"],
176+
});
177+
for (const filePath of filePaths) {
178+
receive({ path: filePath, opensNewTab: false, checksFileID: false });
179+
}
180+
};
181+
168182
const receive = async (event: WatchV2 & { checksFileID: boolean }) => {
169183
const ext = extname(event.path);
170184
switch (ext) {

src/main/platform.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
export const getUploadOnceAvailable = () => {
2+
switch (process.platform) {
3+
case "aix":
4+
case "android":
5+
case "freebsd":
6+
case "haiku":
7+
case "linux":
8+
case "openbsd":
9+
case "sunos":
10+
case "win32":
11+
case "cygwin":
12+
case "netbsd": {
13+
return true;
14+
}
15+
16+
case "darwin": {
17+
return false;
18+
}
19+
20+
default: {
21+
throw new Error(`Unknown platform: ${process.platform satisfies never}`);
22+
}
23+
}
24+
};

0 commit comments

Comments
 (0)