Skip to content

Commit

Permalink
refactor: update to use obsidian api for platform detection
Browse files Browse the repository at this point in the history
  • Loading branch information
aidenlx committed Sep 13, 2021
1 parent 763adad commit f1ed456
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
5 changes: 2 additions & 3 deletions src/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
AFItem,
FolderItem,
Modifier,
Platform,
TAbstractFile,
TFile,
TFolder,
Expand All @@ -21,8 +22,6 @@ export const isFolder = (item: AFItem): item is FolderItem =>
export const isMd = (file: TFile | string) =>
typeof file === "string" ? extname(file) === ".md" : file.extension === "md";

export const isMac = () => navigator.userAgent.includes("Macintosh");

export enum NoteLoc {
Index,
Inside,
Expand All @@ -33,7 +32,7 @@ export const isModifier = (evt: MouseEvent, pref: Modifier): boolean => {
const { altKey, metaKey, ctrlKey, shiftKey } = evt;
switch (pref) {
case "Mod":
return isMac() ? metaKey : ctrlKey;
return Platform.isMacOS ? metaKey : ctrlKey;
case "Ctrl":
return ctrlKey;
case "Meta":
Expand Down
14 changes: 10 additions & 4 deletions src/settings.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import { App, debounce, Modifier, PluginSettingTab, Setting } from "obsidian";
import {
App,
debounce,
Modifier,
Platform,
PluginSettingTab,
Setting,
} from "obsidian";

import ALxFolderNote from "./fn-main";
import { isMac, NoteLoc } from "./misc";
import FEHandler from "./modules/fe-handler";
import { NoteLoc } from "./misc";

export const noHideMark = "alx-no-hide-note";

Expand Down Expand Up @@ -125,7 +131,7 @@ export class ALxFolderNoteSettingTab extends PluginSettingTab {
Alt: "⌥ Option",
};

const options = isMac() ? macOSOpts : windowsOpts;
const options = Platform.isMacOS ? macOSOpts : windowsOpts;

dropDown
.addOptions(options)
Expand Down

0 comments on commit f1ed456

Please sign in to comment.