stagepoint sessionsettings bak

pull/717/head
Vincent 5 years ago
parent 8de2ce9e23
commit cc3e206504

@ -186,31 +186,18 @@ ipc.on('remove-dark-overlay', () => {
}); });
window.getSettingValue = settingID => { window.getSettingValue = (settingID, comparisonValue = null) => {
console.log("EXECUTED"); // Comparison value allows you to pull boolean values from any type.
console.log("EXECUTED"); // Eg. window.getSettingValue('theme', 'light')
console.log("EXECUTED"); // returns 'false' when the value is 'dark'.
console.log("EXECUTED"); const settingVal = window.storage.get(settingID);
return comparisonValue ? !!settingVal === comparisonValue : settingVal;
const theme = window.storage.get('theme-setting', 'dark');
console.log(`THEME: ${theme}`);
console.log(`THEME: ${theme}`);
console.log(`THEME: ${theme}`);
console.log(`THEME: ${theme}`);
console.log(`THEME: ${theme}`);
if (settingID === 'theme'){
const theme = window.storage.get('theme-setting', 'dark');
console.log(`THEME: ${theme}`);
}
} }
window.setSettingValue = settingID => { window.setSettingValue = (settingID, value) => {
const those = settingID; window.storage.put(settingID, value);
return those;
} }
installGetter('device-name', 'getDeviceName'); installGetter('device-name', 'getDeviceName');
installGetter('theme-setting', 'getThemeSetting'); installGetter('theme-setting', 'getThemeSetting');

@ -18,18 +18,33 @@ export enum SessionSettingType {
Button = 'button', Button = 'button',
} }
//const { Settings } = window.Signal.Types;
// Grab initial values from database on startup // Grab initial values from database on startup
const localSettings = [ const localSettings = [
{ {
id: 'theme', id: 'theme-setting',
title: 'Light Mode', title: 'Light Mode',
hidden: true,
comparisonValue: 'light',
description: 'Choose the theme best suited to you', description: 'Choose the theme best suited to you',
type: SessionSettingType.Toggle, type: SessionSettingType.Toggle,
category: SessionSettingCategory.General, category: SessionSettingCategory.General,
afterClick: () => window.toggleTheme(), setFn: window.toggleTheme,
}, },
{ {
id: 'typingIndicators', id: 'hide-menu-bar',
title: 'Hide Menu Bar',
//hidden: !Settings.isHideMenuBarSupported(),
type: SessionSettingType.Toggle,
category: SessionSettingCategory.General,
setFn: window.setHideMenuBar,
},
{
id: 'typing-indicators-setting',
title: 'Typing Indicators', title: 'Typing Indicators',
description: description:
'See and share when messages are being typed. This setting is optional and applies to all conversations.', 'See and share when messages are being typed. This setting is optional and applies to all conversations.',
@ -37,7 +52,7 @@ const localSettings = [
category: SessionSettingCategory.Privacy, category: SessionSettingCategory.Privacy,
}, },
{ {
id: 'screenLock', id: 'qwer',
title: 'Screen Lock', title: 'Screen Lock',
description: description:
'Unlock Loki Session using your password. Visit notification settings to customise.', 'Unlock Loki Session using your password. Visit notification settings to customise.',
@ -45,7 +60,7 @@ const localSettings = [
category: SessionSettingCategory.Privacy, category: SessionSettingCategory.Privacy,
}, },
{ {
id: 'screenSecurity', id: 'qewrtrg',
title: 'Screen Security', title: 'Screen Security',
description: description:
'Prevent Loki Session previews from appearing in desktop notifications.', 'Prevent Loki Session previews from appearing in desktop notifications.',
@ -53,7 +68,7 @@ const localSettings = [
category: SessionSettingCategory.Privacy, category: SessionSettingCategory.Privacy,
}, },
{ {
id: 'linkPreviews', id: 'erhe',
title: 'Send Link Previews', title: 'Send Link Previews',
description: description:
'Supported for Imgur, Instagram, Pinterest, Reddit and YouTube.', 'Supported for Imgur, Instagram, Pinterest, Reddit and YouTube.',
@ -61,7 +76,7 @@ const localSettings = [
category: SessionSettingCategory.Privacy, category: SessionSettingCategory.Privacy,
}, },
{ {
id: 'clearConversationHistory', id: 'qwefwef',
title: 'Clear Conversation History', title: 'Clear Conversation History',
category: SessionSettingCategory.Privacy, category: SessionSettingCategory.Privacy,
type: SessionSettingType.Button, type: SessionSettingType.Button,
@ -69,7 +84,7 @@ const localSettings = [
buttonColor: SessionButtonColor.Danger, buttonColor: SessionButtonColor.Danger,
}, },
{ {
id: 'changePassword', id: 'ergreg',
title: 'Change Password', title: 'Change Password',
category: SessionSettingCategory.Account, category: SessionSettingCategory.Account,
type: SessionSettingType.Button, type: SessionSettingType.Button,
@ -77,7 +92,7 @@ const localSettings = [
buttonColor: SessionButtonColor.Primary, buttonColor: SessionButtonColor.Primary,
}, },
{ {
id: 'removePassword', id: 'etyjhnyth',
title: 'Remove Password', title: 'Remove Password',
category: SessionSettingCategory.Account, category: SessionSettingCategory.Account,
type: SessionSettingType.Button, type: SessionSettingType.Button,
@ -99,6 +114,12 @@ export class SettingsView extends React.Component<SettingsViewProps> {
} }
public renderSettingInCategory() { public renderSettingInCategory() {
const { Settings } = window.Signal.Types;
console.log(Settings);
console.log(Settings);
console.log(Settings);
console.log(Settings);
return ( return (
<> <>
{localSettings.map(setting => { {localSettings.map(setting => {
@ -107,14 +128,14 @@ export class SettingsView extends React.Component<SettingsViewProps> {
return ( return (
<div key={setting.id}> <div key={setting.id}>
{renderSettings && ( {renderSettings && !(setting.hidden) && (
<SessionSettingListItem <SessionSettingListItem
title={setting.title} title={setting.title}
description={setting.description} description={setting.description}
type={setting.type} type={setting.type}
value={window.getSettingValue(setting.id)} value={ window.getSettingValue(setting.id, setting.comparisonValue || null) }
onClick={() => { onClick={() => {
SettingsManager.updateSetting(setting); this.updateSetting(setting);
}} }}
buttonText={setting.buttonText || undefined} buttonText={setting.buttonText || undefined}
buttonColor={setting.buttonColor || undefined} buttonColor={setting.buttonColor || undefined}
@ -139,17 +160,20 @@ export class SettingsView extends React.Component<SettingsViewProps> {
</div> </div>
); );
} }
}
export class SettingsManager { public updateSetting(item: any) {
public static updateSetting(item: any) {
if (item.type === SessionSettingType.Toggle) { if (item.type === SessionSettingType.Toggle) {
//alert(`You clicked a toggle with ID: ${item.id}`); // If no custom afterClick function given, alter values in storage here
// Manage toggle events if (!item.setFn) {
// Switch to opposite state
const newValue = !window.getSettingValue(item.id);
window.setSettingValue(item.id, newValue);
}
} }
// If there's an onClick function, execute it // If there's a custom afterClick function,
item.afterClick && item.afterClick(); // execute it instead of automatically updating settings
item.setFn && item.setFn();
return; return;
} }

4
ts/global.d.ts vendored

@ -23,10 +23,12 @@ interface Window {
confirmationDialog: any; confirmationDialog: any;
showSeedDialog: any; showSeedDialog: any;
showAddServerDialog: any; showAddServerDialog: any;
toggleTheme: any;
deleteAccount: any; deleteAccount: any;
toggleTheme: any;
setHideMenuBar: any;
getSettingValue: any; getSettingValue: any;
setSettingValue: any; setSettingValue: any;
} }
interface Promise<T> { interface Promise<T> {

Loading…
Cancel
Save