Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Haelwenn
glitchsoc-fe
Commits
1abf89be
Verified
Commit
1abf89be
authored
Apr 01, 2018
by
Morgan Bazalgette
Committed by
Haelwenn
Jun 04, 2018
Browse files
Hopefully fix the homepage being loaded issue
parent
9b9e7d1b
Changes
1
Hide whitespace changes
Inline
Side-by-side
app/javascript/mastodon/service_worker/entry.js
View file @
1abf89be
...
...
@@ -10,7 +10,7 @@ function openWebCache() {
}
function
fetchRoot
()
{
return
fetch
(
'
/
'
,
{
credentials
:
'
include
'
,
redirect
:
'
manual
'
});
return
fetch
(
'
/
web
'
,
{
credentials
:
'
include
'
,
redirect
:
'
manual
'
});
}
const
firefox
=
navigator
.
userAgent
.
match
(
/Firefox
\/(\d
+
)
/
);
...
...
@@ -19,7 +19,7 @@ const invalidOnlyIfCached = firefox && firefox[1] < 60;
// Cause a new version of a registered Service Worker to replace an existing one
// that is already installed, and replace the currently active worker on open pages.
self
.
addEventListener
(
'
install
'
,
function
(
event
)
{
event
.
waitUntil
(
Promise
.
all
([
openWebCache
(),
fetchRoot
()]).
then
(([
cache
,
root
])
=>
cache
.
put
(
'
/
'
,
root
)));
event
.
waitUntil
(
Promise
.
all
([
openWebCache
(),
fetchRoot
()]).
then
(([
cache
,
root
])
=>
cache
.
put
(
'
/
web
'
,
root
)));
});
self
.
addEventListener
(
'
activate
'
,
function
(
event
)
{
event
.
waitUntil
(
self
.
clients
.
claim
());
...
...
@@ -27,14 +27,14 @@ self.addEventListener('activate', function(event) {
self
.
addEventListener
(
'
fetch
'
,
function
(
event
)
{
const
url
=
new
URL
(
event
.
request
.
url
);
if
(
url
.
pathname
.
startsWith
(
'
/web
/
'
))
{
if
(
url
.
pathname
.
startsWith
(
'
/web
'
))
{
const
asyncResponse
=
fetchRoot
();
const
asyncCache
=
openWebCache
();
event
.
respondWith
(
asyncResponse
.
then
(
response
=>
asyncCache
.
then
(
cache
=>
cache
.
put
(
'
/
'
,
response
.
clone
()))
response
=>
asyncCache
.
then
(
cache
=>
cache
.
put
(
'
/
web
'
,
response
.
clone
()))
.
then
(()
=>
response
),
()
=>
asyncCache
.
then
(
cache
=>
cache
.
match
(
'
/
'
))));
()
=>
asyncCache
.
then
(
cache
=>
cache
.
match
(
'
/
web
'
))));
}
else
if
(
url
.
pathname
===
'
/auth/sign_out
'
)
{
const
asyncResponse
=
fetch
(
event
.
request
);
const
asyncCache
=
openWebCache
();
...
...
@@ -42,7 +42,7 @@ self.addEventListener('fetch', function(event) {
event
.
respondWith
(
asyncResponse
.
then
(
response
=>
{
if
(
response
.
ok
||
response
.
type
===
'
opaqueredirect
'
)
{
return
Promise
.
all
([
asyncCache
.
then
(
cache
=>
cache
.
delete
(
'
/
'
)),
asyncCache
.
then
(
cache
=>
cache
.
delete
(
'
/
web
'
)),
indexedDB
.
deleteDatabase
(
'
mastodon
'
),
]).
then
(()
=>
response
);
}
...
...
Write
Preview
Supports
Markdown
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