Skip to content
This repository has been archived by the owner on Dec 1, 2022. It is now read-only.

Commit

Permalink
v2.4.2 (#120)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikesteele authored Dec 25, 2019
1 parent af5f878 commit 09d4a9a
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 27 deletions.
2 changes: 1 addition & 1 deletion background_page/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dual-captions-background-page",
"version": "2.4.1",
"version": "2.4.2",
"description": "",
"main": "./dist/index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion browser_action/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dual-captions-browser-action",
"version": "2.4.1",
"version": "2.4.2",
"private": true,
"dependencies": {
"chai": "^4.1.2",
Expand Down
2 changes: 1 addition & 1 deletion content_script/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dual-captions-content_script",
"version": "2.4.1",
"version": "2.4.2",
"private": true,
"dependencies": {
"franc": "^4.1.0",
Expand Down
44 changes: 25 additions & 19 deletions content_script/src/PopupMessageHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class PopupMessageHandler extends React.Component {
});
this.getSavedUILanguage().then(uiLanguage => {
if (uiLanguage) {
this.changeSetting('uiLanguage', uiLanguage);
this.changeSetting('uiLanguage', uiLanguage, false);
}
}).catch(err => {
console.log(`Couldn't get saved UI language on mount. Error: ${err}`);
Expand All @@ -65,13 +65,13 @@ class PopupMessageHandler extends React.Component {

onMouseMove() {
if (!this.state.settings.mouseIsActive) {
this.changeSetting('mouseIsActive', true);
this.changeSetting('mouseIsActive', true, false);
}
if (this.idleTimer) {
window.clearTimeout(this.idleTimer);
}
this.idleTimer = window.setTimeout(() => {
this.changeSetting('mouseIsActive', false);
this.changeSetting('mouseIsActive', false, false);
}, 2500);
}

Expand Down Expand Up @@ -188,14 +188,20 @@ class PopupMessageHandler extends React.Component {
document.body.removeEventListener('keyup', this.onKeyUp);
}

changeSetting(setting, value) {
this.setState(state => ({
settings: {
...state.settings,
[setting]: value,
settingsAreDefault: false,
},
}));
changeSetting(setting, value, settingsAreNoLongerDefault) {
this.setState(state => {
let settingsAreDefault = state.settings.settingsAreDefault;
if (settingsAreDefault && settingsAreNoLongerDefault) {
settingsAreDefault = false;
}
return {
settings: {
...state.settings,
[setting]: value,
settingsAreDefault,
}
};
});
}

onMessage(message, sender, sendResponse) {
Expand All @@ -207,7 +213,7 @@ class PopupMessageHandler extends React.Component {

// TODO - Should deprecate
case 'change-language':
this.changeSetting('secondSubtitleLanguage', message.payload);
this.changeSetting('secondSubtitleLanguage', message.payload, true);
break;

case 'change-settings':
Expand All @@ -220,22 +226,22 @@ class PopupMessageHandler extends React.Component {
hideActionPanel
} = message.payload;
if (settings.extraSpace !== extraSpace) {
this.changeSetting('extraSpace', extraSpace);
this.changeSetting('extraSpace', extraSpace, true);
}
if (settings.customTextColor !== customTextColor) {
this.changeSetting('customTextColor', customTextColor);
this.changeSetting('customTextColor', customTextColor, true);
}
if (settings.customColorsEnabled !== customColorsEnabled) {
this.changeSetting('customColorsEnabled', customColorsEnabled);
this.changeSetting('customColorsEnabled', customColorsEnabled, true);
}
if (settings.smallText !== smallText) {
this.changeSetting('smallText', smallText);
this.changeSetting('smallText', smallText, true);
}
if (settings.hotKeyEnabled !== hotKeyEnabled) {
this.changeSetting('hotKeyEnabled', hotKeyEnabled);
this.changeSetting('hotKeyEnabled', hotKeyEnabled, true);
}
if (settings.hideActionPanel !== hideActionPanel) {
this.changeSetting('hideActionPanel', hideActionPanel);
this.changeSetting('hideActionPanel', hideActionPanel, true);
}
break;

Expand Down Expand Up @@ -281,7 +287,7 @@ class PopupMessageHandler extends React.Component {
break;

case 'change-ui-language':
this.changeSetting('uiLanguage', message.payload);
this.changeSetting('uiLanguage', message.payload, true);
sendResponse({
ok: true
});
Expand Down
2 changes: 1 addition & 1 deletion content_script/src/SettingControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ class SettingControls extends React.Component {
}}
key={lang}
onClick={() => {
settings.changeSetting('secondSubtitleLanguage', lang);
settings.changeSetting('secondSubtitleLanguage', lang, true);
this.setState({
actionTooltopOpen: false
});
Expand Down
4 changes: 2 additions & 2 deletions content_script/src/SettingsModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const TextColorControl = props => {
marginBottom: '16px'
};
const onChange = e => {
settings.changeSetting('customTextColor', e.target.value);
settings.changeSetting('customTextColor', e.target.value, true);
}
return (
<div style={wrapperStyles}>
Expand Down Expand Up @@ -47,7 +47,7 @@ const CheckboxControl = props => {
const isChecked = settings[settingKey];
const icon = isChecked ? <MdCheckBox /> : <MdCheckBoxOutlineBlank />;
const onClick = () => {
settings.changeSetting(settingKey, !isChecked);
settings.changeSetting(settingKey, !isChecked, true);
}
return (
<div style={wrapperStyles}>
Expand Down
2 changes: 1 addition & 1 deletion manifest/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dual-captions-manifest-creator",
"version": "2.4.1",
"version": "2.4.2",
"description": "",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion site_integrations/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dual-captions-site-integrations",
"version": "2.4.1",
"version": "2.4.2",
"description": "",
"main": "./dist/index.js",
"scripts": {
Expand Down

0 comments on commit 09d4a9a

Please sign in to comment.