Skip to content

Conversation

@krushnarout
Copy link
Member

before glass shows the omi cv1 image

before:

5F48195F-0270-4F1D-9D6E-93AF806178CE_1_201_a

after:
IMG_1106

closes #3437

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly fixes an issue where devices identified as 'Glass' were showing the wrong image. However, the implementation introduces significant code duplication when checking the modelNumber and deviceName. More importantly, it appears to introduce a regression by removing the check for 'DEV' in the device name, which is inconsistent with other parts of the code and may cause some devkit devices to be misidentified. I've provided comments with suggestions to address these issues.

Comment on lines 75 to 96
if (modelNumber != null && modelNumber.isNotEmpty && modelNumber.toUpperCase() != 'UNKNOWN') {
final upperModel = modelNumber.toUpperCase();
if (upperModel.contains('DEVKIT') || upperModel.contains('FRIEND')) {

if (upperModel.contains('GLASS')) {
return Assets.images.omiGlass.path;
}

if (upperModel.contains('DEVKIT') || (upperModel.contains('FRIEND'))) {
return Assets.images.omiDevkitWithoutRope.path;
}
}
if (deviceName != null && deviceName.isNotEmpty) {
final upperName = deviceName.toUpperCase();
if (upperName.contains('DEVKIT') || upperName.contains('DEV') || upperName.contains('FRIEND')) {

if (upperName.contains('GLASS')) {
return Assets.images.omiGlass.path;
}

if (upperName.contains('DEVKIT') || (upperName.contains('FRIEND'))) {
return Assets.images.omiDevkitWithoutRope.path;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The logic to determine the image path from modelNumber and deviceName is nearly identical and duplicated. Both blocks of code check for 'GLASS', 'DEVKIT', and 'FRIEND'. This duplication makes the code harder to maintain and increases the risk of introducing bugs if one block is updated but the other is not. 1

To improve maintainability, consider extracting this logic into a single private helper function. This would centralize the device image selection logic for DeviceType.omi, making it cleaner and easier to update in the future.

Rules References

Footnotes

  1. Prefer using existing helper functions over inlining their logic, especially when they handle complex cases like fallbacks or error handling. Inlining can introduce subtle bugs by missing parts of the original logic.

@krushnarout
Copy link
Member Author

krushnarout commented Dec 1, 2025

update discussed in tg with Aarav

only show the device id when there are multiple same devices. If there’s just one, don’t show the device id.

IMG_1114

@aaravgarg aaravgarg requested a review from mdmohsin7 December 3, 2025 02:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Device image mismatch

2 participants