@@ -9,103 +9,60 @@ import targetsIndex from "./index/targets.js";
9
9
import searchIndex from "./index/std-docs.js" ;
10
10
import { mapping , crateIndex } from "./index/crates.js" ;
11
11
import storage from "./core/storage.js" ;
12
+ import IndexSetter from "./index-setter.js" ;
12
13
13
14
// Query all storage by this method:
14
15
// chrome.storage.local.get(null, function(result) {
15
16
// console.log('Value currently is ', result);
16
17
// });
17
18
18
- export default class IndexManager {
19
+ export default class IndexManager extends IndexSetter {
19
20
static async getStdStableIndex ( ) {
20
21
// Convert default map searchIndex to Object since rust 1.76.0
21
22
return await storage . getItem ( 'index-std-stable' ) || Object . fromEntries ( searchIndex ) ;
22
23
}
23
24
24
- static setStdStableIndex ( index ) {
25
- storage . setItem ( 'index-std-stable' , index ) ;
26
- }
27
-
28
25
static async getStdNightlyIndex ( ) {
29
26
// Convert default map searchIndex to Object since rust 1.76.0
30
27
return await storage . getItem ( 'index-std-nightly' ) || Object . fromEntries ( searchIndex ) ;
31
28
}
32
29
33
- static setStdNightlyIndex ( index ) {
34
- storage . setItem ( 'index-std-nightly' , index ) ;
35
- }
36
-
37
30
static async getBookIndex ( ) {
38
31
return await storage . getItem ( 'index-book' ) || booksIndex ;
39
32
}
40
33
41
- static setBookIndex ( index ) {
42
- storage . setItem ( 'index-book' , index ) ;
43
- }
44
-
45
34
static async getLabelIndex ( ) {
46
35
return await storage . getItem ( 'index-label' ) || labelsIndex ;
47
36
}
48
37
49
- static setLabelIndex ( index ) {
50
- storage . setItem ( 'index-label' , index ) ;
51
- }
52
-
53
38
static async getRfcIndex ( ) {
54
39
return await storage . getItem ( 'index-rfc' ) || rfcsIndex ;
55
40
}
56
41
57
- static setRfcIndex ( index ) {
58
- storage . setItem ( 'index-rfc' , index ) ;
59
- }
60
-
61
42
static async getCrateMapping ( ) {
62
43
return await storage . getItem ( 'index-crate-mapping' ) || mapping ;
63
44
}
64
45
65
- static setCrateMapping ( index ) {
66
- storage . setItem ( 'index-crate-mapping' , index ) ;
67
- }
68
-
69
46
static async getCrateIndex ( ) {
70
47
return await storage . getItem ( 'index-crate' ) || crateIndex ;
71
48
}
72
49
73
- static setCrateIndex ( index ) {
74
- storage . setItem ( 'index-crate' , index ) ;
75
- }
76
-
77
50
static async getLintIndex ( ) {
78
51
return await storage . getItem ( 'index-lint' ) || lintsIndex ;
79
52
}
80
53
81
- static setLintIndex ( index ) {
82
- storage . setItem ( 'index-lint' , index ) ;
83
- }
84
-
85
54
static async getCaniuseIndex ( ) {
86
55
return await storage . getItem ( 'index-caniuse' ) || caniuseIndex ;
87
56
}
88
57
89
- static setCaniuseIndex ( index ) {
90
- storage . setItem ( 'index-caniuse' , index ) ;
91
- }
92
-
93
58
static async getRustcIndex ( ) {
94
59
return await storage . getItem ( 'index-rustc' ) || rustcIndex ;
95
60
}
96
61
97
- static setRustcIndex ( index ) {
98
- storage . setItem ( 'index-rustc' , index ) ;
99
- }
100
-
101
62
static async getTargetIndex ( ) {
102
63
return await storage . getItem ( 'index-target' ) || targetsIndex ;
103
64
}
104
65
105
- static setTargetIndex ( index ) {
106
- storage . setItem ( 'index-target' , index ) ;
107
- }
108
-
109
66
static async getCommandIndex ( ) {
110
67
let index = await storage . getItem ( 'index-command' ) ;
111
68
if ( index ) {
@@ -119,22 +76,4 @@ export default class IndexManager {
119
76
}
120
77
return commandsIndex ;
121
78
}
122
-
123
- static setCommandIndex ( index ) {
124
- storage . setItem ( 'index-command' , index ) ;
125
- }
126
-
127
- static updateAllIndex ( ) {
128
- IndexManager . setBookIndex ( booksIndex ) ;
129
- IndexManager . setCaniuseIndex ( caniuseIndex ) ;
130
- IndexManager . setCommandIndex ( commandsIndex ) ;
131
- IndexManager . setCrateIndex ( crateIndex ) ;
132
- IndexManager . setCrateMapping ( mapping ) ;
133
- IndexManager . setLabelIndex ( labelsIndex ) ;
134
- IndexManager . setLintIndex ( lintsIndex ) ;
135
- IndexManager . setRfcIndex ( rfcsIndex ) ;
136
- IndexManager . setRustcIndex ( rustcIndex ) ;
137
- IndexManager . setStdStableIndex ( searchIndex ) ;
138
- IndexManager . setTargetIndex ( targetsIndex ) ;
139
- }
140
79
} ;
0 commit comments