-
Notifications
You must be signed in to change notification settings - Fork 9k
Include Profile.BellSound as a media resource #19289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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() }; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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; }; |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
another drive by optimization
carlos-zamora
left a comment
There was a problem hiding this 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.
| std::filesystem::path filePath{ std::wstring_view{ currentSound.GetAt(0) } }; | ||
| return hstring{ filePath.filename().wstring() }; | ||
| return currentSound.GetAt(0).Resolved(); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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() };There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
| newSounds.resize(inheritedSounds.Size()); // fill with null | ||
| inheritedSounds.GetMany(0, newSounds); |
There was a problem hiding this comment.
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).
| std::vector<IMediaResource> sounds; | ||
| sounds.resize(_BellSound->Size()); // fill with null | ||
| _BellSound->GetMany(0, sounds); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
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
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
bellSoundtodesktopWallpaper, 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 foundin the preview for the bell if it is a single file which failed validation!