<commit_before>import * as React from 'react';
import { Token } from '../models/misskey';
import AuthForm, { IAuthFormProps } from './AuthForm';
import PostFrom from './PostForm';
import { IConfig, appConfig, loadUserConfig, saveUserConfig } from '../models/config';
import { Match } from 'satch';
import FixedContainer from './FixedContainer';
const remote = require('remote');
const mui = require('material-ui');
const ThemeManager = new mui.Styles.ThemeManager();
const { AppBar, IconButton } = mui;
const NavigationClose = require('material-ui/lib/svg-icons/navigation/close');

interface IAppState {
	token?: Token;
	ready?: boolean;
	existToken?: boolean;
	config?: IConfig;
}

export default class App extends React.Component<{}, IAppState> {
	constructor(props?: {}, context?: any) {
		super(props, context);
		this.state = {
			ready: false,
			existToken: false
		};
		(window as any).app = this; // debug
	}

	static childContextTypes: React.ValidationMap<any> = {
		muiTheme: React.PropTypes.object
	};

	getChildContext() {
		return {
			muiTheme: ThemeManager.getCurrentTheme()
		};
	}

	componentDidMount() {
		loadUserConfig().then(userConfig => {
			const mergedConfig: IConfig = Object.assign(appConfig, userConfig);
			const existUserKey = mergedConfig.userKey !== void 0;
			if (existUserKey) {
				this.setState({
					ready: true,
					token: new Token(mergedConfig.appKey, mergedConfig.userKey),
					existToken: true,
					config: mergedConfig
				});
			} else {
				this.setState({
					ready: true,
					config: mergedConfig
				});
			}
			remote.getCurrentWindow().show();
		});
	}

	onGetToken(token: Token) {
		this.setState({
			token,
			existToken: true
		});
		loadUserConfig().then(userConfig => {
			userConfig.userKey = token.userKey;
			saveUserConfig(userConfig);
		});
	}

	updateStatus(text: string) {
		this.state.token.status.update(text);
	}

	onClickCloseButton() {
		setTimeout(() => remote.getCurrentWindow().close(), 256);
	}

	render() {
		return (
			<FixedContainer>
				<AppBar
					title='Disskey'
					showMenuIconButton={false}
					iconElementRight={
						<IconButton style={{WebkitAppRegion: 'no-drag'}} onClick={this.onClickCloseButton}>
							<NavigationClose />
						</IconButton>
					}
					style={{WebkitAppRegion: 'drag'}} />
				<div style={{margin: '0 32px'} as any}>{
					new Match<any, React.DOMElement<React.HTMLAttributes> | React.ReactElement<IAuthFormProps>>(null)
						.when(() => !this.state.ready, () => <div></div>)
						.when(() => !this.state.existToken, () =>
							<AuthForm
								appKey={this.state.config.appKey}
								onGetToken={this.onGetToken.bind(this)} />
						)
						.default(() =>
							<PostFrom onSubmit={this.updateStatus.bind(this)} />
						)
				}</div>
			</FixedContainer>
		);
	}
}<commit_msg>Show scroll bar<commit_after>import * as React from 'react';
import { Token } from '../models/misskey';
import AuthForm, { IAuthFormProps } from './AuthForm';
import PostFrom from './PostForm';
import { IConfig, appConfig, loadUserConfig, saveUserConfig } from '../models/config';
import { Match } from 'satch';
import FixedContainer from './FixedContainer';
const remote = require('remote');
const mui = require('material-ui');
const ThemeManager = new mui.Styles.ThemeManager();
const { AppBar, IconButton } = mui;
const NavigationClose = require('material-ui/lib/svg-icons/navigation/close');

interface IAppState {
	token?: Token;
	ready?: boolean;
	existToken?: boolean;
	config?: IConfig;
}

export default class App extends React.Component<{}, IAppState> {
	constructor(props?: {}, context?: any) {
		super(props, context);
		this.state = {
			ready: false,
			existToken: false
		};
		(window as any).app = this; // debug
	}

	static childContextTypes: React.ValidationMap<any> = {
		muiTheme: React.PropTypes.object
	};

	getChildContext() {
		return {
			muiTheme: ThemeManager.getCurrentTheme()
		};
	}

	componentDidMount() {
		loadUserConfig().then(userConfig => {
			const mergedConfig: IConfig = Object.assign(appConfig, userConfig);
			const existUserKey = mergedConfig.userKey !== void 0;
			if (existUserKey) {
				this.setState({
					ready: true,
					token: new Token(mergedConfig.appKey, mergedConfig.userKey),
					existToken: true,
					config: mergedConfig
				});
			} else {
				this.setState({
					ready: true,
					config: mergedConfig
				});
			}
			remote.getCurrentWindow().show();
		});
	}

	onGetToken(token: Token) {
		this.setState({
			token,
			existToken: true
		});
		loadUserConfig().then(userConfig => {
			userConfig.userKey = token.userKey;
			saveUserConfig(userConfig);
		});
	}

	updateStatus(text: string) {
		this.state.token.status.update(text);
	}

	onClickCloseButton() {
		setTimeout(() => remote.getCurrentWindow().close(), 256);
	}

	render() {
		return (
			<FixedContainer>
				<AppBar
					title='Disskey'
					showMenuIconButton={false}
					iconElementRight={
						<IconButton style={{WebkitAppRegion: 'no-drag'}} onClick={this.onClickCloseButton}>
							<NavigationClose />
						</IconButton>
					}
					style={{WebkitAppRegion: 'drag'}} />
				<FixedContainer style={{top: '64px', padding: '0 32px', overflowY: 'scroll'} as any}>{
					new Match<any, React.DOMElement<React.HTMLAttributes> | React.ReactElement<IAuthFormProps>>(null)
						.when(() => !this.state.ready, () => <div></div>)
						.when(() => !this.state.existToken, () =>
							<AuthForm
								appKey={this.state.config.appKey}
								onGetToken={this.onGetToken.bind(this)} />
						)
						.default(() =>
							<PostFrom onSubmit={this.updateStatus.bind(this)} />
						)
				}</FixedContainer>
			</FixedContainer>
		);
	}
}
{'fraction_non_alphanumeric': 0.15547329455314648, 'fraction_numerical': 0.0028203772254539045, 'mean_word_length': 3.624286878565607, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 53, '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': '1321564', 'n_tokens_mistral': 2172, 'n_tokens_neox': 1793, 'n_words': 362}