added free session memory button.

This commit is contained in:
maximstewart 2021-02-20 03:24:24 -06:00
parent e2014e25e7
commit 5adf3cbb66
4 changed files with 39 additions and 10 deletions

View File

@ -21,7 +21,9 @@
<li><button name="saveModalLauncher" class="button-primary" type="button">Save</button></li>
<li><button name="editModalLauncher" class="button-primary" type="button">Edit</button></li>
<li><button name="deleteModalLauncher" class="button-danger" type="button">Delete</button></li>
<br/><br/><br/>
<br/><br/>
<li><button name="freeSessionMeory" class="button-info" type="button">Free Memory</button></li>
<br/><br/>
<li><button name="import" class="button-primary" type="button">Import</button></li>
<li><button name="downloadModalLauncher" class="button-primary" type="button">Download</button></li>
<li><button name="donate" class="button-warning" type="button">Donate</button></li>
@ -232,10 +234,9 @@
<script src="../scripts/session-manager.js"></script>
<script src="../scripts/utils.js"></script>
<script src="../scripts/actions.js"></script>
<script src="../scripts/session-manager.js"></script>
<script src="../scripts/events.js"></script>
</body>
</html>

View File

@ -1,6 +1,5 @@
const message2 = "Name too long or none provided; or, unacceptable character used.";
const regexp = /^[a-zA-Z0-9-_]+$/; // Alphanumeric, dash, underscore
let data = null;
@ -18,7 +17,6 @@ const processor = () => {
if (enteryName.length < 0 || enteryName.length > 54 || enteryName.search(regexp) == -1) {
messageWindow("danger", message2, "modal-gutter");
// prePprocessor(obj, "", message2);
return ;
}

View File

@ -26,13 +26,18 @@ document.addEventListener("click", (e) => {
const selectedItemName = (selectedItem !== null) ? selectedItem.getAttribute("name") : "";
// Modals
if (/(saveModalLauncher|editModalLauncher|deleteModalLauncher|downloadModalLauncher)/.test(action)) {
if (/(saveModalLauncher|freeSessionMeory|editModalLauncher|deleteModalLauncher|downloadModalLauncher)/.test(action)) {
if (action == "saveModalLauncher") {
preSaveSession(selectedItem, selectedItemName);
showModal("saveModal");
return ;
}
if (action == "freeSessionMeory") {
freeSessionMeory();
return ;
}
if (selectedItem) {
if (action == "editModalLauncher") {
preEditSession(selectedItem, selectedItemName);

View File

@ -215,7 +215,7 @@ const loadSession = (json = null, replaceTabs = false) => {
let keys = Object.keys(json);
let keysLength = Object.keys(json).length;
try {
browser.windows.getAll().then(windows => {
windowApi.getAll().then(windows => {
windowApi.getCurrent({populate: true}).then(currentWindow => {
let wasCurrentTabId = null;
@ -268,6 +268,21 @@ const loadSession = (json = null, replaceTabs = false) => {
const freeSessionMeory = () => {
windowApi.getAll({populate: true}).then(windows => {
for (let i = 0; i < windows.length; i++) {
windows[i].tabs.forEach(tab => {
let discarding = tabsApi.discard(tab.id);
discarding.then(onDiscarded, onError);
});
}
});
messageWindow("success", "Freed session memory...");
}
const confirmSessionOverwrite = () => {
storageApi.set({[holderName]: holderData});
holderElm = document.getElementsByName(holderName)[0];
@ -276,3 +291,13 @@ const confirmSessionOverwrite = () => {
messageWindow("warning", "Overwrote session...");
resetArgs("confModal");
}
function onDiscarded() {
console.log(`Discarded`);
}
function onError(error) {
console.log(`Error: ${error}`);
}