Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Sharkey
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Dima Krasner
Sharkey
Commits
36170a11
Commit
36170a11
authored
2 years ago
by
tamaina
Browse files
Options
Downloads
Patches
Plain Diff
refactor(sw): self => globalThis
parent
0f546b47
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
packages/sw/src/scripts/create-notification.ts
+4
-4
4 additions, 4 deletions
packages/sw/src/scripts/create-notification.ts
packages/sw/src/scripts/operations.ts
+2
-2
2 additions, 2 deletions
packages/sw/src/scripts/operations.ts
packages/sw/src/sw.ts
+7
-7
7 additions, 7 deletions
packages/sw/src/sw.ts
with
13 additions
and
13 deletions
packages/sw/src/scripts/create-notification.ts
+
4
−
4
View file @
36170a11
...
...
@@ -23,7 +23,7 @@ export async function createNotification<K extends keyof pushNotificationDataMap
const
n
=
await
composeNotification
(
data
);
if
(
n
)
{
return
self
.
registration
.
showNotification
(...
n
);
return
globalThis
.
registration
.
showNotification
(...
n
);
}
else
{
console
.
error
(
'
Could not compose notification
'
,
data
);
return
createEmptyNotification
();
...
...
@@ -239,7 +239,7 @@ export async function createEmptyNotification() {
const
i18n
=
await
swLang
.
i18n
as
I18n
<
any
>
;
const
{
t
}
=
i18n
;
await
self
.
registration
.
showNotification
(
await
globalThis
.
registration
.
showNotification
(
t
(
'
_notification.emptyPushNotificationMessage
'
),
{
silent
:
true
,
...
...
@@ -253,8 +253,8 @@ export async function createEmptyNotification() {
setTimeout
(
async
()
=>
{
for
(
const
n
of
[
...(
await
self
.
registration
.
getNotifications
({
tag
:
'
user_visible_auto_notification
'
})),
...(
await
self
.
registration
.
getNotifications
({
tag
:
'
read_notification
'
})),
...(
await
globalThis
.
registration
.
getNotifications
({
tag
:
'
user_visible_auto_notification
'
})),
...(
await
globalThis
.
registration
.
getNotifications
({
tag
:
'
read_notification
'
})),
]
)
{
n
.
close
();
...
...
This diff is collapsed.
Click to expand it.
packages/sw/src/scripts/operations.ts
+
2
−
2
View file @
36170a11
...
...
@@ -51,11 +51,11 @@ export async function openClient(order: swMessageOrderType, url: string, loginId
return
client
;
}
return
self
.
clients
.
openWindow
(
getUrlWithLoginId
(
url
,
loginId
));
return
globalThis
.
clients
.
openWindow
(
getUrlWithLoginId
(
url
,
loginId
));
}
export
async
function
findClient
()
{
const
clients
=
await
self
.
clients
.
matchAll
({
const
clients
=
await
globalThis
.
clients
.
matchAll
({
type
:
'
window
'
,
});
for
(
const
c
of
clients
)
{
...
...
This diff is collapsed.
Click to expand it.
packages/sw/src/sw.ts
+
7
−
7
View file @
36170a11
...
...
@@ -6,7 +6,7 @@ import * as swos from '@/scripts/operations';
import
{
acct
as
getAcct
}
from
'
@/filters/user
'
;
globalThis
.
addEventListener
(
'
install
'
,
ev
=>
{
//ev.waitUntil(
self
.skipWaiting());
//ev.waitUntil(
globalThis
.skipWaiting());
});
globalThis
.
addEventListener
(
'
activate
'
,
ev
=>
{
...
...
@@ -17,7 +17,7 @@ globalThis.addEventListener('activate', ev => {
.
filter
((
v
)
=>
v
!==
swLang
.
cacheName
)
.
map
(
name
=>
caches
.
delete
(
name
)),
))
.
then
(()
=>
self
.
clients
.
claim
()),
.
then
(()
=>
globalThis
.
clients
.
claim
()),
);
});
...
...
@@ -40,7 +40,7 @@ globalThis.addEventListener('fetch', ev => {
globalThis
.
addEventListener
(
'
push
'
,
ev
=>
{
// クライアント取得
ev
.
waitUntil
(
self
.
clients
.
matchAll
({
ev
.
waitUntil
(
globalThis
.
clients
.
matchAll
({
includeUncontrolled
:
true
,
type
:
'
window
'
,
}).
then
(
async
(
clients
:
readonly
WindowClient
[])
=>
{
...
...
@@ -58,24 +58,24 @@ globalThis.addEventListener('push', ev => {
return
createNotification
(
data
);
case
'
readAllNotifications
'
:
for
(
const
n
of
await
self
.
registration
.
getNotifications
())
{
for
(
const
n
of
await
globalThis
.
registration
.
getNotifications
())
{
if
(
n
?.
data
?.
type
===
'
notification
'
)
n
.
close
();
}
break
;
case
'
readAllAntennas
'
:
for
(
const
n
of
await
self
.
registration
.
getNotifications
())
{
for
(
const
n
of
await
globalThis
.
registration
.
getNotifications
())
{
if
(
n
?.
data
?.
type
===
'
unreadAntennaNote
'
)
n
.
close
();
}
break
;
case
'
readNotifications
'
:
for
(
const
n
of
await
self
.
registration
.
getNotifications
())
{
for
(
const
n
of
await
globalThis
.
registration
.
getNotifications
())
{
if
(
data
.
body
.
notificationIds
.
includes
(
n
.
data
.
body
.
id
))
{
n
.
close
();
}
}
break
;
case
'
readAntenna
'
:
for
(
const
n
of
await
self
.
registration
.
getNotifications
())
{
for
(
const
n
of
await
globalThis
.
registration
.
getNotifications
())
{
if
(
n
?.
data
?.
type
===
'
unreadAntennaNote
'
&&
data
.
body
.
antennaId
===
n
.
data
.
body
.
antenna
.
id
)
{
n
.
close
();
}
...
...
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