From e670ad5701ba4e6fbfa2a9e087e818541e44c815 Mon Sep 17 00:00:00 2001 From: Mario Steele Date: Thu, 24 Jul 2025 04:21:10 -0500 Subject: [PATCH 1/5] Updated MapData Had data going in the wrong direction, corrected this. --- FreeTubeSync/Database/MapData.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/FreeTubeSync/Database/MapData.cs b/FreeTubeSync/Database/MapData.cs index f6dc079..ef8b010 100644 --- a/FreeTubeSync/Database/MapData.cs +++ b/FreeTubeSync/Database/MapData.cs @@ -4,7 +4,7 @@ namespace FreeTubeSync.Database; public static class MapData { - public static void MapFrom(this object obj1, object obj2) + public static void MapFrom(this object obj2, object obj1) { var props = new Dictionary(); var t1Type = obj1.GetType(); @@ -18,8 +18,12 @@ public static class MapData properties = t2Type.GetProperties(); foreach (var property in properties) { - if (props[property.Name] is not IEnumerable) - property.SetValue(obj2, props[property.Name]); + if (props.ContainsKey(property.Name)) + { + var value = props[property.Name]; + if (value is string || value is not IEnumerable) + property.SetValue(obj2, value); + } } } From 904db164613b01a8f95312136dff90cd79957355 Mon Sep 17 00:00:00 2001 From: Mario Steele Date: Thu, 24 Jul 2025 04:22:15 -0500 Subject: [PATCH 2/5] Updated SettingJson Changed from object to string, as it was to difficult to handle any data field in the value. --- FreeTubeSync/Model/Json/SettingJson.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FreeTubeSync/Model/Json/SettingJson.cs b/FreeTubeSync/Model/Json/SettingJson.cs index 2971293..a9d8f9a 100644 --- a/FreeTubeSync/Model/Json/SettingJson.cs +++ b/FreeTubeSync/Model/Json/SettingJson.cs @@ -6,5 +6,5 @@ namespace FreeTubeSync.Model.Json; public class SettingJson { public string _id { get; set; } = string.Empty; - public object value { get; set; } + public string value { get; set; } } \ No newline at end of file From 50ad10682be5cd96370ae4bd91b39a30c80785e1 Mon Sep 17 00:00:00 2001 From: Mario Steele Date: Thu, 24 Jul 2025 04:22:44 -0500 Subject: [PATCH 3/5] Updated Migrations Couple of migrations to get the Json Value to work properly. --- ...008_ChangeSettingToJsonElement.Designer.cs | 246 ++++++++++++++++++ ...250724061008_ChangeSettingToJsonElement.cs | 22 ++ ...916_FinalizeSettingStringValue.Designer.cs | 246 ++++++++++++++++++ ...250724074916_FinalizeSettingStringValue.cs | 22 ++ 4 files changed, 536 insertions(+) create mode 100644 FreeTubeSync/Migrations/20250724061008_ChangeSettingToJsonElement.Designer.cs create mode 100644 FreeTubeSync/Migrations/20250724061008_ChangeSettingToJsonElement.cs create mode 100644 FreeTubeSync/Migrations/20250724074916_FinalizeSettingStringValue.Designer.cs create mode 100644 FreeTubeSync/Migrations/20250724074916_FinalizeSettingStringValue.cs diff --git a/FreeTubeSync/Migrations/20250724061008_ChangeSettingToJsonElement.Designer.cs b/FreeTubeSync/Migrations/20250724061008_ChangeSettingToJsonElement.Designer.cs new file mode 100644 index 0000000..418a0d5 --- /dev/null +++ b/FreeTubeSync/Migrations/20250724061008_ChangeSettingToJsonElement.Designer.cs @@ -0,0 +1,246 @@ +// +using System.Text.Json; +using FreeTubeSync.Database; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace FreeTubeSync.Migrations +{ + [DbContext(typeof(DataContext))] + [Migration("20250724061008_ChangeSettingToJsonElement")] + partial class ChangeSettingToJsonElement + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "9.0.7"); + + modelBuilder.Entity("FreeTubeSync.Model.Database.History", b => + { + b.Property("_id") + .HasColumnType("TEXT"); + + b.Property("author") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("authorId") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("description") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("isLive") + .HasColumnType("INTEGER"); + + b.Property("lastViewedPlaylistItemId") + .HasColumnType("TEXT"); + + b.Property("lastViewedPlaylistType") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("lengthSeconds") + .HasColumnType("INTEGER"); + + b.Property("published") + .HasColumnType("INTEGER"); + + b.Property("timeWatched") + .HasColumnType("INTEGER"); + + b.Property("title") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("type") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("videoId") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("viewCount") + .HasColumnType("INTEGER"); + + b.Property("watchProgress") + .HasColumnType("REAL"); + + b.HasKey("_id"); + + b.ToTable("Histories"); + }); + + modelBuilder.Entity("FreeTubeSync.Model.Database.Playlist", b => + { + b.Property("_id") + .HasColumnType("TEXT"); + + b.Property("createdAt") + .HasColumnType("INTEGER"); + + b.Property("lastUpdatedAt") + .HasColumnType("INTEGER"); + + b.Property("playlistName") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("protected") + .HasColumnType("INTEGER"); + + b.HasKey("_id"); + + b.ToTable("Playlists"); + }); + + modelBuilder.Entity("FreeTubeSync.Model.Database.Profile", b => + { + b.Property("_id") + .HasColumnType("TEXT"); + + b.Property("bgColor") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("name") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("textColor") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("_id"); + + b.ToTable("Profiles"); + }); + + modelBuilder.Entity("FreeTubeSync.Model.Database.SearchHistory", b => + { + b.Property("_id") + .HasColumnType("TEXT"); + + b.Property("lastUpdatedAt") + .HasColumnType("INTEGER"); + + b.HasKey("_id"); + + b.ToTable("SearchHistories"); + }); + + modelBuilder.Entity("FreeTubeSync.Model.Database.Setting", b => + { + b.Property("_id") + .HasColumnType("TEXT"); + + b.Property("value") + .HasColumnType("TEXT"); + + b.HasKey("_id"); + + b.ToTable("Settings"); + }); + + modelBuilder.Entity("FreeTubeSync.Model.Database.Subscription", b => + { + b.Property("id") + .HasColumnType("TEXT"); + + b.Property("Profile_id") + .HasColumnType("TEXT"); + + b.Property("name") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("thumbnail") + .HasColumnType("TEXT"); + + b.HasKey("id"); + + b.HasIndex("Profile_id"); + + b.ToTable("Subscriptions"); + }); + + modelBuilder.Entity("FreeTubeSync.Model.Database.Video", b => + { + b.Property("playlistItemId") + .HasColumnType("TEXT"); + + b.Property("Playlist_id") + .HasColumnType("TEXT"); + + b.Property("author") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("authorId") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("lengthSeconds") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("pubished") + .HasColumnType("INTEGER"); + + b.Property("timeAdded") + .HasColumnType("INTEGER"); + + b.Property("title") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("type") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("videoId") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("playlistItemId"); + + b.HasIndex("Playlist_id"); + + b.ToTable("Videos"); + }); + + modelBuilder.Entity("FreeTubeSync.Model.Database.Subscription", b => + { + b.HasOne("FreeTubeSync.Model.Database.Profile", null) + .WithMany("subscriptions") + .HasForeignKey("Profile_id"); + }); + + modelBuilder.Entity("FreeTubeSync.Model.Database.Video", b => + { + b.HasOne("FreeTubeSync.Model.Database.Playlist", null) + .WithMany("videos") + .HasForeignKey("Playlist_id"); + }); + + modelBuilder.Entity("FreeTubeSync.Model.Database.Playlist", b => + { + b.Navigation("videos"); + }); + + modelBuilder.Entity("FreeTubeSync.Model.Database.Profile", b => + { + b.Navigation("subscriptions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/FreeTubeSync/Migrations/20250724061008_ChangeSettingToJsonElement.cs b/FreeTubeSync/Migrations/20250724061008_ChangeSettingToJsonElement.cs new file mode 100644 index 0000000..7a033a2 --- /dev/null +++ b/FreeTubeSync/Migrations/20250724061008_ChangeSettingToJsonElement.cs @@ -0,0 +1,22 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace FreeTubeSync.Migrations +{ + /// + public partial class ChangeSettingToJsonElement : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + + } + } +} diff --git a/FreeTubeSync/Migrations/20250724074916_FinalizeSettingStringValue.Designer.cs b/FreeTubeSync/Migrations/20250724074916_FinalizeSettingStringValue.Designer.cs new file mode 100644 index 0000000..4e70266 --- /dev/null +++ b/FreeTubeSync/Migrations/20250724074916_FinalizeSettingStringValue.Designer.cs @@ -0,0 +1,246 @@ +// +using FreeTubeSync.Database; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace FreeTubeSync.Migrations +{ + [DbContext(typeof(DataContext))] + [Migration("20250724074916_FinalizeSettingStringValue")] + partial class FinalizeSettingStringValue + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "9.0.7"); + + modelBuilder.Entity("FreeTubeSync.Model.Database.History", b => + { + b.Property("_id") + .HasColumnType("TEXT"); + + b.Property("author") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("authorId") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("description") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("isLive") + .HasColumnType("INTEGER"); + + b.Property("lastViewedPlaylistItemId") + .HasColumnType("TEXT"); + + b.Property("lastViewedPlaylistType") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("lengthSeconds") + .HasColumnType("INTEGER"); + + b.Property("published") + .HasColumnType("INTEGER"); + + b.Property("timeWatched") + .HasColumnType("INTEGER"); + + b.Property("title") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("type") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("videoId") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("viewCount") + .HasColumnType("INTEGER"); + + b.Property("watchProgress") + .HasColumnType("REAL"); + + b.HasKey("_id"); + + b.ToTable("Histories"); + }); + + modelBuilder.Entity("FreeTubeSync.Model.Database.Playlist", b => + { + b.Property("_id") + .HasColumnType("TEXT"); + + b.Property("createdAt") + .HasColumnType("INTEGER"); + + b.Property("lastUpdatedAt") + .HasColumnType("INTEGER"); + + b.Property("playlistName") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("protected") + .HasColumnType("INTEGER"); + + b.HasKey("_id"); + + b.ToTable("Playlists"); + }); + + modelBuilder.Entity("FreeTubeSync.Model.Database.Profile", b => + { + b.Property("_id") + .HasColumnType("TEXT"); + + b.Property("bgColor") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("name") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("textColor") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("_id"); + + b.ToTable("Profiles"); + }); + + modelBuilder.Entity("FreeTubeSync.Model.Database.SearchHistory", b => + { + b.Property("_id") + .HasColumnType("TEXT"); + + b.Property("lastUpdatedAt") + .HasColumnType("INTEGER"); + + b.HasKey("_id"); + + b.ToTable("SearchHistories"); + }); + + modelBuilder.Entity("FreeTubeSync.Model.Database.Setting", b => + { + b.Property("_id") + .HasColumnType("TEXT"); + + b.Property("value") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("_id"); + + b.ToTable("Settings"); + }); + + modelBuilder.Entity("FreeTubeSync.Model.Database.Subscription", b => + { + b.Property("id") + .HasColumnType("TEXT"); + + b.Property("Profile_id") + .HasColumnType("TEXT"); + + b.Property("name") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("thumbnail") + .HasColumnType("TEXT"); + + b.HasKey("id"); + + b.HasIndex("Profile_id"); + + b.ToTable("Subscriptions"); + }); + + modelBuilder.Entity("FreeTubeSync.Model.Database.Video", b => + { + b.Property("playlistItemId") + .HasColumnType("TEXT"); + + b.Property("Playlist_id") + .HasColumnType("TEXT"); + + b.Property("author") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("authorId") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("lengthSeconds") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("pubished") + .HasColumnType("INTEGER"); + + b.Property("timeAdded") + .HasColumnType("INTEGER"); + + b.Property("title") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("type") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("videoId") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("playlistItemId"); + + b.HasIndex("Playlist_id"); + + b.ToTable("Videos"); + }); + + modelBuilder.Entity("FreeTubeSync.Model.Database.Subscription", b => + { + b.HasOne("FreeTubeSync.Model.Database.Profile", null) + .WithMany("subscriptions") + .HasForeignKey("Profile_id"); + }); + + modelBuilder.Entity("FreeTubeSync.Model.Database.Video", b => + { + b.HasOne("FreeTubeSync.Model.Database.Playlist", null) + .WithMany("videos") + .HasForeignKey("Playlist_id"); + }); + + modelBuilder.Entity("FreeTubeSync.Model.Database.Playlist", b => + { + b.Navigation("videos"); + }); + + modelBuilder.Entity("FreeTubeSync.Model.Database.Profile", b => + { + b.Navigation("subscriptions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/FreeTubeSync/Migrations/20250724074916_FinalizeSettingStringValue.cs b/FreeTubeSync/Migrations/20250724074916_FinalizeSettingStringValue.cs new file mode 100644 index 0000000..307c6e6 --- /dev/null +++ b/FreeTubeSync/Migrations/20250724074916_FinalizeSettingStringValue.cs @@ -0,0 +1,22 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace FreeTubeSync.Migrations +{ + /// + public partial class FinalizeSettingStringValue : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + + } + } +} From 71a33539c4d20261d6d61089dc544fa4720938b2 Mon Sep 17 00:00:00 2001 From: Mario Steele Date: Thu, 24 Jul 2025 04:23:05 -0500 Subject: [PATCH 4/5] Updated Solution Added reference to the database in development. --- FreeTubeSync.sln | 1 + 1 file changed, 1 insertion(+) diff --git a/FreeTubeSync.sln b/FreeTubeSync.sln index 29c73d0..1e234e7 100644 --- a/FreeTubeSync.sln +++ b/FreeTubeSync.sln @@ -7,6 +7,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution compose.yaml = compose.yaml Dockerfile = Dockerfile README.md = README.md + data\FreeTubeSync.db = data\FreeTubeSync.db EndProjectSection EndProject Global From 4f51b82a933d3d16993596197c276dd936782053 Mon Sep 17 00:00:00 2001 From: Mario Steele Date: Thu, 24 Jul 2025 04:23:32 -0500 Subject: [PATCH 5/5] Updated misc files --- FreeTubeSync.sln.DotSettings.user | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/FreeTubeSync.sln.DotSettings.user b/FreeTubeSync.sln.DotSettings.user index 6675bb5..ead3520 100644 --- a/FreeTubeSync.sln.DotSettings.user +++ b/FreeTubeSync.sln.DotSettings.user @@ -1,3 +1,6 @@  ForceIncluded - ForceIncluded \ No newline at end of file + ForceIncluded + ForceIncluded + ForceIncluded + ForceIncluded \ No newline at end of file