Add script offset / delay to Handy support. (#1573)

* Add script offset / delay to Handy support.

Further work on  #1376.

Offsets are added to the current video position, so a positive value leads to earlier motion.  (The most common setting.)

This is needed because most script times have a consistent delay when compared to the video. (Delay from the API calls to the server should be handled by the server offset calculation.)

* Rename scriptOffset to funscriptOffset
* Correct localisation keys

Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
This commit is contained in:
UnluckyChemical765
2021-08-25 18:50:02 -07:00
committed by GitHub
parent 50217f6318
commit 45a9aabdaf
14 changed files with 76 additions and 16 deletions

View File

@@ -37,6 +37,7 @@ export const SettingsInterfacePanel: React.FC = () => {
const [cssEnabled, setCSSEnabled] = useState<boolean>(false);
const [language, setLanguage] = useState<string>("en");
const [handyKey, setHandyKey] = useState<string>();
const [funscriptOffset, setFunscriptOffset] = useState<number>(0);
const [updateInterfaceConfig] = useConfigureInterface({
menuItems: menuItemIds,
@@ -51,6 +52,7 @@ export const SettingsInterfacePanel: React.FC = () => {
language,
slideshowDelay,
handyKey,
funscriptOffset,
});
useEffect(() => {
@@ -67,6 +69,7 @@ export const SettingsInterfacePanel: React.FC = () => {
setLanguage(iCfg?.language ?? "en-US");
setSlideshowDelay(iCfg?.slideshowDelay ?? 5000);
setHandyKey(iCfg?.handyKey ?? "");
setFunscriptOffset(iCfg?.funscriptOffset ?? 0);
}, [config]);
async function onSave() {
@@ -281,7 +284,9 @@ export const SettingsInterfacePanel: React.FC = () => {
</Form.Group>
<Form.Group>
<h5>{intl.formatMessage({ id: "config.ui.handy_connection_key" })}</h5>
<h5>
{intl.formatMessage({ id: "config.ui.handy_connection_key.heading" })}
</h5>
<Form.Control
className="col col-sm-6 text-input"
value={handyKey}
@@ -290,7 +295,25 @@ export const SettingsInterfacePanel: React.FC = () => {
}}
/>
<Form.Text className="text-muted">
{intl.formatMessage({ id: "config.ui.handy_connection_key_desc" })}
{intl.formatMessage({
id: "config.ui.handy_connection_key.description",
})}
</Form.Text>
</Form.Group>
<Form.Group>
<h5>
{intl.formatMessage({ id: "config.ui.funscript_offset.heading" })}
</h5>
<Form.Control
className="col col-sm-6 text-input"
type="number"
value={funscriptOffset}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
setFunscriptOffset(Number.parseInt(e.currentTarget.value, 10));
}}
/>
<Form.Text className="text-muted">
{intl.formatMessage({ id: "config.ui.funscript_offset.description" })}
</Form.Text>
</Form.Group>