mirror of
https://github.com/wassname/talk.git
synced 2026-07-01 22:24:08 +08:00
Added support for forcing the notification settings pane
This commit is contained in:
@@ -13,6 +13,25 @@ const {
|
||||
|
||||
const { RECAPTCHA_PUBLIC, WEBSOCKET_LIVE_URI } = require('../config');
|
||||
|
||||
// Grab TALK_CLIENT_* environment variables.
|
||||
const TALK_CLIENT = /^TALK_CLIENT_/i;
|
||||
|
||||
// TALK_CLIENT_ENV is all the environment keys that are loaded at runtime.
|
||||
const TALK_CLIENT_ENV = Object.keys(process.env)
|
||||
.filter(key => TALK_CLIENT.test(key))
|
||||
.reduce(
|
||||
(env, key) => {
|
||||
env[key] = process.env[key];
|
||||
return env;
|
||||
},
|
||||
{
|
||||
TALK_RECAPTCHA_PUBLIC: RECAPTCHA_PUBLIC,
|
||||
LIVE_URI: WEBSOCKET_LIVE_URI,
|
||||
STATIC_URL,
|
||||
STATIC_ORIGIN,
|
||||
}
|
||||
);
|
||||
|
||||
// TEMPLATE_LOCALS stores the static data that is provided as a `text/json` on
|
||||
// to the client from the template.
|
||||
const TEMPLATE_LOCALS = {
|
||||
@@ -20,12 +39,8 @@ const TEMPLATE_LOCALS = {
|
||||
BASE_PATH,
|
||||
MOUNT_PATH,
|
||||
STATIC_URL,
|
||||
data: {
|
||||
TALK_RECAPTCHA_PUBLIC: RECAPTCHA_PUBLIC,
|
||||
LIVE_URI: WEBSOCKET_LIVE_URI,
|
||||
STATIC_URL,
|
||||
STATIC_ORIGIN,
|
||||
},
|
||||
TALK_CLIENT_ENV,
|
||||
data: TALK_CLIENT_ENV,
|
||||
};
|
||||
|
||||
// attachStaticLocals will attach the locals to the response only.
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
export const pluginsConfigSelector = state => state.config.plugins_config;
|
||||
export const staticConfigSelector = state => state.config.static;
|
||||
|
||||
@@ -9,6 +9,8 @@ import {
|
||||
} from 'plugin-api/beta/client/hocs';
|
||||
import { getSlotFragmentSpreads } from 'plugin-api/beta/client/utils';
|
||||
import { withUpdateNotificationSettings } from '../mutations';
|
||||
import { connect } from 'plugin-api/beta/client/hocs';
|
||||
import { staticConfigSelector } from 'plugin-api/beta/client/selectors';
|
||||
|
||||
const slots = ['notificationSettings'];
|
||||
|
||||
@@ -42,8 +44,11 @@ class SettingsContainer extends React.Component {
|
||||
};
|
||||
|
||||
getNeedEmailVerification() {
|
||||
return !this.props.root.me.profiles.some(
|
||||
profile => profile.provider === 'local' && profile.confirmedAt
|
||||
return (
|
||||
this.props.root.settings.notificationsRequireConfirmation &&
|
||||
!this.props.root.me.profiles.some(
|
||||
profile => profile.provider === 'local' && profile.confirmedAt
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -94,11 +99,22 @@ const enhance = compose(
|
||||
}
|
||||
}
|
||||
}
|
||||
settings {
|
||||
notificationsRequireConfirmation
|
||||
}
|
||||
}
|
||||
`,
|
||||
}),
|
||||
// Grab the static configuration from the redux store.
|
||||
connect(state => ({
|
||||
static: staticConfigSelector(state),
|
||||
})),
|
||||
excludeIf(
|
||||
props =>
|
||||
// If the environment variable for TALK_CLIENT_FORCE_NOTIFICATION_SETTINGS
|
||||
// is `TRUE`, then always show it.
|
||||
props.static.TALK_CLIENT_FORCE_NOTIFICATION_SETTINGS !== 'TRUE' &&
|
||||
// Only show the settings pane if we have a local profile otherwise.
|
||||
!props.root.me.profiles.some(profile => profile.provider === 'local')
|
||||
),
|
||||
withUpdateNotificationSettings,
|
||||
|
||||
Reference in New Issue
Block a user