<commit_before>import ExtensionOptions from './storage/ExtensionOptions';
import ThreadStorage from './storage/ThreadStorage';
import ChromeStorage from './storage/ChromeStorage';
import * as Utils from './utils';

/* This file should really be called 'eventScript' as it's only loaded when needed */

chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
	switch (request.method) {
		case 'ThreadStorage.getById':
			sendResponse(ThreadStorage.getById(request.threadId));
			break;
		case 'ThreadStorage.add':
			ThreadStorage.add(request.threadId);
			ThreadStorage.save();
			break;
		case 'ExtensionOptions.getAll':
			sendResponse({
				redirect: ExtensionOptions.getRedirect(),
				className: ExtensionOptions.getCSSClassName(),
				css: ExtensionOptions.getCSS(),
				clearComment: ExtensionOptions.getClearComment()
			});
			break;
		default:
			break;
	}
});

chrome.runtime.onInstalled.addListener(details => {
	if (details.reason === 'update') {
		if (details.version === chrome.app.getDetails().version) {
			return;
		}

		// Update stored options if outdated
		ChromeStorage.get('reddit_au_options').then(opts => {
			ExtensionOptions.clear().then(() => {
				opts = opts || {};

				ExtensionOptions
					.setBackgroundColor(opts.color || opts.backColor)
					.setBackgroundNightColor(opts.backNightColor)
					.setTextColor(opts.front_color || opts.frontColor)
					.setTextNightColor(opts.frontNightColor)
					.setLinkColor(opts.linkColor)
					.setLinkNightColor(opts.linkNightColor)
					.setQuoteTextColor(opts.quoteTextColor)
					.setQuoteTextNightColor(opts.quoteTextNightColor)
					.setThreadRemovalSeconds(opts.thread_removal_time_seconds || opts.threadRemovalTimeSeconds)
					.setBorder(opts.has_border || opts.border)
					.setClearComment(opts.clearCommentOnClick, opts.clearCommentincludeChildren)
					.setCustomCSS(opts.customCSS)
					.setCustomCSSClassName(opts.customCSSClassName)
					.setRedirect(opts.redirect)<commit_msg>Fix RES option reset after update<commit_after>import ExtensionOptions from './storage/ExtensionOptions';
import ThreadStorage from './storage/ThreadStorage';
import ChromeStorage from './storage/ChromeStorage';
import * as Utils from './utils';

/* This file should really be called 'eventScript' as it's only loaded when needed */

chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
	switch (request.method) {
		case 'ThreadStorage.getById':
			sendResponse(ThreadStorage.getById(request.threadId));
			break;
		case 'ThreadStorage.add':
			ThreadStorage.add(request.threadId);
			ThreadStorage.save();
			break;
		case 'ExtensionOptions.getAll':
			sendResponse({
				redirect: ExtensionOptions.getRedirect(),
				className: ExtensionOptions.getCSSClassName(),
				css: ExtensionOptions.getCSS(),
				clearComment: ExtensionOptions.getClearComment()
			});
			break;
		default:
			break;
	}
});

chrome.runtime.onInstalled.addListener(details => {
	if (details.reason === 'update') {
		if (details.version === chrome.app.getDetails().version) {
			return;
		}

		// Update stored options if outdated
		ChromeStorage.get('reddit_au_options').then(opts => {
			ExtensionOptions.clear().then(() => {
				opts = opts || {};

				ExtensionOptions
					.setBackgroundColor(opts.color || opts.backColor)
					.setBackgroundNightColor(opts.backNightColor)
					.setTextColor(opts.front_color || opts.frontColor)
					.setTextNightColor(opts.frontNightColor)
					.setLinkColor(opts.linkColor)
					.setLinkNightColor(opts.linkNightColor)
					.setQuoteTextColor(opts.quoteTextColor)
					.setQuoteTextNightColor(opts.quoteTextNightColor)
					.setThreadRemovalSeconds(opts.thread_removal_time_seconds || opts.threadRemovalTimeSeconds)
					.setBorder(opts.has_border || opts.border)
					.setClearComment(opts.clearCommentOnClick, opts.clearCommentincludeChildren)
					.setCustomCSS(opts.customCSS)
					.setCustomCSSClassName(opts.customCSSClassName)
					.setRedirect(opts.redirect)
					.setIsResUser(opts.usesRES)
{'fraction_non_alphanumeric': 0.11943269470017417, 'fraction_numerical': 0.0, 'mean_word_length': 4.646067415730337, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '1974765', 'n_tokens_mistral': 1383, 'n_tokens_neox': 1141, 'n_words': 195}