fix: 🚑 Fix Language Pack Memory Leak

Since language packs were added, there was a memory leak where each time you load a page containing a translated language, the active language pack would be loaded into memory (RAM) each time, after the initial load. For example, starting the app loads the memory pack into memory first, then if you open settings, it would load the pack twice. Language packs are only a few mb or kb so it wasn't major but it is fixed now.
This commit is contained in:
Kenny 2022-06-17 20:04:33 -04:00
parent 792717127f
commit b99b7f63a0
1 changed files with 4 additions and 4 deletions

View File

@ -15,17 +15,17 @@ const packs = {
indonesian: require('./languages/indonesian'),
}
function module(text, listPacks) {
function module(subPack, listPacks) {
//--- List All Packs ---//
if (listPacks === true) return packs;
//--- Return Language Pack ---//
const selectedLanguage = localStorage.getItem("language") || "english";
const languagePack = require('./languages/'+selectedLanguage);
const languagePack = packs[selectedLanguage];
if (!text) return languagePack;
return languagePack[text];
if (!subPack) return languagePack;
return languagePack[subPack];
}