Skip to content

Commit

Permalink
fix: always specify a device type (#709)
Browse files Browse the repository at this point in the history
I think this is useful on its own, but it will be required when we want
to update to the latest `@comapeo/schema`.
  • Loading branch information
EvanHahn committed Sep 16, 2024
1 parent 81514f9 commit cf09155
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/frontend/hooks/server/deviceInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const useEditDeviceInfo = () => {
mutationFn: async (name: string) => {
return mapeoApi.setDeviceInfo({
name,
deviceType: deviceType ? expoToCoreDeviceType(deviceType) : undefined,
deviceType: expoToCoreDeviceType(deviceType),
});
},
onSuccess: () => {
Expand All @@ -35,21 +35,20 @@ export const useEditDeviceInfo = () => {
};

function expoToCoreDeviceType(
d: Readonly<DeviceType>,
): 'mobile' | 'tablet' | 'desktop' | 'UNRECOGNIZED' | undefined {
d: Readonly<null | DeviceType>,
): 'mobile' | 'tablet' | 'desktop' | 'UNRECOGNIZED' {
switch (d) {
case DeviceType.PHONE: {
return 'mobile';
}
case DeviceType.TABLET: {
return 'tablet';
}
case DeviceType.TV: {
return undefined;
}
case DeviceType.DESKTOP: {
return 'desktop';
}
case null:
case DeviceType.TV:
case DeviceType.UNKNOWN: {
return 'UNRECOGNIZED';
}
Expand Down

0 comments on commit cf09155

Please sign in to comment.