Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: [#174160259] Switch label to change text on switch value change #2168

Merged
merged 4 commits into from
Aug 31, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions ts/screens/services/ServiceDetailsScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,8 @@ class ServiceDetailsScreen extends React.Component<Props, State> {
private service = this.props.navigation.getParam("service");

// finds out which channels are enabled in the user profile
private profileEnabledChannels = getEnabledChannelsForService(
this.props.profile,
this.serviceId
);
private profileEnabledChannels = () =>
getEnabledChannelsForService(this.props.profile, this.serviceId);

// whether last attempt to save the preferences failed
private profileVersion = pot
Expand Down Expand Up @@ -446,16 +444,18 @@ class ServiceDetailsScreen extends React.Component<Props, State> {
private getInboxSwitchRow = () => {
const isDisabled =
// the preference can be updated if
// natifications are globally disabled or
// notifications are globally disabled or
!this.props.isInboxEnabled ||
// profile is updating
pot.isUpdating(this.props.profile);

const isSwitchedOn =
// inbox is globally disabled or
// inbox is globally enabled and
this.props.isInboxEnabled &&
// inbox is disabled for the given service
this.state.uiEnabledChannels.inbox;
// inbox is enabled for the given service
this.state.uiEnabledChannels.inbox &&
// inbox is enabled for the profile
this.profileEnabledChannels().inbox;

const onValueChange = (value: boolean) => {
if (!value && !this.props.wasServiceAlertDisplayedOnce) {
Expand All @@ -476,7 +476,7 @@ class ServiceDetailsScreen extends React.Component<Props, State> {
bold={true}
style={isSwitchedOn ? styles.enabledColor : styles.disabledColor}
>
{this.profileEnabledChannels.inbox
{isSwitchedOn
? I18n.t("services.serviceIsEnabled")
: I18n.t("services.serviceNotEnabled")}
</Text>
Expand Down