Skip to content

Commit 2a68c9f

Browse files
committed
fix mobile license issue
1 parent 618ae89 commit 2a68c9f

File tree

5 files changed

+29
-25
lines changed

5 files changed

+29
-25
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": "mdfriday",
33
"name": "Friday",
4-
"version": "26.1.2",
4+
"version": "26.1.3",
55
"minAppVersion": "0.15.0",
66
"description": "Notes to Website. Friday helps you turn Markdown documents into websites in minutes.",
77
"author": "sunwei",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "obsidian-friday-plugin",
3-
"version": "26.1.2",
3+
"version": "26.1.3",
44
"description": "Friday is an Obsidian plugin that empowers users to focus on content creation by writing Markdown files, while we handle the distribution. From creating websites to content deployment, Friday serves as a creative output assistant, helping users turn their work into publishable sites with ease.",
55
"main": "main.js",
66
"type": "module",

src/hugoverse.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import {App, FileSystemAdapter, Notice, requestUrl, TFile, TFolder, Vault} from "obsidian";
1+
import {App, FileSystemAdapter, Notice, Platform, requestUrl, TFile, TFolder, Vault} from "obsidian";
22
import type {RequestUrlResponse} from "obsidian";
33
import type {User} from "./user";
44
import type FridayPlugin from "./main";
5-
import * as path from "path";
65
import type { LicenseActivationResponse, LicenseUsageResponse } from "./license";
76

87
const NEW_ID = "-1"
@@ -23,9 +22,13 @@ export class Hugoverse {
2322
this.apiUrl = this.plugin.apiUrl;
2423
this.user = this.plugin.user;
2524

25+
// basePath is only available on desktop (FileSystemAdapter)
26+
// On mobile, we don't need it for license-related operations
2627
const adapter = this.app.vault.adapter;
27-
if (adapter instanceof FileSystemAdapter) {
28+
if (Platform.isDesktop && adapter instanceof FileSystemAdapter) {
2829
this.basePath = adapter.getBasePath();
30+
} else {
31+
this.basePath = '';
2932
}
3033
}
3134

@@ -57,7 +60,15 @@ export class Hugoverse {
5760
}
5861

5962
projectDirPath(filepath: string): string {
60-
return path.dirname(filepath)
63+
// Use simple string manipulation instead of Node.js path module
64+
// This works on both desktop and mobile
65+
const lastSlash = filepath.lastIndexOf('/');
66+
if (lastSlash === -1) {
67+
const lastBackslash = filepath.lastIndexOf('\\');
68+
if (lastBackslash === -1) return '.';
69+
return filepath.substring(0, lastBackslash);
70+
}
71+
return filepath.substring(0, lastSlash);
6172
}
6273

6374
/*

src/main.ts

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,11 @@ export default class FridayPlugin extends Plugin {
166166

167167
this.user = new User(this);
168168

169+
// Initialize Hugoverse for license-related API calls (works on both platforms)
170+
// Note: Some Hugoverse methods are desktop-only, but license activation works on mobile
171+
const { Hugoverse } = await import('./hugoverse');
172+
this.hugoverse = new Hugoverse(this);
173+
169174
// Fetch usage information if license is active
170175
await this.refreshLicenseUsage();
171176
}
@@ -177,13 +182,13 @@ export default class FridayPlugin extends Plugin {
177182
console.log('[Friday] Desktop mode: Loading full features...');
178183

179184
// Dynamically import PC-only modules
185+
// Note: Hugoverse is already initialized in initCore for license operations
180186
const [
181187
{ default: ServerView },
182188
{ ThemeSelectionModal },
183189
{ ProjectManagementModal },
184190
{ ProjectService },
185191
{ Site },
186-
{ Hugoverse },
187192
{ NetlifyAPI },
188193
{ FTPUploader },
189194
{ themeApiService }
@@ -193,7 +198,6 @@ export default class FridayPlugin extends Plugin {
193198
import('./projects/modal'),
194199
import('./projects/service'),
195200
import('./site'),
196-
import('./hugoverse'),
197201
import('./netlify'),
198202
import('./ftp'),
199203
import('./theme/themeApiService')
@@ -211,8 +215,7 @@ export default class FridayPlugin extends Plugin {
211215
this.ProjectManagementModalClass = ProjectManagementModal;
212216
this.themeApiService = themeApiService;
213217

214-
// Initialize PC-only services
215-
this.hugoverse = new Hugoverse(this);
218+
// Initialize PC-only services (hugoverse already initialized in initCore)
216219
this.netlify = new NetlifyAPI(this);
217220
this.site = new Site(this);
218221
this.projectService = new ProjectService(this);
@@ -817,23 +820,12 @@ export default class FridayPlugin extends Plugin {
817820
*/
818821
async refreshLicenseUsage() {
819822
// Check if dependencies are initialized
820-
if (!this.user) {
821-
console.log('[Friday] Skipping usage refresh: user not initialized yet');
822-
return;
823-
}
824-
825-
// On mobile, we need to dynamically import hugoverse for license usage check
826-
let hugoverse = this.hugoverse;
827-
if (!hugoverse && Platform.isMobile) {
828-
const { Hugoverse } = await import('./hugoverse');
829-
hugoverse = new Hugoverse(this);
830-
}
831-
832-
if (!hugoverse) {
833-
console.log('[Friday] Skipping usage refresh: hugoverse not available');
823+
if (!this.user || !this.hugoverse) {
824+
console.log('[Friday] Skipping usage refresh: dependencies not initialized yet');
834825
return;
835826
}
836827

828+
const hugoverse = this.hugoverse;
837829
const { license, userToken } = this.settings;
838830

839831
// Only fetch usage if license is active and not expired

versions.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@
1010
"0.11.4": "0.15.0",
1111
"0.11.5": "0.15.0",
1212
"26.1.1": "0.15.0",
13-
"26.1.2": "0.15.0"
13+
"26.1.2": "0.15.0",
14+
"26.1.3": "0.15.0"
1415
}

0 commit comments

Comments
 (0)