-
Notifications
You must be signed in to change notification settings - Fork 798
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[frontend] linter fixed, session storage function updated, some var n…
…ames edited (#3167)
- Loading branch information
1 parent
f343632
commit a2fd08f
Showing
5 changed files
with
26 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 3 additions & 8 deletions
11
...ont/src/utils/sessionStorage/setStackDataInSessionStorage/setStackDataInSessionStorage.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,12 @@ | ||
type SetDataOnSessionStorageParams = { | ||
valueToStore: unknown; | ||
key: string; | ||
stackValue: number; | ||
}; | ||
const setStackDataInSessionStorage = ({ valueToStore, key, stackValue }: SetDataOnSessionStorageParams): void => { | ||
const setStackDataInSessionStorage = (key: string, valueToStore: unknown, stackValue: number): void => { | ||
const storedStackData = sessionStorage.getItem(key); | ||
const currentStoredStackData = storedStackData ? JSON.parse(storedStackData) : []; | ||
|
||
currentStoredStackData.unshift(valueToStore); | ||
|
||
if (currentStoredStackData.length > stackValue) currentStoredStackData.pop(); | ||
const newStackDataToStore = currentStoredStackData.slice(0, stackValue); | ||
|
||
sessionStorage.setItem(key, JSON.stringify(currentStoredStackData)); | ||
sessionStorage.setItem(key, JSON.stringify(newStackDataToStore)); | ||
}; | ||
|
||
export default setStackDataInSessionStorage; |