@@ -619,80 +619,85 @@ async function retrieveFilteredPlugins(filterState) {
619619 ) ;
620620 $list . installed . setAttribute ( "empty-msg" , strings [ "no plugins found" ] ) ;
621621 }
622-
623622async function getOwned ( ) {
624623 $list . owned . setAttribute ( "empty-msg" , strings [ "loading..." ] ) ;
625624
626- const purchases = await helpers . promisify ( iap . getPurchases ) ;
627625 const disabledMap = settings . value . pluginsDisabled || { } ;
628-
629- // Prevent duplicates
630626 const addedIds = new Set ( ) ;
631627
632- // Play Store / IAP purchases
633- await Promise . all (
634- purchases . map ( async ( { productIds } ) => {
635- const [ sku ] = productIds ;
628+ // -------------------
629+ // Google Play / IAP
630+ // -------------------
631+ try {
632+ const purchases = await helpers . promisify ( iap . getPurchases ) ;
636633
637- try {
638- const url = Url . join ( constants . API_BASE , "plugin/owned" , sku ) ;
639- const plugin = await fsOperation ( url ) . readFile ( "json" ) ;
634+ await Promise . all (
635+ purchases . map ( async ( { productIds } ) => {
636+ const [ sku ] = productIds ;
640637
641- if ( ! plugin || addedIds . has ( plugin . id ) ) return ;
638+ try {
639+ const url = Url . join ( constants . API_BASE , "plugin/owned" , sku ) ;
640+ const plugin = await fsOperation ( url ) . readFile ( "json" ) ;
642641
643- const isInstalled = plugins . installed . find (
644- ( { id } ) => id === plugin . id
645- ) ;
642+ if ( ! plugin || addedIds . has ( plugin . id ) ) return ;
646643
647- plugin . installed = ! ! isInstalled ;
644+ const isInstalled = plugins . installed . find (
645+ ( { id } ) => id === plugin . id
646+ ) ;
648647
649- if ( plugin . installed ) {
650- plugin . enabled = disabledMap [ plugin . id ] !== true ;
651- plugin . onToggleEnabled = onToggleEnabled ;
652- }
648+ plugin . installed = ! ! isInstalled ;
653649
654- addedIds . add ( plugin . id ) ;
655- plugins . owned . push ( plugin ) ;
656- $list . owned . append ( < Item { ...plugin } updates = { updates } /> ) ;
657- } catch ( err ) {
658- console . error ( "Failed to load owned IAP plugin:" , err ) ;
659- }
660- } )
661- ) ;
650+ if ( plugin . installed ) {
651+ plugin . enabled = disabledMap [ plugin . id ] !== true ;
652+ plugin . onToggleEnabled = onToggleEnabled ;
653+ }
662654
663- // Razorpay / external purchases
664- try {
665- const url = withSupportedEditor (
666- `${ constants . API_BASE } /plugins?owned=true`
667- ) ;
655+ addedIds . add ( plugin . id ) ;
656+ plugins . owned . push ( plugin ) ;
657+ $list . owned . append ( < Item { ...plugin } updates = { updates } /> ) ;
658+ } catch ( err ) {
659+ console . error ( "Failed to load owned IAP plugin:" , err ) ;
660+ }
661+ } )
662+ ) ;
663+ } catch ( err ) {
664+ console . warn ( "IAP unavailable, continuing with Razorpay:" , err ) ;
665+ }
668666
669- const ownedPlugins = await fetchPlugins ( url ) ;
667+ // -------------------
668+ // Razorpay purchases
669+ // -------------------
670+ try {
671+ const url = withSupportedEditor (
672+ `${ constants . API_BASE } /plugins?owned=true`
673+ ) ;
670674
671- ownedPlugins . forEach ( ( plugin ) => {
672- if ( ! plugin || addedIds . has ( plugin . id ) ) return ;
675+ const ownedPlugins = await fetchPlugins ( url ) ;
673676
674- const isInstalled = plugins . installed . find (
675- ( { id } ) => id === plugin . id
676- ) ;
677+ ownedPlugins . forEach ( ( plugin ) => {
678+ if ( ! plugin || addedIds . has ( plugin . id ) ) return ;
677679
678- plugin . installed = ! ! isInstalled ;
680+ const isInstalled = plugins . installed . find (
681+ ( { id } ) => id === plugin . id
682+ ) ;
679683
680- if ( plugin . installed ) {
681- plugin . enabled = disabledMap [ plugin . id ] !== true ;
682- plugin . onToggleEnabled = onToggleEnabled ;
683- }
684+ plugin . installed = ! ! isInstalled ;
684685
685- addedIds . add ( plugin . id ) ;
686- plugins . owned . push ( plugin ) ;
687- $list . owned . append ( < Item { ...plugin } updates = { updates } /> ) ;
688- } ) ;
689- } catch ( err ) {
690- console . error ( "Failed to fetch owned plugins:" , err ) ;
691- }
686+ if ( plugin . installed ) {
687+ plugin . enabled = disabledMap [ plugin . id ] !== true ;
688+ plugin . onToggleEnabled = onToggleEnabled ;
689+ }
692690
693- $list . owned . setAttribute ( "empty-msg" , strings [ "no plugins found" ] ) ;
691+ addedIds . add ( plugin . id ) ;
692+ plugins . owned . push ( plugin ) ;
693+ $list . owned . append ( < Item { ...plugin } updates = { updates } /> ) ;
694+ } ) ;
695+ } catch ( err ) {
696+ console . error ( "Failed to fetch owned plugins:" , err ) ;
694697 }
695698
699+ $list . owned . setAttribute ( "empty-msg" , strings [ "no plugins found" ] ) ;
700+ }
696701 function onInstall ( plugin ) {
697702 if ( updates ) return ;
698703
0 commit comments