Skip to content

Commit

Permalink
feat: make checkIfMusicInstalled optional
Browse files Browse the repository at this point in the history
  • Loading branch information
N0chteil committed Jun 6, 2023
1 parent 90769d7 commit 3b0f220
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,32 @@ import EventEmitter from "events";
export class AppleBridge {
public emitter = new EventEmitter();
public isMusicInstalled: boolean;
public checkIfInstalled: {
music: boolean;
};

static instance: AppleBridge;

constructor() {
constructor(
checkIfInstalled = {
music: true
}
) {
if (AppleBridge.instance) return AppleBridge.instance;

AppleBridge.instance = this;

this.checkIfInstalled = checkIfInstalled;
this.init();
}

async init() {
if (!checkIfMusicRunning()) return setTimeout(() => this.init(), 5000);

this.isMusicInstalled = await checkIfMusicInstalled();
this.isMusicInstalled =
this.checkIfInstalled?.music ?? true
? await checkIfMusicInstalled()
: true;

if (!this.isMusicInstalled) return;

Expand Down

0 comments on commit 3b0f220

Please sign in to comment.