Skip to content

Commit 563ed54

Browse files
committed
use switch for save and clear if off
1 parent 2ff79e2 commit 563ed54

5 files changed

Lines changed: 61 additions & 129 deletions

File tree

src/sidebar/SettingsBox.module.css

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -88,29 +88,6 @@ input {
8888
font-weight: bold;
8989
}
9090

91-
.clearRecentsButton {
92-
border: 1px solid lightgray;
93-
border-radius: 8px;
94-
background: none;
95-
color: inherit;
96-
padding: 3px 5px;
97-
cursor: pointer;
98-
justify-self: center;
99-
display: flex;
100-
align-items: center;
101-
justify-content: center;
102-
}
103-
104-
.clearRecentsButton svg {
105-
scale: 1;
106-
margin: 0;
107-
}
108-
109-
.clearRecentsButton:hover {
110-
background: #ececec;
111-
color: #333;
112-
}
113-
11491
.title,
11592
.infoLine,
11693
.settingsTable,

src/sidebar/SettingsBox.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@ export default function SettingsBox({ profile }: { profile: RoutingProfile }) {
5252
Dispatcher.dispatch(new UpdateSettings({ showDistanceInMiles: !settings.showDistanceInMiles }))
5353
}
5454
/>
55-
<div className={styles.settingsToggle} style={{ cursor: 'default' }}>
56-
<button className={styles.clearRecentsButton} onClick={() => clearRecentLocations()}>
57-
<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 -960 960 960">
58-
<path fill="currentColor" d="m256-200-56-56 224-224-224-224 56-56 224 224 224-224 56 56-224 224 224 224-56 56-224-224-224 224Z"/>
59-
</svg>
60-
</button>
61-
<div>{tr('clear_recent_locations')}</div>
62-
</div>
55+
<SettingsToggle
56+
title={tr('save_recent_locations')}
57+
enabled={settings.saveRecentLocations}
58+
onClick={() => {
59+
if (settings.saveRecentLocations) clearRecentLocations()
60+
Dispatcher.dispatch(new UpdateSettings({ saveRecentLocations: !settings.saveRecentLocations }))
61+
}}
62+
/>
6363
</div>
6464
<div className={styles.title}>{tr('settings_gpx_export')}</div>
6565
<div className={styles.settingsTable}>

src/sidebar/search/RecentLocations.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { calcDist, Coordinate } from '@/utils'
22
import { tr } from '@/translation/Translation'
33
import { textToCoordinate } from '@/Converters'
4+
import { getSettingsStore } from '@/stores/Stores'
45

56
const STORAGE_KEY = 'recentLocations'
67
export const MAX_ENTRIES = 15
@@ -47,6 +48,7 @@ export function clearRecentLocations(): void {
4748
}
4849

4950
export function saveRecentLocation(mainText: string, secondText: string, coordinate: Coordinate, now: number = Date.now()): void {
51+
if (!getSettingsStore().state.saveRecentLocations) return
5052
if (mainText === tr('current_location')) return
5153
if (textToCoordinate(mainText)) return
5254

src/stores/SettingsStore.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { SetCustomModelEnabled, UpdateSettings } from '@/actions/Actions'
55
export interface Settings {
66
showDistanceInMiles: boolean
77
drawAreasEnabled: boolean
8+
saveRecentLocations: boolean
89
gpxExportRte: boolean
910
gpxExportWpt: boolean
1011
gpxExportTrk: boolean
@@ -13,6 +14,7 @@ export interface Settings {
1314
export const defaultSettings: Settings = {
1415
showDistanceInMiles: false,
1516
drawAreasEnabled: false,
17+
saveRecentLocations: true,
1618
gpxExportRte: false,
1719
gpxExportWpt: false,
1820
gpxExportTrk: true,

0 commit comments

Comments
 (0)