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
Pleroma
mastofe
Commits
4b041c15
Verified
Commit
4b041c15
authored
Jun 30, 2020
by
Haelwenn
Browse files
initial_state: sync notifications.shows with pleroma notification_settings
lodash suggestion from Alex Gleason
parent
cfefd0ae
Pipeline
#27911
passed with stage
in 4 minutes and 47 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
app/javascript/flavours/glitch/actions/settings.js
View file @
4b041c15
...
...
@@ -25,7 +25,10 @@ const debouncedSave = debounce((dispatch, getState) => {
const
data
=
getState
().
get
(
'
settings
'
).
filter
((
_
,
path
)
=>
path
!==
'
saved
'
).
toJS
();
api
(
getState
).
put
(
'
/api/pleroma/notification_settings
'
,
{
exclude_types
:
excludeTypesFromSettings
(
getState
())
});
api
(
getState
).
put
(
'
/api/pleroma/notification_settings
'
,
{
exclude_types
:
excludeTypesFromSettings
(
getState
())
}
).
catch
(
error
=>
dispatch
(
showAlertForError
(
error
)));
api
(
getState
).
put
(
'
/api/web/settings
'
,
{
data
})
.
then
(()
=>
dispatch
({
type
:
SETTING_SAVE
}))
...
...
app/javascript/flavours/glitch/util/initial_state.js
View file @
4b041c15
import
{
get
,
set
}
from
'
lodash
'
;
const
maybeSetNotificationsSettings
=
result
=>
{
const
me
=
get
(
result
,
[
'
meta
'
,
'
me
'
]);
if
(
!
me
)
return
;
const
showTypes
=
get
(
result
,
[
'
settings
'
,
'
notifications
'
,
'
shows
'
],
{});
const
excludeTypes
=
get
(
result
,
[
'
accounts
'
,
me
,
'
pleroma
'
,
'
notification_settings
'
,
'
exclude_types
'
],
[]);
excludeTypes
.
forEach
(
x
=>
showTypes
[
x
]
=
false
);
set
(
result
,
[
'
settings
'
,
'
notifications
'
,
'
shows
'
],
showTypes
);
}
const
element
=
document
.
getElementById
(
'
initial-state
'
);
const
initialState
=
element
&&
function
()
{
const
result
=
JSON
.
parse
(
element
.
textContent
);
...
...
@@ -6,6 +19,7 @@ const initialState = element && function () {
}
catch
(
e
)
{
result
.
local_settings
=
{};
}
maybeSetNotificationsSettings
(
result
);
return
result
;
}();
...
...
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