Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
pleroma-fe
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository 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
Joseph Nuthalapati
pleroma-fe
Commits
11716a7a
Commit
11716a7a
authored
6 years ago
by
minibikini
Browse files
Options
Downloads
Patches
Plain Diff
second attempt to add subscribe module and fix race condition
parent
a85d128d
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
src/main.js
+4
-2
4 additions, 2 deletions
src/main.js
src/modules/pushNotifications.js
+29
-0
29 additions, 0 deletions
src/modules/pushNotifications.js
src/modules/users.js
+4
-4
4 additions, 4 deletions
src/modules/users.js
with
37 additions
and
6 deletions
src/main.js
+
4
−
2
View file @
11716a7a
...
...
@@ -10,6 +10,7 @@ import apiModule from './modules/api.js'
import
configModule
from
'
./modules/config.js
'
import
chatModule
from
'
./modules/chat.js
'
import
oauthModule
from
'
./modules/oauth.js
'
import
pushNotificationsModule
from
'
./modules/pushNotifications.js
'
import
VueTimeago
from
'
vue-timeago
'
import
VueI18n
from
'
vue-i18n
'
...
...
@@ -60,12 +61,13 @@ createPersistedState(persistedStateOptions).then((persistedState) => {
api
:
apiModule
,
config
:
configModule
,
chat
:
chatModule
,
oauth
:
oauthModule
oauth
:
oauthModule
,
pushNotifications
:
pushNotificationsModule
},
plugins
:
[
persistedState
],
strict
:
false
// Socket modifies itself, let's ignore this for now.
// strict: process.env.NODE_ENV !== 'production'
})
afterStoreSetup
({
store
,
i18n
})
afterStoreSetup
({
store
,
i18n
})
})
This diff is collapsed.
Click to expand it.
src/modules/pushNotifications.js
0 → 100644
+
29
−
0
View file @
11716a7a
import
registerPushNotifications
from
'
../services/push/push.js
'
const
subscribe
=
{
state
:
{
token
:
null
,
vapidPublicKey
:
null
},
mutations
:
{
setApiToken
(
state
,
user
)
{
state
.
token
=
user
.
credentials
},
setVapidPublicKey
(
state
,
vapidPublicKey
)
{
state
.
vapidPublicKey
=
vapidPublicKey
}
},
actions
:
{
setInstanceOption
(
store
,
{
name
,
value
})
{
store
.
commit
(
'
setVapidPublicKey
'
,
value
)
if
(
store
.
state
.
token
)
registerPushNotifications
(
this
)
},
setCurrentUser
(
store
,
user
)
{
store
.
commit
(
'
setApiToken
'
,
user
.
credentials
)
if
(
store
.
state
.
vapidPublicKey
)
registerPushNotifications
(
this
)
}
}
}
export
default
subscribe
This diff is collapsed.
Click to expand it.
src/modules/users.js
+
4
−
4
View file @
11716a7a
import
backendInteractorService
from
'
../services/backend_interactor_service/backend_interactor_service.js
'
import
registerPushNotifications
from
'
../services/push/push.js
'
import
{
compact
,
map
,
each
,
merge
}
from
'
lodash
'
import
{
set
}
from
'
vue
'
...
...
@@ -87,6 +86,9 @@ const users = {
store
.
dispatch
(
'
stopFetching
'
,
'
friends
'
)
store
.
commit
(
'
setBackendInteractor
'
,
backendInteractorService
())
},
setCurrentUser
(
store
,
user
)
{
store
.
commit
(
'
setCurrentUser
'
,
user
)
},
loginUser
(
store
,
accessToken
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
const
commit
=
store
.
commit
...
...
@@ -98,7 +100,7 @@ const users = {
.
then
((
user
)
=>
{
// user.credentials = userCredentials
user
.
credentials
=
accessToken
commit
(
'
setCurrentUser
'
,
user
)
store
.
dispatch
(
'
setCurrentUser
'
,
user
)
commit
(
'
addNewUsers
'
,
[
user
])
// Set our new backend interactor
...
...
@@ -122,8 +124,6 @@ const users = {
// Fetch our friends
store
.
rootState
.
api
.
backendInteractor
.
fetchFriends
({
id
:
user
.
id
})
.
then
((
friends
)
=>
commit
(
'
addNewUsers
'
,
friends
))
registerPushNotifications
(
store
)
})
}
else
{
// Authentication failed
...
...
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