Skip to content

Commit 0a1e657

Browse files
committed
開発者オーバレイの表示と保存処理を修正
1 parent 356ba1c commit 0a1e657

File tree

3 files changed

+24
-11
lines changed

3 files changed

+24
-11
lines changed

src/components/DevOverlay.test.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
backgroundLocationTrackingAtom,
88
locationAtom,
99
} from '~/store/atoms/location';
10+
import { isLEDThemeAtom } from '~/store/atoms/theme';
1011
import DevOverlay from './DevOverlay';
1112

1213
jest.mock('jotai', () => {
@@ -91,7 +92,10 @@ describe('DevOverlay', () => {
9192
if (atom === backgroundLocationTrackingAtom) {
9293
return backgroundLocationTracking as never;
9394
}
94-
return undefined as never;
95+
if (atom === isLEDThemeAtom) {
96+
return false as never;
97+
}
98+
throw new Error(`Unexpected atom mock: ${String(atom)}`);
9599
});
96100
};
97101

src/components/DevOverlay.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -520,9 +520,7 @@ const DevOverlay: React.FC = () => {
520520
<Typography style={styles.chartLabel}>
521521
ACCURACY HISTORY
522522
</Typography>
523-
<Typography style={[styles.chartValue, chartValueStyle]}>
524-
{accuracyChartBlocks.length === 0 ? '---' : null}
525-
</Typography>
523+
<Typography style={[styles.chartValue, chartValueStyle]} />
526524
<Typography
527525
style={[styles.chartValue, chartValueStyle]}
528526
testID="dev-overlay-accuracy-history"
@@ -592,9 +590,7 @@ const DevOverlay: React.FC = () => {
592590
<Typography style={styles.chartLabel}>
593591
ACCURACY HISTORY
594592
</Typography>
595-
<Typography style={[styles.chartValue, chartValueStyle]}>
596-
{accuracyChartBlocks.length === 0 ? '---' : null}
597-
</Typography>
593+
<Typography style={[styles.chartValue, chartValueStyle]} />
598594
<Typography
599595
style={[styles.chartValue, chartValueStyle]}
600596
testID="dev-overlay-accuracy-history"

src/components/Permitted.tsx

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,15 +239,28 @@ const PermittedLayout: React.FC<Props> = ({ children }: Props) => {
239239
devOverlayEnabled ? 'hideDevOverlay' : 'showDevOverlay'
240240
),
241241
handler: async () => {
242+
const prevValue = devOverlayEnabled;
242243
const nextValue = !devOverlayEnabled;
243244
setTuning((prev) => ({
244245
...prev,
245246
devOverlayEnabled: nextValue,
246247
}));
247-
await AsyncStorage.setItem(
248-
ASYNC_STORAGE_KEYS.DEV_OVERLAY_ENABLED,
249-
String(nextValue)
250-
);
248+
try {
249+
await AsyncStorage.setItem(
250+
ASYNC_STORAGE_KEYS.DEV_OVERLAY_ENABLED,
251+
String(nextValue)
252+
);
253+
} catch (error) {
254+
console.error(error);
255+
setTuning((prev) => ({
256+
...prev,
257+
devOverlayEnabled: prevValue,
258+
}));
259+
Alert.alert(
260+
translate('errorTitle'),
261+
translate('failedToSavePreference')
262+
);
263+
}
251264
},
252265
});
253266
}

0 commit comments

Comments
 (0)