Skip to content

Commit

Permalink
fix(client/exports): accept promise export for PhoneAsItem
Browse files Browse the repository at this point in the history
  • Loading branch information
TasoOneAsia committed Jan 2, 2022
1 parent 178ea75 commit 6048902
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions resources/client/cl_main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,10 @@ RegisterCommand(
*
* * * * * * * * * * * * */

const checkExportCanOpen = (): boolean => {
const exportResp = exps[config.PhoneAsItem.exportResource][config.PhoneAsItem.exportFunction]();
const checkExportCanOpen = async (): Promise<boolean> => {
const exportResp = await Promise.resolve(
exps[config.PhoneAsItem.exportResource][config.PhoneAsItem.exportFunction](),
);
if (typeof exportResp !== 'number' && typeof exportResp !== 'boolean') {
throw new Error('You must return either a boolean or number from your export function');
}
Expand All @@ -109,7 +111,7 @@ const checkExportCanOpen = (): boolean => {

async function togglePhone(): Promise<void> {
if (config.PhoneAsItem.enabled) {
const canAccess = checkExportCanOpen();
const canAccess = await checkExportCanOpen();
if (!canAccess) return;
}
if (global.isPhoneOpen) return await hidePhone();
Expand Down

0 comments on commit 6048902

Please sign in to comment.