Skip to content
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

Improve the process of inserting changes into the database #138

Merged
merged 13 commits into from
Mar 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions Rise Media Player Dev.sln
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rise.Models", "Rise.Models\
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rise.Repository", "Rise.Repository\Rise.Repository.csproj", "{C0DA58A4-4EBE-4F14-8EB2-F92E99960C52}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rise.Tasks", "Rise.Tasks\Rise.Tasks.csproj", "{1AC2B1A4-6E0F-4849-A301-7C646A212A24}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rise.Data", "Rise.Data\Rise.Data.csproj", "{5185BB21-8B6A-4C08-8C50-4E1B8F57B2D5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -93,6 +97,46 @@ Global
{C0DA58A4-4EBE-4F14-8EB2-F92E99960C52}.Release|x64.Build.0 = Release|x64
{C0DA58A4-4EBE-4F14-8EB2-F92E99960C52}.Release|x86.ActiveCfg = Release|x86
{C0DA58A4-4EBE-4F14-8EB2-F92E99960C52}.Release|x86.Build.0 = Release|x86
{1AC2B1A4-6E0F-4849-A301-7C646A212A24}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1AC2B1A4-6E0F-4849-A301-7C646A212A24}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1AC2B1A4-6E0F-4849-A301-7C646A212A24}.Debug|ARM.ActiveCfg = Debug|ARM
{1AC2B1A4-6E0F-4849-A301-7C646A212A24}.Debug|ARM.Build.0 = Debug|ARM
{1AC2B1A4-6E0F-4849-A301-7C646A212A24}.Debug|ARM64.ActiveCfg = Debug|ARM64
{1AC2B1A4-6E0F-4849-A301-7C646A212A24}.Debug|ARM64.Build.0 = Debug|ARM64
{1AC2B1A4-6E0F-4849-A301-7C646A212A24}.Debug|x64.ActiveCfg = Debug|x64
{1AC2B1A4-6E0F-4849-A301-7C646A212A24}.Debug|x64.Build.0 = Debug|x64
{1AC2B1A4-6E0F-4849-A301-7C646A212A24}.Debug|x86.ActiveCfg = Debug|x86
{1AC2B1A4-6E0F-4849-A301-7C646A212A24}.Debug|x86.Build.0 = Debug|x86
{1AC2B1A4-6E0F-4849-A301-7C646A212A24}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1AC2B1A4-6E0F-4849-A301-7C646A212A24}.Release|Any CPU.Build.0 = Release|Any CPU
{1AC2B1A4-6E0F-4849-A301-7C646A212A24}.Release|ARM.ActiveCfg = Release|ARM
{1AC2B1A4-6E0F-4849-A301-7C646A212A24}.Release|ARM.Build.0 = Release|ARM
{1AC2B1A4-6E0F-4849-A301-7C646A212A24}.Release|ARM64.ActiveCfg = Release|ARM64
{1AC2B1A4-6E0F-4849-A301-7C646A212A24}.Release|ARM64.Build.0 = Release|ARM64
{1AC2B1A4-6E0F-4849-A301-7C646A212A24}.Release|x64.ActiveCfg = Release|x64
{1AC2B1A4-6E0F-4849-A301-7C646A212A24}.Release|x64.Build.0 = Release|x64
{1AC2B1A4-6E0F-4849-A301-7C646A212A24}.Release|x86.ActiveCfg = Release|x86
{1AC2B1A4-6E0F-4849-A301-7C646A212A24}.Release|x86.Build.0 = Release|x86
{5185BB21-8B6A-4C08-8C50-4E1B8F57B2D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5185BB21-8B6A-4C08-8C50-4E1B8F57B2D5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5185BB21-8B6A-4C08-8C50-4E1B8F57B2D5}.Debug|ARM.ActiveCfg = Debug|ARM
{5185BB21-8B6A-4C08-8C50-4E1B8F57B2D5}.Debug|ARM.Build.0 = Debug|ARM
{5185BB21-8B6A-4C08-8C50-4E1B8F57B2D5}.Debug|ARM64.ActiveCfg = Debug|ARM64
{5185BB21-8B6A-4C08-8C50-4E1B8F57B2D5}.Debug|ARM64.Build.0 = Debug|ARM64
{5185BB21-8B6A-4C08-8C50-4E1B8F57B2D5}.Debug|x64.ActiveCfg = Debug|x64
{5185BB21-8B6A-4C08-8C50-4E1B8F57B2D5}.Debug|x64.Build.0 = Debug|x64
{5185BB21-8B6A-4C08-8C50-4E1B8F57B2D5}.Debug|x86.ActiveCfg = Debug|x86
{5185BB21-8B6A-4C08-8C50-4E1B8F57B2D5}.Debug|x86.Build.0 = Debug|x86
{5185BB21-8B6A-4C08-8C50-4E1B8F57B2D5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5185BB21-8B6A-4C08-8C50-4E1B8F57B2D5}.Release|Any CPU.Build.0 = Release|Any CPU
{5185BB21-8B6A-4C08-8C50-4E1B8F57B2D5}.Release|ARM.ActiveCfg = Release|ARM
{5185BB21-8B6A-4C08-8C50-4E1B8F57B2D5}.Release|ARM.Build.0 = Release|ARM
{5185BB21-8B6A-4C08-8C50-4E1B8F57B2D5}.Release|ARM64.ActiveCfg = Release|ARM64
{5185BB21-8B6A-4C08-8C50-4E1B8F57B2D5}.Release|ARM64.Build.0 = Release|ARM64
{5185BB21-8B6A-4C08-8C50-4E1B8F57B2D5}.Release|x64.ActiveCfg = Release|x64
{5185BB21-8B6A-4C08-8C50-4E1B8F57B2D5}.Release|x64.Build.0 = Release|x64
{5185BB21-8B6A-4C08-8C50-4E1B8F57B2D5}.Release|x86.ActiveCfg = Release|x86
{5185BB21-8B6A-4C08-8C50-4E1B8F57B2D5}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
19 changes: 6 additions & 13 deletions Rise Media Player Dev/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,6 @@ public static TimeSpan IndexingInterval
/// </summary>
public static LastFMViewModel LMViewModel { get; private set; }

/// <summary>
/// Pipeline for interacting with backend service or database.
/// </summary>
public static IRepository Repository { get; private set; }

/// <summary>
/// Gets the music library.
/// </summary>
Expand Down Expand Up @@ -183,6 +178,7 @@ protected async override void OnActivated(IActivatedEventArgs e)

Window.Current.Activate();
break;

case ActivationKind.ToastNotification:
if (e is ToastNotificationActivatedEventArgs toastActivationArgs)
{
Expand All @@ -206,22 +202,19 @@ protected async override void OnActivated(IActivatedEventArgs e)
}

/// <summary>
/// Initializes the app's database and ViewModels.
/// Initializes the app's ViewModels.
/// </summary>
private async Task InitDatabase()
private async Task InitDataSourcesAsync()
{
// We still have to make sure the file's there
_ = await ApplicationData.Current.LocalCacheFolder.CreateFileAsync("Files.db", CreationCollisionOption.OpenIfExists);
string dbPath = Path.Combine(ApplicationData.Current.LocalCacheFolder.Path, "Files.db");
DbContextOptionsBuilder<Context> dbOptions = new DbContextOptionsBuilder<Context>().UseSqlite(
"Data Source=" + dbPath);

Repository = new SQLRepository(dbOptions);

MusicLibrary = await StorageLibrary.GetLibraryAsync(KnownLibraryId.Music);
VideoLibrary = await StorageLibrary.GetLibraryAsync(KnownLibraryId.Videos);

PBackendController = new PlaylistsBackendController();
NBackendController = new NotificationsBackendController();

MViewModel = new MainViewModel();
LMViewModel = new LastFMViewModel();
PViewModel = new PlaybackViewModel();
Expand Down Expand Up @@ -351,7 +344,7 @@ private async Task<Frame> InitializeWindowAsync(dynamic args)
// just ensure that the window is active
if (Window.Current.Content is not Frame rootFrame)
{
await InitDatabase();
await InitDataSourcesAsync();
await MViewModel.GetListsAsync();

StartIndexingTimer();
Expand Down
2 changes: 1 addition & 1 deletion Rise Media Player Dev/ChangeTrackers/SongsTracker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public static async Task ManageSongChange(StorageLibraryChange change)
if (change.PreviousPath == ViewModel.Songs[i].Location)
{
ViewModel.Songs[i].Location = file.Path;
await ViewModel.Songs[i].SaveAsync();
await ViewModel.Songs[i].SaveEditsAsync();
}
}
break;
Expand Down
44 changes: 22 additions & 22 deletions Rise Media Player Dev/Rise.App.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -568,9 +568,9 @@
<Content Include="Assets\Web\LASTFM.png" />
<Content Include="Materials_Visualisers\Bloom.html" />
<Content Include="Properties\Default.rd.xml" />
<PRIResource Include="Strings\en-gb\WindowsBehaviours.resw" />
<PRIResource Include="Strings\en-gb\Widgets.resw" />
<PRIResource Include="Strings\en-gb\HelpTips.resw" />
<PRIResource Include="Strings\en-GB\WindowsBehaviours.resw" />
<PRIResource Include="Strings\en-GB\Widgets.resw" />
<PRIResource Include="Strings\en-GB\HelpTips.resw" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
Expand Down Expand Up @@ -940,14 +940,14 @@
</PackageReference>
</ItemGroup>
<ItemGroup>
<PRIResource Include="Strings\en-gb\Language.resw" />
<PRIResource Include="Strings\en-gb\About.resw" />
<PRIResource Include="Strings\en-gb\Playback.resw" />
<PRIResource Include="Strings\en-gb\Navigation.resw" />
<PRIResource Include="Strings\en-gb\Appearance.resw" />
<PRIResource Include="Strings\en-gb\MediaLibrary.resw" />
<PRIResource Include="Strings\en-gb\Information.resw" />
<PRIResource Include="Strings\en-gb\Sidebar.resw" />
<PRIResource Include="Strings\en-GB\Language.resw" />
<PRIResource Include="Strings\en-GB\About.resw" />
<PRIResource Include="Strings\en-GB\Playback.resw" />
<PRIResource Include="Strings\en-GB\Navigation.resw" />
<PRIResource Include="Strings\en-GB\Appearance.resw" />
<PRIResource Include="Strings\en-GB\MediaLibrary.resw" />
<PRIResource Include="Strings\en-GB\Information.resw" />
<PRIResource Include="Strings\en-GB\Sidebar.resw" />
</ItemGroup>
<ItemGroup>
<Folder Include="Assets\AtAGlance\WidgetService\" />
Expand All @@ -961,13 +961,13 @@
<Folder Include="Settings\SyncingPages\" />
</ItemGroup>
<ItemGroup>
<PRIResource Include="Strings\en-gb\Setup.resw" />
<PRIResource Include="Strings\en-GB\Setup.resw" />
</ItemGroup>
<ItemGroup>
<PRIResource Include="Strings\en-gb\Terms.resw" />
<PRIResource Include="Strings\en-GB\Terms.resw" />
</ItemGroup>
<ItemGroup>
<PRIResource Include="Strings\en-gb\Connect.resw" />
<PRIResource Include="Strings\en-GB\Connect.resw" />
</ItemGroup>
<ItemGroup>
<Content Include="Assets\MediaPlayerIcons.ttf">
Expand Down Expand Up @@ -1077,14 +1077,14 @@
<PRIResource Include="Strings\hi-IN\Connect.resw" />
<PRIResource Include="Strings\hi-IN\Appearance.resw" />
<PRIResource Include="Strings\hi-IN\About.resw" />
<PRIResource Include="Strings\en-gb\MediaData.resw" />
<PRIResource Include="Strings\en-gb\NowPlaying.resw" />
<PRIResource Include="Strings\en-gb\File.resw" />
<PRIResource Include="Strings\en-gb\Details.resw" />
<PRIResource Include="Strings\en-gb\Props.resw" />
<PRIResource Include="Strings\en-gb\Finish.resw" />
<PRIResource Include="Strings\en-gb\Privacy.resw" />
<PRIResource Include="Strings\en-gb\Local.resw" />
<PRIResource Include="Strings\en-GB\MediaData.resw" />
<PRIResource Include="Strings\en-GB\NowPlaying.resw" />
<PRIResource Include="Strings\en-GB\File.resw" />
<PRIResource Include="Strings\en-GB\Details.resw" />
<PRIResource Include="Strings\en-GB\Props.resw" />
<PRIResource Include="Strings\en-GB\Finish.resw" />
<PRIResource Include="Strings\en-GB\Privacy.resw" />
<PRIResource Include="Strings\en-GB\Local.resw" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Rise.Models\Rise.Models.csproj">
Expand Down
2 changes: 1 addition & 1 deletion Rise Media Player Dev/UserControls/NowPlayingBar.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ private async void Props_Click(object sender, RoutedEventArgs e)
if (!App.PViewModel.CurrentSong.IsOnline)
{
SelectedSong = App.PViewModel.CurrentSong;
await App.PViewModel.CurrentSong.StartEdit();
await App.PViewModel.CurrentSong.StartEditAsync();
}
}

Expand Down
Loading