-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstorage.js
More file actions
32 lines (24 loc) · 687 Bytes
/
storage.js
File metadata and controls
32 lines (24 loc) · 687 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
class Storage {
constructor() {
}
static getSearchedUsersFromStorage() {
let users;
if(localStorage.getItem("searched") === null){
users = [];
}
else{
users = JSON.parse(localStorage.getItem("searched"));
}
return users;
}
static addSearchedUsersToStorage(username){
let users = this.getSearchedUsersFromStorage();
if(users.indexOf(username) === -1){
users.push(username);
}
localStorage.setItem("searched", JSON.stringify(users));
}
static clearAllSearchedUsersToStorage(){
localStorage.removeItem("searched");
}
}