@@ -11,21 +11,11 @@ import Tooltip from "bootstrap/js/dist/tooltip";
11
11
12
12
this . storage = localStorage ;
13
13
this . types = [ "informationObject" , "actor" , "repository" ] ;
14
- this . initialItems = JSON . stringify ( {
15
- informationObject : [ ] ,
16
- actor : [ ] ,
17
- repository : [ ] ,
18
- } ) ;
19
- this . items = JSON . parse ( this . storage . getItem ( "clipboard" ) ) ;
20
- this . exportTokens = JSON . parse ( this . storage . getItem ( "exportTokens" ) ) ;
21
-
22
- if ( ! this . items ) {
23
- this . items = JSON . parse ( this . initialItems ) ;
24
- }
25
-
26
- if ( ! this . exportTokens ) {
27
- this . exportTokens = [ ] ;
28
- }
14
+ this . initialItems = { informationObject : [ ] , actor : [ ] , repository : [ ] } ;
15
+ this . items =
16
+ JSON . parse ( this . storage . getItem ( "clipboard" ) ) || this . initialItems ;
17
+ this . exportTokens =
18
+ JSON . parse ( this . storage . getItem ( "exportTokens" ) ) || [ ] ;
29
19
30
20
this . init ( ) ;
31
21
}
@@ -335,7 +325,8 @@ import Tooltip from "bootstrap/js/dist/tooltip";
335
325
336
326
// Load items from local storage in case activity
337
327
// in another tab has changed the content
338
- this . items = JSON . parse ( this . storage . getItem ( "clipboard" ) ) ;
328
+ this . items =
329
+ JSON . parse ( this . storage . getItem ( "clipboard" ) ) || this . initialItems ;
339
330
340
331
var $button = $ ( event . target ) . closest ( "button" ) ;
341
332
var type = $button . data ( "clipboard-type" ) ;
@@ -375,7 +366,7 @@ import Tooltip from "bootstrap/js/dist/tooltip";
375
366
if ( type && this . types . includes ( type ) ) {
376
367
this . items [ type ] = [ ] ;
377
368
} else {
378
- this . items = JSON . parse ( this . initialItems ) ;
369
+ this . items = this . initialItems ;
379
370
}
380
371
381
372
this . storage . setItem ( "clipboard" , JSON . stringify ( this . items ) ) ;
0 commit comments