Skip to content

Commit 5d23751

Browse files
committed
Fix file download on mobile
1 parent 74d8414 commit 5d23751

File tree

5 files changed

+9
-13
lines changed

5 files changed

+9
-13
lines changed

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "obsidian-read-it-later",
33
"name": "ReadItLater",
4-
"version": "0.0.13",
4+
"version": "0.0.14",
55
"minAppVersion": "0.9.12",
66
"description": "Saves the clipboard to a new notice.",
77
"author": "Dominik Pieper",

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "obsidian-sample-plugin",
3-
"version": "0.0.13",
3+
"version": "0.0.14",
44
"description": "This is a sample plugin for Obsidian (https://obsidian.md)",
55
"main": "main.js",
66
"scripts": {
@@ -34,8 +34,6 @@
3434
"@mozilla/readability": "^0.4.2",
3535
"@rollup/plugin-json": "^4.1.0",
3636
"@types/mime-types": "^2.1.1",
37-
"got": "^11.8.2",
38-
"mime-types": "^2.1.34",
3937
"spark-md5": "^3.0.2",
4038
"turndown": "^7.1.1"
4139
}

src/helpers/downloadImage.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
import got from 'got';
2-
import { extension } from 'mime-types';
3-
41
export async function downloadImage(url: string): Promise<{ fileContent: ArrayBuffer; fileExtension: string | false }> {
5-
const res = await got(url, { responseType: 'buffer' });
2+
const res = await fetch(url);
63

74
return {
8-
fileContent: res.body,
9-
fileExtension: extension(res.headers['content-type']),
5+
fileContent: await res.arrayBuffer(),
6+
fileExtension: url.slice(url.lastIndexOf('.')),
107
};
118
}

src/parsers/WebsiteParser.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Parser } from './Parser';
22
import { Note } from './Note';
3-
import { App, Notice, request } from 'obsidian';
3+
import { App, Notice, Platform, request } from 'obsidian';
44
import { getBaseUrl, replaceImages } from '../helpers';
55
import { isProbablyReaderable, Readability } from '@mozilla/readability';
66
import { ReadItLaterSettings } from '../settings';
@@ -45,7 +45,8 @@ class WebsiteParser extends Parser {
4545
private async parsableArticle(app: App, article: Article, url: string) {
4646
const title = article.title || 'No title';
4747
let content = await parseHtmlContent(article.content);
48-
if (this.settings.downloadImages) {
48+
49+
if (this.settings.downloadImages && Platform.isDesktop) {
4950
content = await replaceImages(app, content, this.settings.assetsDir);
5051
}
5152

src/views/settings-tab.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export class ReadItLaterSettingsTab extends PluginSettingTab {
4646

4747
new Setting(containerEl)
4848
.setName('Download images')
49-
.setDesc('If this is true, the used images are downloaded to the defined folder')
49+
.setDesc('If this is true, the used images are downloaded to the defined folder (just on Desktop)')
5050
.addToggle((toggle) =>
5151
toggle
5252
.setValue(this.plugin.settings.downloadImages || DEFAULT_SETTINGS.downloadImages)

0 commit comments

Comments
 (0)