This repository was archived by the owner on Jun 26, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +7
-13
lines changed Expand file tree Collapse file tree 1 file changed +7
-13
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ export default class CssSnippetStore extends Plugin {
18
18
19
19
observer : MutationObserver ;
20
20
21
- onload ( ) {
21
+ async onload ( ) {
22
22
// Start the mutation observer when the plugin is loaded.
23
23
this . injectWhenSettingsLoaded ( ) ;
24
24
@@ -27,11 +27,8 @@ export default class CssSnippetStore extends Plugin {
27
27
const url = "https://raw.githubusercontent.com/xavwe/obsidian-css-snippet-store/refs/heads/main/snippets.json"
28
28
try {
29
29
if ( navigator . onLine ) {
30
- fetch ( url )
31
- . then ( r => r . json ( ) )
32
- . then ( t => {
33
- this . snippets = t ;
34
- } )
30
+ const response = await fetch ( url ) ;
31
+ const data = await response . json ( ) ;
35
32
} else {
36
33
new Notice ( `No Internet connection...` ) ;
37
34
return ;
@@ -165,17 +162,14 @@ class CssSnippetStoreModal extends Modal {
165
162
const button = buttonWrapper . createEl ( 'button' , { text : 'Install' , cls : 'mod-cta' } ) ;
166
163
167
164
// Attach event listener
168
- button . addEventListener ( 'click' , ( ) => {
165
+ button . addEventListener ( 'click' , async ( ) => {
169
166
let code ;
170
167
const url = "https://raw.githubusercontent.com/" + snippet . repo + "/refs/heads/main/" + snippet . folder + "/snippet.css"
171
168
try {
172
169
if ( navigator . onLine ) {
173
- fetch ( url )
174
- . then ( r => r . text ( ) )
175
- . then ( t => {
176
- code = t ;
177
- this . install ( snippet . id , code ) ;
178
- } )
170
+ const response = await fetch ( url ) ;
171
+ const code = await response . text ( ) ;
172
+ await this . install ( snippet . id , code ) ;
179
173
} else {
180
174
new Notice ( `No Internet connection...` ) ;
181
175
return ;
You can’t perform that action at this time.
0 commit comments