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
ec4d5857
Commit
ec4d5857
authored
4 years ago
by
syuilo
Browse files
Options
Downloads
Patches
Plain Diff
Fix service worker generation
parent
45766411
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/client/sw/compose-notification.ts
+90
-0
90 additions, 0 deletions
src/client/sw/compose-notification.ts
src/client/sw/i18n.ts
+3
-0
3 additions, 0 deletions
src/client/sw/i18n.ts
src/client/sw/sw.ts
+1
-2
1 addition, 2 deletions
src/client/sw/sw.ts
webpack.config.ts
+1
-1
1 addition, 1 deletion
webpack.config.ts
with
95 additions
and
3 deletions
src/client/s
cripts
/compose-notification.ts
→
src/client/s
w
/compose-notification.ts
+
90
−
0
View file @
ec4d5857
import
getNoteSummary
from
'
../../misc/get-note-summary
'
;
import
getUserName
from
'
../../misc/get-user-name
'
;
import
{
clientDb
,
get
,
bulkGet
}
from
'
../db
'
;
const
getTranslation
=
(
text
:
string
):
Promise
<
string
>
=>
get
(
text
,
clientDb
.
i18n
);
import
{
i18n
}
from
'
@/sw/i18n
'
;
export
default
async
function
(
type
,
data
):
Promise
<
[
string
,
NotificationOptions
]
>
{
const
contexts
=
[
'
deletedNote
'
,
'
invisibleNote
'
,
'
withNFiles
'
,
'
poll
'
];
const
locale
=
Object
.
fromEntries
(
await
bulkGet
(
contexts
,
clientDb
.
i18n
)
as
[
string
,
string
][]);
switch
(
type
)
{
case
'
driveFileCreated
'
:
// TODO (Server Side)
return
[
await
getTranslation
(
'
_notification.fileUploaded
'
),
{
return
[
i18n
.
t
(
'
_notification.fileUploaded
'
),
{
body
:
data
.
name
,
icon
:
data
.
url
}];
case
'
notification
'
:
switch
(
data
.
type
)
{
case
'
mention
'
:
return
[
(
await
getTranslation
(
'
_notification.youGotMention
'
)).
replace
(
'
{
name
}
'
,
getUserName
(
data
.
user
)),
{
body
:
getNoteSummary
(
data
.
note
,
locale
),
return
[
i18n
.
t
(
'
_notification.youGotMention
'
,
{
name
:
getUserName
(
data
.
user
)
}
),
{
body
:
getNoteSummary
(
data
.
note
,
i18n
.
locale
),
icon
:
data
.
user
.
avatarUrl
}];
case
'
reply
'
:
return
[
(
await
getTranslation
(
'
_notification.youGotReply
'
)).
replace
(
'
{
name
}
'
,
getUserName
(
data
.
user
)),
{
body
:
getNoteSummary
(
data
.
note
,
locale
),
return
[
i18n
.
t
(
'
_notification.youGotReply
'
,
{
name
:
getUserName
(
data
.
user
)
}
),
{
body
:
getNoteSummary
(
data
.
note
,
i18n
.
locale
),
icon
:
data
.
user
.
avatarUrl
}];
case
'
renote
'
:
return
[
(
await
getTranslation
(
'
_notification.youRenoted
'
)).
replace
(
'
{
name
}
'
,
getUserName
(
data
.
user
)),
{
body
:
getNoteSummary
(
data
.
note
,
locale
),
return
[
i18n
.
t
(
'
_notification.youRenoted
'
,
{
name
:
getUserName
(
data
.
user
)
}
),
{
body
:
getNoteSummary
(
data
.
note
,
i18n
.
locale
),
icon
:
data
.
user
.
avatarUrl
}];
case
'
quote
'
:
return
[
(
await
getTranslation
(
'
_notification.youGotQuote
'
)).
replace
(
'
{
name
}
'
,
getUserName
(
data
.
user
)),
{
body
:
getNoteSummary
(
data
.
note
,
locale
),
return
[
i18n
.
t
(
'
_notification.youGotQuote
'
,
{
name
:
getUserName
(
data
.
user
)
}
),
{
body
:
getNoteSummary
(
data
.
note
,
i18n
.
locale
),
icon
:
data
.
user
.
avatarUrl
}];
case
'
reaction
'
:
return
[
`
${
data
.
reaction
}
${
getUserName
(
data
.
user
)}
`
,
{
body
:
getNoteSummary
(
data
.
note
,
locale
),
body
:
getNoteSummary
(
data
.
note
,
i18n
.
locale
),
icon
:
data
.
user
.
avatarUrl
}];
case
'
pollVote
'
:
return
[
(
await
getTranslation
(
'
_notification.youGotPoll
'
)).
replace
(
'
{
name
}
'
,
getUserName
(
data
.
user
)),
{
body
:
getNoteSummary
(
data
.
note
,
locale
),
return
[
i18n
.
t
(
'
_notification.youGotPoll
'
,
{
name
:
getUserName
(
data
.
user
)
}
),
{
body
:
getNoteSummary
(
data
.
note
,
i18n
.
locale
),
icon
:
data
.
user
.
avatarUrl
}];
case
'
follow
'
:
return
[
await
getTranslation
(
'
_notification.youWereFollowed
'
),
{
return
[
i18n
.
t
(
'
_notification.youWereFollowed
'
),
{
body
:
getUserName
(
data
.
user
),
icon
:
data
.
user
.
avatarUrl
}];
case
'
receiveFollowRequest
'
:
return
[
await
getTranslation
(
'
_notification.youReceivedFollowRequest
'
),
{
return
[
i18n
.
t
(
'
_notification.youReceivedFollowRequest
'
),
{
body
:
getUserName
(
data
.
user
),
icon
:
data
.
user
.
avatarUrl
}];
case
'
followRequestAccepted
'
:
return
[
await
getTranslation
(
'
_notification.yourFollowRequestAccepted
'
),
{
return
[
i18n
.
t
(
'
_notification.yourFollowRequestAccepted
'
),
{
body
:
getUserName
(
data
.
user
),
icon
:
data
.
user
.
avatarUrl
}];
case
'
groupInvited
'
:
return
[
await
getTranslation
(
'
_notification.youWereInvitedToGroup
'
),
{
return
[
i18n
.
t
(
'
_notification.youWereInvitedToGroup
'
),
{
body
:
data
.
group
.
name
}];
...
...
@@ -80,12 +75,12 @@ export default async function(type, data): Promise<[string, NotificationOptions]
}
case
'
unreadMessagingMessage
'
:
if
(
data
.
groupId
===
null
)
{
return
[
(
await
getTranslation
(
'
_notification.youGotMessagingMessageFromUser
'
)).
replace
(
'
{
name
}
'
,
getUserName
(
data
.
user
)),
{
return
[
i18n
.
t
(
'
_notification.youGotMessagingMessageFromUser
'
,
{
name
:
getUserName
(
data
.
user
)
}
),
{
icon
:
data
.
user
.
avatarUrl
,
tag
:
`messaging:user:
${
data
.
user
.
id
}
`
}];
}
return
[
(
await
getTranslation
(
'
_notification.youGotMessagingMessageFromGroup
'
)).
replace
(
'
{
name
}
'
,
data
.
group
.
name
),
{
return
[
i18n
.
t
(
'
_notification.youGotMessagingMessageFromGroup
'
,
{
name
:
data
.
group
.
name
}
),
{
icon
:
data
.
user
.
avatarUrl
,
tag
:
`messaging:group:
${
data
.
group
.
id
}
`
}];
...
...
This diff is collapsed.
Click to expand it.
src/client/sw/i18n.ts
0 → 100644
+
3
−
0
View file @
ec4d5857
import
{
I18n
}
from
'
@/i18n
'
;
export
const
i18n
=
new
I18n
(
_LOCALE_
);
This diff is collapsed.
Click to expand it.
src/client/sw.ts
→
src/client/sw
/sw
.ts
+
1
−
2
View file @
ec4d5857
...
...
@@ -3,9 +3,8 @@
*/
declare
var
self
:
ServiceWorkerGlobalScope
;
import
composeNotification
from
'
@/s
cripts
/compose-notification
'
;
import
composeNotification
from
'
@/s
w
/compose-notification
'
;
// eslint-disable-next-line no-undef
const
version
=
_VERSION_
;
const
cacheName
=
`mk-cache-
${
version
}
`
;
...
...
This diff is collapsed.
Click to expand it.
webpack.config.ts
+
1
−
1
View file @
ec4d5857
...
...
@@ -38,7 +38,7 @@ module.exports = Object.keys(isProduction ? locales : {
}).
map
(
lang
=>
({
entry
:
{
app
:
'
./src/client/init.ts
'
,
sw
:
'
./src/client/sw.ts
'
sw
:
'
./src/client/sw
/sw
.ts
'
},
module
:
{
rules
:
[{
...
...
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