Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita5a9d05

Browse files
committed
use either the file or local storage tutorial
Signed-off-by: shmck <shawn.j.mckay@gmail.com>
1 parent4a634dd commita5a9d05

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

‎src/services/storage/index.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class Storage<T> {
3333
publicget=async():Promise<T>=>{
3434
if(SESSION_STORAGE_PATH){
3535
try{
36-
// 1. read from file instead of local storage if specified
36+
// 1.attempt toread from file instead of local storage if specified
3737
constsessionFile=awaitreadFile(SESSION_STORAGE_PATH,`${this.filePath}.json`)
3838
if(!sessionFile){
3939
thrownewError('No session file found')
@@ -50,14 +50,15 @@ class Storage<T> {
5050
}catch(err:any){
5151
logger(`Failed to read or parse session file:${SESSION_STORAGE_PATH}/${this.filePath}.json:${err.message}`)
5252
}
53-
}
54-
constvalue:string|undefined=awaitthis.storage.get(this.key)
55-
if(value){
56-
// 2. read from local storage
57-
try{
58-
returnJSON.parse(value)
59-
}catch(err:any){
60-
logger(`Failed to parse session state from local storage:${value}:${err.message}`)
53+
}else{
54+
// 2. attempt to read from local storage
55+
constvalue:string|undefined=awaitthis.storage.get(this.key)
56+
if(value){
57+
try{
58+
returnJSON.parse(value)
59+
}catch(err:any){
60+
logger(`Failed to parse session state from local storage:${value}:${err.message}`)
61+
}
6162
}
6263
}
6364
// 3. fallback to the default

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp