From df81617588b0be28e8ee7ead79de05fad45c5f81 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Thu, 19 Oct 2023 16:14:02 +0200 Subject: [PATCH] MOBILE-4362 siteplugins: Add helper function to update cached data --- .../components/plugin-content/plugin-content.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/core/features/siteplugins/components/plugin-content/plugin-content.ts b/src/core/features/siteplugins/components/plugin-content/plugin-content.ts index 2bd56a959..9f40f08c5 100644 --- a/src/core/features/siteplugins/components/plugin-content/plugin-content.ts +++ b/src/core/features/siteplugins/components/plugin-content/plugin-content.ts @@ -22,6 +22,7 @@ import { CoreSitePlugins, CoreSitePluginsContent, CoreSitePluginsProvider } from import { CoreNavigator } from '@services/navigator'; import { CoreDomUtils } from '@services/utils/dom'; import { CoreEvents } from '@singletons/events'; +import { CoreSites, CoreSitesReadingStrategy } from '@services/sites'; /** * Component to render a site plugin content. @@ -238,6 +239,19 @@ export class CoreSitePluginsPluginContentComponent implements OnInit, DoCheck { CoreEvents.trigger(CoreSitePluginsProvider.UPDATE_COURSE_CONTENT, { cmId, alreadyFetched }); } + /** + * Update this content stored in the app's cache. This function will not reload the view, it will only update the data stored + * in the device so it's updated for the next usage. If you want to update the view, please use refreshContent. + */ + async updateCachedContent(): Promise { + await CoreSitePlugins.getContent( + this.component, + this.method, + this.args, + CoreSites.getReadingStrategyPreSets(CoreSitesReadingStrategy.ONLY_NETWORK), + ); + } + } export type CoreSitePluginsPluginContentLoadedData = {