mirror of
https://github.com/johannesjo/super-productivity.git
synced 2026-01-23 02:36:05 +00:00
fix(android): prevent crash by making share plugin detection synchronous
Calling await on the Capacitor Share plugin proxy (which happens when returning it from an async function or awaiting it directly) triggers a 'Share.then()' native call which fails on Android. This change makes the detection utilities synchronous and removes the await keywords to treat the plugin object correctly.
This commit is contained in:
parent
6215d014f1
commit
939264e3d3
2 changed files with 7 additions and 7 deletions
|
|
@ -8,7 +8,7 @@ export type ShareSupport = 'native' | 'web' | 'none';
|
|||
* Detect available share support on current platform.
|
||||
*/
|
||||
export const detectShareSupport = async (): Promise<ShareSupport> => {
|
||||
if (await isCapacitorShareAvailable()) {
|
||||
if (isCapacitorShareAvailable()) {
|
||||
return 'native';
|
||||
}
|
||||
|
||||
|
|
@ -27,7 +27,7 @@ export const detectShareSupport = async (): Promise<ShareSupport> => {
|
|||
* Check if native/system share is available on current platform.
|
||||
*/
|
||||
export const isSystemShareAvailable = async (): Promise<boolean> => {
|
||||
if (await isCapacitorShareAvailable()) {
|
||||
if (isCapacitorShareAvailable()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -45,15 +45,15 @@ export const isSystemShareAvailable = async (): Promise<boolean> => {
|
|||
/**
|
||||
* Check if Capacitor Share plugin is available.
|
||||
*/
|
||||
export const isCapacitorShareAvailable = async (): Promise<boolean> => {
|
||||
const sharePlugin = await getCapacitorSharePlugin();
|
||||
export const isCapacitorShareAvailable = (): boolean => {
|
||||
const sharePlugin = getCapacitorSharePlugin();
|
||||
return !!sharePlugin;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get Capacitor Share plugin if available.
|
||||
*/
|
||||
export const getCapacitorSharePlugin = async (): Promise<typeof Share | null> => {
|
||||
export const getCapacitorSharePlugin = (): typeof Share | null => {
|
||||
if (Capacitor.isNativePlatform() || IS_ANDROID_WEB_VIEW) {
|
||||
return Share;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -205,7 +205,7 @@ export class ShareService {
|
|||
async tryNativeShare(payload: SharePayload): Promise<ShareResult> {
|
||||
const normalized = ShareTextUtil.ensureShareText(payload);
|
||||
|
||||
const capacitorShare = await SharePlatformUtil.getCapacitorSharePlugin();
|
||||
const capacitorShare = SharePlatformUtil.getCapacitorSharePlugin();
|
||||
if (capacitorShare) {
|
||||
try {
|
||||
await capacitorShare.share({
|
||||
|
|
@ -461,7 +461,7 @@ export class ShareService {
|
|||
filename: string,
|
||||
title: string,
|
||||
): Promise<ShareResult> {
|
||||
const sharePlugin = await SharePlatformUtil.getCapacitorSharePlugin();
|
||||
const sharePlugin = SharePlatformUtil.getCapacitorSharePlugin();
|
||||
if (!sharePlugin) {
|
||||
return {
|
||||
success: false,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue