mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-11 02:32:41 +00:00
Remove spaces from code indentation
This commit is contained in:
@@ -3,7 +3,7 @@ export const HISTORY_SLOTS = 5;
|
|||||||
|
|
||||||
// History values in minutes
|
// History values in minutes
|
||||||
const DEFAULT_HISTORY_SAVE_DELAYS = {
|
const DEFAULT_HISTORY_SAVE_DELAYS = {
|
||||||
'0' : 0,
|
'0' : 0,
|
||||||
'1' : 2,
|
'1' : 2,
|
||||||
'2' : 10,
|
'2' : 10,
|
||||||
'3' : 60,
|
'3' : 60,
|
||||||
@@ -38,28 +38,28 @@ function getVersionBySlot(brew, slot){
|
|||||||
};
|
};
|
||||||
|
|
||||||
function updateStoredBrew(brew, slot = 0) {
|
function updateStoredBrew(brew, slot = 0) {
|
||||||
const archiveBrew = {
|
const archiveBrew = {
|
||||||
title : brew.title,
|
title : brew.title,
|
||||||
text : brew.text,
|
text : brew.text,
|
||||||
style : brew.style,
|
style : brew.style,
|
||||||
version : brew.version,
|
version : brew.version,
|
||||||
shareId : brew.shareId,
|
shareId : brew.shareId,
|
||||||
savedAt : brew?.savedAt || new Date(),
|
savedAt : brew?.savedAt || new Date(),
|
||||||
expireAt : new Date()
|
expireAt : new Date()
|
||||||
};
|
};
|
||||||
|
|
||||||
archiveBrew.expireAt.setMinutes(archiveBrew.expireAt.getMinutes() + HISTORY_SAVE_DELAYS[slot]);
|
archiveBrew.expireAt.setMinutes(archiveBrew.expireAt.getMinutes() + HISTORY_SAVE_DELAYS[slot]);
|
||||||
|
|
||||||
const key = getKeyBySlot(brew, slot);
|
const key = getKeyBySlot(brew, slot);
|
||||||
localStorage.setItem(key, JSON.stringify(archiveBrew));
|
localStorage.setItem(key, JSON.stringify(archiveBrew));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export function historyExists(brew){
|
export function historyExists(brew){
|
||||||
return Object.keys(localStorage)
|
return Object.keys(localStorage)
|
||||||
.some((key)=>{
|
.some((key)=>{
|
||||||
return key.startsWith(`${HISTORY_PREFIX}-${brew.shareId}`);
|
return key.startsWith(`${HISTORY_PREFIX}-${brew.shareId}`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function loadHistory(brew){
|
export function loadHistory(brew){
|
||||||
@@ -108,14 +108,14 @@ export function getHistoryItems(brew){
|
|||||||
|
|
||||||
export function versionHistoryGarbageCollection(){
|
export function versionHistoryGarbageCollection(){
|
||||||
Object.keys(localStorage)
|
Object.keys(localStorage)
|
||||||
.filter((key)=>{
|
.filter((key)=>{
|
||||||
return key.startsWith(HISTORY_PREFIX);
|
return key.startsWith(HISTORY_PREFIX);
|
||||||
})
|
})
|
||||||
.forEach((key)=>{
|
.forEach((key)=>{
|
||||||
const collectAt = new Date(JSON.parse(localStorage.getItem(key)).savedAt);
|
const collectAt = new Date(JSON.parse(localStorage.getItem(key)).savedAt);
|
||||||
collectAt.setMinutes(collectAt.getMinutes() + GARBAGE_COLLECT_DELAY);
|
collectAt.setMinutes(collectAt.getMinutes() + GARBAGE_COLLECT_DELAY);
|
||||||
if(new Date() > collectAt){
|
if(new Date() > collectAt){
|
||||||
localStorage.removeItem(key);
|
localStorage.removeItem(key);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
Reference in New Issue
Block a user