Skip to content

Conversation

@DHowett
Copy link
Member

@DHowett DHowett commented Aug 27, 2025

I legitimately cannot figure out how I forgot this. Bell should support all the same validation as other media resources! Technically this means you can set bellSound to desktopWallpaper, but... we'll pretend that makes sense.

I reworked the viewmodel to be a little more sensible. It no longer requires somebody else to check that its files exist. The settings UI now also displays File not found in the preview for the bell if it is a single file which failed validation!

I legitimately cannot figure out how I forgot this. Bell should support
all the same validation as other media resources! Technically this means
you can set `bellSound` to `desktopWallpaper`, but... we'll pretend that
makes sense.
if (sounds && sounds.Size() > 0)
{
winrt::hstring soundPath{ wil::ExpandEnvironmentStringsW<std::wstring>(sounds.GetAt(rand() % sounds.Size()).c_str()) };
winrt::hstring soundPath{ sounds.GetAt(rand() % sounds.Size()).Resolved() };
Copy link
Member Author

Choose a reason for hiding this comment

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

If any resource failed validation, we'll just call playBellSound(L""). This fails like any other invalid file failed in the past.

Copy link
Member Author

Choose a reason for hiding this comment

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

My original plan was to have the resolver remove entries that were illegal. however, that would also remove them from the user settings file. Instead, I fell back to the existing behavior.

newSounds.push_back(sound);
}
newSounds.resize(inheritedSounds.Size()); // fill with null
inheritedSounds.GetMany(0, newSounds);
Copy link
Member Author

Choose a reason for hiding this comment

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

drive by optimization

{
get_self<BellSoundViewModel>(sound)->FileExists(false);
// If the resource was resolved to something other than its path, show the path!
_ShowDirectory = true;
Copy link
Member Author

Choose a reason for hiding this comment

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

@carlos-zamora since you wrote bell sounds, you might care about this. it means that if you use a relative path to your bell sound file, the settings UI will always display the folder it resolved to

Copy link
Member

Choose a reason for hiding this comment

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

Nice! I'm totally ok with that. Means that we're being very clear about what's being loaded.

}
}

co_await winrt::resume_foreground(_dispatcher);
Copy link
Member Author

Choose a reason for hiding this comment

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

we don't need this any more because the settings model did it and populated them all with .Ok()

runtimeclass BellSoundViewModel : Windows.UI.Xaml.Data.INotifyPropertyChanged
{
String Path;
String Path { get; };
Copy link
Member Author

Choose a reason for hiding this comment

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

never written; removed setter

}
std::vector<IMediaResource> sounds;
sounds.resize(_BellSound->Size()); // fill with null
_BellSound->GetMany(0, sounds);
Copy link
Member Author

Choose a reason for hiding this comment

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

another drive by optimization

Copy link
Member

@carlos-zamora carlos-zamora left a comment

Choose a reason for hiding this comment

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

Mainly blocking over having the preview display the full path vs the file name.

Re:desktopWallpaper is an accepted value
Tested it locally;. User can't set it via the SUI since they have to use a filepicker so that's good. User can go into their settings.json and set desktopWallpaper there. We don't get a warning, whereas if they put foo they would.
It's not ideal, but at the same time, if the user is setting bellSound to desktopWallpaper, they kinda did it to themselves.
If anything, I guess this is like a P3 backlogged bug imo.

Comment on lines 835 to 809
std::filesystem::path filePath{ std::wstring_view{ currentSound.GetAt(0) } };
return hstring{ filePath.filename().wstring() };
return currentSound.GetAt(0).Resolved();
Copy link
Member

Choose a reason for hiding this comment

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

Used to just show the filename. Now it shows the full path. Can we get this to just show the filename again? The full path is a lot of extra text that isn't really meaningful to the user here.

Copy link
Member

Choose a reason for hiding this comment

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

Something like this from DisplayPath() above

auto resolvedPath{ currentSound.GetAt(0).Resolved() };
const std::filesystem::path filePath{ std::wstring_view{ resolvedPath } };
return hstring{ filePath.filename().wstring() };

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch, my miss. Thanks.

{
get_self<BellSoundViewModel>(sound)->FileExists(false);
// If the resource was resolved to something other than its path, show the path!
_ShowDirectory = true;
Copy link
Member

Choose a reason for hiding this comment

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

Nice! I'm totally ok with that. Means that we're being very clear about what's being loaded.

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something and removed Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something labels Aug 27, 2025
Comment on lines 737 to 738
newSounds.resize(inheritedSounds.Size()); // fill with null
inheritedSounds.GetMany(0, newSounds);
Copy link
Member

Choose a reason for hiding this comment

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

This could use wil::to_vector instead. We use it in 3 places already (and hopefully more soon).

Comment on lines 127 to 129
std::vector<IMediaResource> sounds;
sounds.resize(_BellSound->Size()); // fill with null
_BellSound->GetMany(0, sounds);
Copy link
Member

Choose a reason for hiding this comment

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

Same here.

@DHowett DHowett enabled auto-merge (squash) August 27, 2025 23:56
@DHowett DHowett merged commit 4272151 into main Aug 28, 2025
17 of 19 checks passed
@DHowett DHowett deleted the dev/duhowett/bell-is-media-too-dummy branch August 28, 2025 00:05
@DHowett DHowett moved this from To Cherry Pick to Cherry Picked in 1.24 Servicing Pipeline Sep 5, 2025
DHowett added a commit that referenced this pull request Sep 5, 2025
I legitimately cannot figure out how I forgot this. Bell should support
all the same validation as other media resources! Technically this means
you can set `bellSound` to `desktopWallpaper`, but... we'll pretend that
makes sense.

I reworked the viewmodel to be a little more sensible. It no longer
requires somebody else to check that its files exist. The settings UI
now also displays `File not found` in the _preview_ for the bell if it
is a single file which failed validation!

(cherry picked from commit 4272151)
Service-Card-Id: PVTI_lADOAF3p4s4BBcTlzgeF9qU
Service-Version: 1.24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Cherry Picked

Development

Successfully merging this pull request may close these issues.

4 participants