<commit_before>import React from 'react';
import PropTypes from 'prop-types';
import { c } from 'ttag';
import { Toggle, useApi, useLoading, useEventManager, useNotifications } from 'react-components';
import { updateLabel } from 'proton-shared/lib/api/labels';

const ToggleNotify = ({ label }) => {
    const api = useApi();
    const { call } = useEventManager();
    const { createNotification } = useNotifications();
    const [loading, withLoading] = useLoading();

    const handleChange = async ({ target }) => {
        const newLabel = {
            ...label,
            Notify: +target.checked
        };
        await api(updateLabel(label.ID, newLabel));
        await call();
        createNotification({
            text: c('label/folder notification').t`${label.Name} updated`
        });
    };
    return (
        <Toggle
            id={`item-${label.ID}`}
            checked={label.Notify === 1}
            onChange={(e) => withLoading(handleChange(e))}
            loading={loading}
        />
    );
};

ToggleNotify.propTypes = {
    label: PropTypes.object.isRequired
};

export default ToggleNotify;
<commit_msg>Wrap ToggleNotify with a tooltip<commit_after>import React from 'react';
import PropTypes from 'prop-types';
import { c } from 'ttag';
import { Tooltip, Toggle, useApi, useLoading, useEventManager, useNotifications } from 'react-components';
import { updateLabel } from 'proton-shared/lib/api/labels';

const ToggleNotify = ({ label }) => {
    const api = useApi();
    const { call } = useEventManager();
    const { createNotification } = useNotifications();
    const [loading, withLoading] = useLoading();

    const handleChange = async ({ target }) => {
        const newLabel = {
            ...label,
            Notify: +target.checked
        };
        await api(updateLabel(label.ID, newLabel));
        await call();
        createNotification({
            text: c('label/folder notification').t`${label.Name} updated`
        });
    };
    return (
        <Tooltip title={c('Tooltip').t`Enable/disable desktop and mobile notifications`}>
            <Toggle
                id={`item-${label.ID}`}
                checked={label.Notify === 1}
                onChange={(e) => withLoading(handleChange(e))}
                loading={loading}
            />
        </Tooltip>
    );
};

ToggleNotify.propTypes = {
    label: PropTypes.object.isRequired
};

export default ToggleNotify;

{'fraction_non_alphanumeric': 0.1395824805566926, 'fraction_numerical': 0.0008186655751125665, 'mean_word_length': 2.5114942528735633, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6715625', 'n_tokens_mistral': 672, 'n_tokens_neox': 675, 'n_words': 158}