Skip to content

Commit

Permalink
Global Styles: Defer revisions for font activation until explicit save
Browse files Browse the repository at this point in the history
  • Loading branch information
himanshupathak95 committed Feb 13, 2025
1 parent 322899e commit fcd1b9a
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function FontLibraryProvider( { children } ) {
*
* @param {Array} fonts - The font families that will be saved to the database.
*/
const saveFontFamilies = async ( fonts ) => {
const saveFontFamilies = async ( fonts, shouldAutoSave = false ) => {
// Gets the global styles database post content.
const updatedGlobalStyles = globalStyles.record;

Expand All @@ -104,8 +104,14 @@ function FontLibraryProvider( { children } ) {
fonts
);

// Saves a new version of the global styles in the database.
await saveEntityRecord( 'root', 'globalStyles', updatedGlobalStyles );
if ( shouldAutoSave ) {
// Saves a new version of the global styles in the database.
await saveEntityRecord(
'root',
'globalStyles',
updatedGlobalStyles
);
}
};

// Library Fonts
Expand Down Expand Up @@ -309,8 +315,7 @@ function FontLibraryProvider( { children } ) {
fontFamiliesToActivate
);
// Save the global styles to the database.
await saveFontFamilies( activeFonts );

await saveFontFamilies( activeFonts, true );
refreshLibrary();
}

Expand Down Expand Up @@ -343,7 +348,7 @@ function FontLibraryProvider( { children } ) {
fontFamilyToUninstall
);
// Save the global styles to the database.
await saveFontFamilies( activeFonts );
await saveFontFamilies( activeFonts, true );
}

// Refresh the library (the library font families from database).
Expand Down

0 comments on commit fcd1b9a

Please sign in to comment.