Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
client
Commits
44428b58
Commit
44428b58
authored
2 years ago
by
Jono Wenger
Browse files
Options
Downloads
Patches
Plain Diff
Replace saving NDF to ekv in Javascript with local storage
parent
466ab010
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!510
Release
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
storage/utility/NDF.go
+3
-0
3 additions, 0 deletions
storage/utility/NDF.go
storage/utility/NDF_js.go
+40
-0
40 additions, 0 deletions
storage/utility/NDF_js.go
with
43 additions
and
0 deletions
storage/utility/NDF.go
+
3
−
0
View file @
44428b58
...
...
@@ -5,6 +5,9 @@
// LICENSE file. //
////////////////////////////////////////////////////////////////////////////////
// This file is compiled for all architectures except WebAssembly.
//go:build !js || !wasm
package
utility
import
(
...
...
This diff is collapsed.
Click to expand it.
storage/utility/NDF_js.go
0 → 100644
+
40
−
0
View file @
44428b58
////////////////////////////////////////////////////////////////////////////////
// Copyright © 2022 xx foundation //
// //
// Use of this source code is governed by a license that can be found in the //
// LICENSE file. //
////////////////////////////////////////////////////////////////////////////////
package
utility
import
(
"gitlab.com/elixxir/client/storage/versioned"
"gitlab.com/xx_network/primitives/ndf"
"os"
"syscall/js"
)
const
NdfStorageKeyNamePrefix
=
"ndfStorageKey/"
var
localStorage
=
js
.
Global
()
.
Get
(
"localStorage"
)
func
LoadNDF
(
_
*
versioned
.
KV
,
key
string
)
(
*
ndf
.
NetworkDefinition
,
error
)
{
keyValue
:=
localStorage
.
Call
(
"getItem"
,
NdfStorageKeyNamePrefix
+
key
)
if
keyValue
.
IsNull
()
{
return
nil
,
os
.
ErrNotExist
}
return
ndf
.
Unmarshal
([]
byte
(
keyValue
.
String
()))
}
func
SaveNDF
(
_
*
versioned
.
KV
,
key
string
,
ndf
*
ndf
.
NetworkDefinition
)
error
{
marshaled
,
err
:=
ndf
.
Marshal
()
if
err
!=
nil
{
return
err
}
localStorage
.
Call
(
"setItem"
,
NdfStorageKeyNamePrefix
+
key
,
string
(
marshaled
))
return
nil
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment