@@ -607,11 +607,28 @@ angular.module('mm.addons.mod_glossary')
607607 */
608608 self . invalidateEntry = function ( entryId , siteId ) {
609609 return $mmSitesManager . getSite ( siteId ) . then ( function ( site ) {
610- var key = self . _getEntryCacheKey ( entryId ) ;
611- return site . invalidateWsCacheForKey ( key ) ;
610+ return site . invalidateWsCacheForKey ( self . _getEntryCacheKey ( entryId ) ) ;
612611 } ) ;
613612 } ;
614613
614+ /**
615+ * Invalidate cache of all entries in the array.
616+ *
617+ * @param {Array } entries Entry objects to invalidate.
618+ * @param {String } [siteId] Site ID. If not defined, current site.
619+ * @return {Promise } Resolved when data is invalidated.
620+ */
621+ function invalidateEntries ( entries , siteId ) {
622+ var keys = [ ] ;
623+ angular . forEach ( entries , function ( entry ) {
624+ keys . push ( self . _getEntryCacheKey ( entry . id ) ) ;
625+ } ) ;
626+
627+ return $mmSitesManager . getSite ( siteId ) . then ( function ( site ) {
628+ return site . invalidateMultipleWsCacheForKey ( keys ) ;
629+ } ) ;
630+ }
631+
615632 /**
616633 * Invalidate the prefetched content except files.
617634 * To invalidate files, use $mmaModGlossary#invalidateFiles.
@@ -641,37 +658,38 @@ angular.module('mm.addons.mod_glossary')
641658 * @module mm.addons.mod_glossary
642659 * @ngdoc method
643660 * @name $mmaModGlossary#invalidateGlossaryEntries
644- * @param {Object } glossary The glossary object.
645- * @return {Promise } Promise resolved when data is invalidated.
661+ * @param {Object } glossary The glossary object.
662+ * @param {Object } onlyEntriesList If true, entries won't be invalidated.
663+ * @return {Promise } Promise resolved when data is invalidated.
646664 */
647- self . invalidateGlossaryEntries = function ( glossary ) {
648- return self . fetchAllEntries ( self . getEntriesByLetter , [ glossary . id , 'ALL' ] , true ) . then ( function ( entries ) {
649- var promises = [ ] ;
665+ self . invalidateGlossaryEntries = function ( glossary , onlyEntriesList ) {
666+ var promises = [ ] ;
650667
651- angular . forEach ( entries , function ( entry ) {
652- promises . push ( self . invalidateEntry ( entry . id ) ) ;
653- } ) ;
654-
655- angular . forEach ( glossary . browsemodes , function ( mode ) {
656- switch ( mode ) {
657- case 'letter' :
658- promises . push ( self . invalidateEntriesByLetter ( glossary . id , 'ALL' ) ) ;
659- break ;
660- case 'cat' :
661- promises . push ( self . invalidateEntriesByCategory ( glossary . id , mmaModGlossaryShowAllCategories ) ) ;
662- break ;
663- case 'date' :
664- promises . push ( self . invalidateEntriesByDate ( glossary . id , 'CREATION' , 'DESC' ) ) ;
665- promises . push ( self . invalidateEntriesByDate ( glossary . id , 'UPDATE' , 'DESC' ) ) ;
666- break ;
667- case 'author' :
668- promises . push ( self . invalidateEntriesByAuthor ( glossary . id , 'ALL' , 'LASTNAME' , 'ASC' ) ) ;
669- break ;
670- }
671- } ) ;
668+ if ( ! onlyEntriesList ) {
669+ promises . push ( self . fetchAllEntries ( self . getEntriesByLetter , [ glossary . id , 'ALL' ] , true ) . then ( function ( entries ) {
670+ return invalidateEntries ( entries ) ;
671+ } ) ) ;
672+ }
672673
673- return $q . all ( promises ) ;
674+ angular . forEach ( glossary . browsemodes , function ( mode ) {
675+ switch ( mode ) {
676+ case 'letter' :
677+ promises . push ( self . invalidateEntriesByLetter ( glossary . id , 'ALL' ) ) ;
678+ break ;
679+ case 'cat' :
680+ promises . push ( self . invalidateEntriesByCategory ( glossary . id , mmaModGlossaryShowAllCategories ) ) ;
681+ break ;
682+ case 'date' :
683+ promises . push ( self . invalidateEntriesByDate ( glossary . id , 'CREATION' , 'DESC' ) ) ;
684+ promises . push ( self . invalidateEntriesByDate ( glossary . id , 'UPDATE' , 'DESC' ) ) ;
685+ break ;
686+ case 'author' :
687+ promises . push ( self . invalidateEntriesByAuthor ( glossary . id , 'ALL' , 'LASTNAME' , 'ASC' ) ) ;
688+ break ;
689+ }
674690 } ) ;
691+
692+ return $q . all ( promises ) ;
675693 } ;
676694
677695 /**
0 commit comments