Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Romain Courteaud
erp5
Commits
1fad1847
Commit
1fad1847
authored
Jun 08, 2019
by
Yusei Tahara
Committed by
Romain Courteaud
Feb 27, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[erp5_web_renderjs_ui] Clean up service worker code. Remove many `if`.
parent
e2ad4e37
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
40 deletions
+35
-40
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_serviceworker.js
...lateItem/web_page_module/rjs_gadget_erp5_serviceworker.js
+33
-38
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_serviceworker.xml
...ateItem/web_page_module/rjs_gadget_erp5_serviceworker.xml
+2
-2
No files found.
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_serviceworker.js
View file @
1fad1847
...
@@ -272,48 +272,43 @@
...
@@ -272,48 +272,43 @@
.
then
(
function
()
{
.
then
(
function
()
{
if
(
!
CACHE_KEY
)
{
if
(
!
CACHE_KEY
)
{
// CLIENT_CACHE_MAPPING_NAME stores CACHE_KEY of each client.
// CLIENT_CACHE_MAPPING_NAME stores CACHE_KEY of each client.
return
caches
.
open
(
CLIENT_CACHE_MAPPING_NAME
);
return
caches
.
open
(
CLIENT_CACHE_MAPPING_NAME
)
}
.
then
(
function
(
erp5js_cache
)
{
})
// Service worker forget everything when it stops. So, when it started
.
then
(
function
(
erp5js_cache
)
{
// again, CACHE_MAP is empty, get the associated CACHE_KEY from the
if
(
erp5js_cache
)
{
// special Cache named CLIENT_CACHE_MAPPING_NAME.
// Service worker forget everything when it stops. So, when it started
ERP5JS_CACHE
=
erp5js_cache
;
// again, CACHE_MAP is empty, get the associated CACHE_KEY from the
return
erp5js_cache
.
match
(
client_id
)
// special Cache named CLIENT_CACHE_MAPPING_NAME.
.
then
(
function
(
response
)
{
ERP5JS_CACHE
=
erp5js_cache
;
if
(
response
)
{
return
erp5js_cache
.
match
(
client_id
);
// We use Cache Storage as a persistent database.
}
CACHE_KEY
=
response
.
statusText
;
})
CACHE_MAP
[
client_id
]
=
CACHE_KEY
;
.
then
(
function
(
response
)
{
console
.
log
(
"
CACHE_KEY from Cache Storage
"
+
CACHE_KEY
);
if
(
response
)
{
}
// We use Cache Storage as a persistent database.
})
CACHE_KEY
=
response
.
statusText
;
})
CACHE_MAP
[
client_id
]
=
CACHE_KEY
;
console
.
log
(
"
CACHE_KEY from Cache Storage
"
+
CACHE_KEY
);
}
}
})
})
.
then
(
function
()
{
.
then
(
function
()
{
if
(
CACHE_KEY
)
{
return
[];
}
// If associated CACHE_KEY is not found, it means this client is a new one.
// Let's find the latest Cache.
return
caches
.
keys
();
})
.
then
(
function
(
keys
)
{
if
(
!
CACHE_KEY
)
{
if
(
!
CACHE_KEY
)
{
keys
=
keys
.
filter
(
function
(
key
)
{
return
key
.
startsWith
(
prefix
);
});
// If associated CACHE_KEY is not found, it means this client is a new one.
console
.
log
(
"
KEYS =
"
+
keys
);
// Let's find the latest Cache.
if
(
keys
.
length
)
{
return
caches
.
keys
()
CACHE_KEY
=
keys
.
sort
().
reverse
()[
0
];
.
then
(
function
(
keys
)
{
CACHE_MAP
[
client_id
]
=
CACHE_KEY
;
keys
=
keys
.
filter
(
function
(
key
)
{
return
key
.
startsWith
(
prefix
);
});
}
else
{
console
.
log
(
"
KEYS =
"
+
keys
);
CACHE_KEY
=
CACHE_NAME
;
if
(
keys
.
length
)
{
CACHE_MAP
[
client_id
]
=
CACHE_NAME
;
CACHE_KEY
=
keys
.
sort
().
reverse
()[
0
];
}
CACHE_MAP
[
client_id
]
=
CACHE_KEY
;
// Save the associated CACHE_KEY in a persistent database because service
}
else
{
// worker forget everything when it stops.
CACHE_KEY
=
CACHE_NAME
;
ERP5JS_CACHE
.
put
(
client_id
,
new
Response
(
null
,
{
"
statusText
"
:
CACHE_KEY
}));
CACHE_MAP
[
client_id
]
=
CACHE_NAME
;
}
// Save the associated CACHE_KEY in a persistent database because service
// worker forget everything when it stops.
ERP5JS_CACHE
.
put
(
client_id
,
new
Response
(
null
,
{
"
statusText
"
:
CACHE_KEY
}));
})
}
}
})
})
.
then
(
function
()
{
.
then
(
function
()
{
...
...
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_serviceworker.xml
View file @
1fad1847
...
@@ -228,7 +228,7 @@
...
@@ -228,7 +228,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
serial
</string>
</key>
<key>
<string>
serial
</string>
</key>
<value>
<string>
976.15
482.50361.5220
6
</string>
</value>
<value>
<string>
976.15
605.32654.4947
6
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
state
</string>
</key>
<key>
<string>
state
</string>
</key>
...
@@ -246,7 +246,7 @@
...
@@ -246,7 +246,7 @@
</tuple>
</tuple>
<state>
<state>
<tuple>
<tuple>
<float>
15599
17201.4
</float>
<float>
15599
24528.42
</float>
<string>
UTC
</string>
<string>
UTC
</string>
</tuple>
</tuple>
</state>
</state>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment