From cb7289d3d868c813fedaf9d2572d98798d581eb1 Mon Sep 17 00:00:00 2001 From: Brian Jian Zhao Date: Fri, 21 Feb 2020 10:37:58 +1100 Subject: [PATCH] working but buggy --- preload.js | 4 +-- .../settings/SessionSettingListItem.tsx | 31 ++++++++++++++++--- .../session/settings/SessionSettings.tsx | 19 ------------ ts/global.d.ts | 2 ++ 4 files changed, 30 insertions(+), 26 deletions(-) diff --git a/preload.js b/preload.js index 927ac7b32..3637bf4ea 100644 --- a/preload.js +++ b/preload.js @@ -84,11 +84,11 @@ const ipc = electron.ipcRenderer; const localeMessages = ipc.sendSync('locale-data'); -window.setScaling = (number) => { +window.setZoomFactor = (number) => { return webFrame.setZoomFactor(number); } -window.getScaling = () => { +window.getZoomFactor = () => { return webFrame.getZoomFactor(); } diff --git a/ts/components/session/settings/SessionSettingListItem.tsx b/ts/components/session/settings/SessionSettingListItem.tsx index db80bb296..667928d5c 100644 --- a/ts/components/session/settings/SessionSettingListItem.tsx +++ b/ts/components/session/settings/SessionSettingListItem.tsx @@ -88,7 +88,7 @@ export class SessionSettingListItem extends React.Component { /> )} - {type === SessionSettingType.Slider && ( + {type === SessionSettingType.Slider && title === 'messageTTL' ? (
{

{`${currentSliderValue} Hours`}

- )} - -
- See me in here + ):type === SessionSettingType.Slider ? ( +
+ + { + this.handleSlider(sliderValue); + }} + /> +
+

{`% ${currentSliderValue} Zoom Level`}

+
+
+ ): + null}
); @@ -128,5 +143,11 @@ export class SessionSettingListItem extends React.Component { this.setState({ sliderValue: value, }); + + if(this.props.title !== 'messageTTL' && this.state.sliderValue!==null) { + window.setZoomFactor(this.state.sliderValue/100) + } + + } } diff --git a/ts/components/session/settings/SessionSettings.tsx b/ts/components/session/settings/SessionSettings.tsx index 4524fd167..1a88ada2d 100644 --- a/ts/components/session/settings/SessionSettings.tsx +++ b/ts/components/session/settings/SessionSettings.tsx @@ -35,7 +35,6 @@ interface State { pwdLockError: string | null; shouldLockSettings: boolean | null; linkedPubKeys: Array; - scaleValue: number; } interface LocalSettingType { @@ -63,7 +62,6 @@ export class SettingsView extends React.Component { pwdLockError: null, shouldLockSettings: true, linkedPubKeys: new Array(), - scaleValue: 200 }; this.settingsViewRef = React.createRef(); @@ -74,7 +72,6 @@ export class SettingsView extends React.Component { this.refreshLinkedDevice = this.refreshLinkedDevice.bind(this); this.onKeyUp = this.onKeyUp.bind(this); - this.handleScaleChange = this.handleScaleChange.bind(this) window.addEventListener('keyup', this.onKeyUp); } @@ -164,11 +161,6 @@ export class SettingsView extends React.Component { ); })} - -
- -
-
Scale: {this.state.scaleValue}
); } @@ -277,17 +269,6 @@ export class SettingsView extends React.Component { ); } - - public handleScaleChange(event:any):any { - const {value} = event.target; - let scaleVal:number = parseInt(value,10); - this.setState({ - scaleValue:scaleVal - }) - window.setSettingValue('') - } - - public renderSessionInfo(): JSX.Element { return (
diff --git a/ts/global.d.ts b/ts/global.d.ts index 882a32e3f..fbc071720 100644 --- a/ts/global.d.ts +++ b/ts/global.d.ts @@ -11,6 +11,7 @@ interface Window { mnemonic: any; clipboard: any; attemptConnection: any; + setZoomFactor: any; passwordUtil: any; userConfig: any; @@ -58,6 +59,7 @@ interface Window { lokiFeatureFlags: any; resetDatabase: any; + } interface Promise {