From ddeb37a6c91e7f6fbf4a289ef56450b155481e96 Mon Sep 17 00:00:00 2001 From: Li Date: Thu, 18 Jul 2024 07:30:21 +1000 Subject: [PATCH 1/4] Add an optional import of feed data --- .gitattributes | 2 + LiftLog.Ui/LiftLog.Ui.csproj | 1 - .../ExportedDataDao/ExportedDataDaoV2.cs | 7 ++- .../ExportedDataDao/ExportedDataDaoV2.proto | 2 + LiftLog.Ui/Pages/Feed/FeedPage.razor | 29 ++++------- LiftLog.Ui/Pages/Index.razor | 16 +++--- .../Pages/Settings/BackupAndRestorePage.razor | 35 ++++++++++++- LiftLog.Ui/Shared/MainLayout.razor | 2 +- .../Presentation/ConfirmationDialog.razor | 49 ++++++++++++++++++ LiftLog.Ui/Shared/Presentation/Dialog.razor | 4 +- .../Smart/AndroidNotificationAlert.razor | 2 +- LiftLog.Ui/Store/Feed/FeedActions.cs | 2 + LiftLog.Ui/Store/Feed/FeedReducers.cs | 4 ++ LiftLog.Ui/Store/Settings/SettingsActions.cs | 5 +- LiftLog.Ui/Store/Settings/SettingsEffects.cs | 13 ++++- LiftLog.Web/Services/WebExporter.cs | 2 +- .../wwwroot/export.liftlogbackup.gz | Bin 17 files changed, 136 insertions(+), 39 deletions(-) create mode 100644 LiftLog.Ui/Shared/Presentation/ConfirmationDialog.razor rename {LiftLog.Ui => LiftLog.Web}/wwwroot/export.liftlogbackup.gz (100%) diff --git a/.gitattributes b/.gitattributes index 8df72f4e..7b08e098 100644 --- a/.gitattributes +++ b/.gitattributes @@ -63,3 +63,5 @@ #*.RTF diff=astextplain *.cs linguist-language=C# *.razor linguist-language=C# + +LiftLog.Ui/wwwroot/tailwind.js linguist-vendored diff --git a/LiftLog.Ui/LiftLog.Ui.csproj b/LiftLog.Ui/LiftLog.Ui.csproj index 00ab2026..3682bde4 100644 --- a/LiftLog.Ui/LiftLog.Ui.csproj +++ b/LiftLog.Ui/LiftLog.Ui.csproj @@ -44,7 +44,6 @@ - diff --git a/LiftLog.Ui/Models/ExportedDataDao/ExportedDataDaoV2.cs b/LiftLog.Ui/Models/ExportedDataDao/ExportedDataDaoV2.cs index 666272fb..7e777a41 100644 --- a/LiftLog.Ui/Models/ExportedDataDao/ExportedDataDaoV2.cs +++ b/LiftLog.Ui/Models/ExportedDataDao/ExportedDataDaoV2.cs @@ -11,12 +11,14 @@ internal partial class ExportedDataDaoV2 public ExportedDataDaoV2( IEnumerable sessions, IDictionary savedPrograms, - Guid activeProgramId + Guid activeProgramId, + FeedStateDaoV1? feedState ) { Sessions.AddRange(sessions); ActiveProgramId = activeProgramId.ToString(); SavedPrograms.Add(savedPrograms); + FeedState = feedState; } public static ExportedDataDaoV2 FromV1(ExportedDataDaoV1 v1) @@ -36,7 +38,8 @@ public static ExportedDataDaoV2 FromV1(ExportedDataDaoV1 v1) return new ExportedDataDaoV2( v1.Sessions.Select(x => x.ToModel()).Select(SessionDaoV2.FromModel), plans, - activePlanId + activePlanId, + null ); } } diff --git a/LiftLog.Ui/Models/ExportedDataDao/ExportedDataDaoV2.proto b/LiftLog.Ui/Models/ExportedDataDao/ExportedDataDaoV2.proto index 8135d8c5..7d5817ed 100644 --- a/LiftLog.Ui/Models/ExportedDataDao/ExportedDataDaoV2.proto +++ b/LiftLog.Ui/Models/ExportedDataDao/ExportedDataDaoV2.proto @@ -4,6 +4,7 @@ package LiftLog.Ui.Models.ExportedDataDao; import "Models/SessionHistoryDao/SessionHistoryDaoV2.proto"; import "Models/SessionBlueprintDao/SessionBlueprintDaoV2.proto"; import "Models/ProgramBlueprintDao/ProgramBlueprintDaoV1.proto"; +import "Models/FeedStateDao.proto"; import "google/protobuf/wrappers.proto"; message ExportedDataDaoV2 { @@ -11,4 +12,5 @@ message ExportedDataDaoV2 { repeated LiftLog.Ui.Models.SessionBlueprintDao.SessionBlueprintDaoV2 program = 2; map saved_programs = 3; google.protobuf.StringValue active_program_id = 4; + LiftLog.Ui.Models.FeedStateDaoV1 feed_state = 5; } diff --git a/LiftLog.Ui/Pages/Feed/FeedPage.razor b/LiftLog.Ui/Pages/Feed/FeedPage.razor index cc458327..094d1ea8 100644 --- a/LiftLog.Ui/Pages/Feed/FeedPage.razor +++ b/LiftLog.Ui/Pages/Feed/FeedPage.razor @@ -111,22 +111,15 @@ } - - Unfollow user - This will unfollow @(userToDelete?.Nickname ?? userToDelete?.Name ?? "Anonymous User") and remove all their content on your device. -
- Cancel - Unfollow -
-
- - Remove follower - This will stop @(userToDelete?.Nickname ?? userToDelete?.Name ?? "Anonymous User") from following you and remove all your content from their device. -
- Cancel - Unfollow -
-
+ + Unfollow user + This will unfollow @(userToDelete?.Nickname ?? userToDelete?.Name ?? "Anonymous User") and remove all their content on your device. + + + + Remove follower + This will stop @(userToDelete?.Nickname ?? userToDelete?.Name ?? "Anonymous User") from following you and remove all your content from their device. + @code { @@ -139,8 +132,8 @@ private ElementReference tabs; - private Dialog? deleteUserDialog; - private Dialog? removeFollowerDialog; + private ConfirmationDialog? deleteUserDialog; + private ConfirmationDialog? removeFollowerDialog; private FeedUser? userToDelete; private FullScreenDialog? settingsDialog; private FeedIdentityManager? feedIdentityManager; diff --git a/LiftLog.Ui/Pages/Index.razor b/LiftLog.Ui/Pages/Index.razor index 31379231..d6955a4b 100644 --- a/LiftLog.Ui/Pages/Index.razor +++ b/LiftLog.Ui/Pages/Index.razor @@ -88,21 +88,17 @@ else - - Replace current session - + + Replace current session + There is already a current session in progress, start a new one without saving? - -
- Cancel - Replace -
-
+ + @code { - private Dialog? replaceCurrentSesisonDialog; + private ConfirmationDialog? replaceCurrentSesisonDialog; private Session? selectedSession; protected override async Task OnInitializedAsync() diff --git a/LiftLog.Ui/Pages/Settings/BackupAndRestorePage.razor b/LiftLog.Ui/Pages/Settings/BackupAndRestorePage.razor index fd216ae0..20fb6810 100644 --- a/LiftLog.Ui/Pages/Settings/BackupAndRestorePage.razor +++ b/LiftLog.Ui/Pages/Settings/BackupAndRestorePage.razor @@ -16,11 +16,26 @@ + + + Import Feed Data? + +

This backup includes a feed account. Would you like to import it?

+

You will lose access to your current account without a backup.

+

This will replace your current account and cannot be undone!

+
+
+ + @code { + + private FeedState? importedFeedState; + private ConfirmationDialog? importFeedDialog; protected override void OnInitialized() { Dispatcher.Dispatch(new SetPageTitleAction("Backup and Restore")); Dispatcher.Dispatch(new SetBackNavigationUrlAction("/settings")); + SubscribeToAction(OnBeginFeedImport); base.OnInitialized(); } @@ -31,5 +46,23 @@ Dispatcher.Dispatch(new SetStatsIsDirtyAction(true)); } - private void ExportData() => Dispatcher.Dispatch(new ExportDataAction()); + private void ExportData() => Dispatcher.Dispatch(new ExportDataAction(true)); + + private void OnBeginFeedImport(BeginFeedImportAction action) + { + importedFeedState = action.FeedState; + importFeedDialog?.Open(); + } + + private void ImportFeedData() + { + if (importedFeedState is null) + { + return; + } + + Dispatcher.Dispatch(new SetFeedStateAction(importedFeedState)); + importedFeedState = null; + importFeedDialog?.Close(); + } } diff --git a/LiftLog.Ui/Shared/MainLayout.razor b/LiftLog.Ui/Shared/MainLayout.razor index 526b4080..c93d5c04 100644 --- a/LiftLog.Ui/Shared/MainLayout.razor +++ b/LiftLog.Ui/Shared/MainLayout.razor @@ -57,7 +57,7 @@ - +