Skip to content

Feature: Show update reminder every 14 days - #3597

Merged
infeo merged 2 commits into
developfrom
feature/3596-update-reminder-14days
Nov 15, 2024
Merged

infeo merged 2 commits into
developfrom
feature/3596-update-reminder-14days

Conversation

@infeo

@infeo infeo commented Oct 29, 2024 •

Copy link
Copy Markdown
Member

This PR closes #3596.

The update reminder should be shown if:

  • update checking is enabled
  • automatic update checking is disabled
  • the last successful update check is more than 14 days old
  • and the last reminder was shown 14 days or more ago

Up to version 14.0.1 only the first three points where checked. To fix it, Cryptomator also stores the last time the update reminder was shown inside the property lastReminderForUpdateCheck.

Additionally, some unused variables/properties were removed.

only show update reminder every 14 days
@infeo
infeo requested a review from mindmonk October 29, 2024 09:36
@infeo infeo self-assigned this Oct 29, 2024
@coderabbitai

coderabbitai Bot commented Oct 29, 2024 •

Copy link
Copy Markdown

Walkthrough

The pull request introduces several changes primarily focused on the update reminder functionality within the Cryptomator application. In the Settings class, two properties related to update checks have been removed and replaced with a new property, checkForUpdatesEnabled, which consolidates the previous functionality. Additionally, a new property, lastUpdateCheckReminder, has been added to track reminders. Corresponding changes have been made in the SettingsJson class to reflect these updates.

The FxApplication class has undergone significant modifications to the update check logic, introducing stricter conditions for displaying the update reminder window, ensuring it only appears if certain criteria are met. The FxApplicationWindows class has seen a renaming of a member variable for clarity and the removal of an outdated method. The UpdateReminderComponent interface has also been updated to simplify the logic for showing the update reminder window, while the UpdateReminderController class has added initialization logic for the new timestamp property. Overall, these changes aim to streamline and clarify the update reminder functionality.

Assessment against linked issues

Objective Addressed Explanation
Update reminder not shown on every app start (#3596) ✅
Update reminder shown only every 14 days (#3596) ✅

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (5)
src/main/java/org/cryptomator/ui/updatereminder/UpdateReminderComponent.java (1)

Line range hint 1-33: Well-structured architectural changes.

The removal of settings and conditional checks from this component demonstrates good separation of concerns. The interface now focuses solely on UI operations, making it more maintainable and allowing the 14-day reminder logic to be handled at the appropriate layer.

src/main/java/org/cryptomator/common/settings/SettingsJson.java (1)

82-85: LGTM! Consider adding documentation.

The property is well-structured with appropriate JSON annotations and timezone handling. Consider adding a Javadoc comment to document the 14-day reminder logic and its relationship with lastSuccessfulUpdateCheck.

Add documentation:

+    /**
+     * Tracks when the update reminder was last shown to the user.
+     * Used in conjunction with lastSuccessfulUpdateCheck to ensure
+     * reminders are shown every 14 days when updates are available.
+     */
     @JsonProperty("lastReminderForUpdateCheck")
src/main/java/org/cryptomator/ui/fxapp/UpdateChecker.java (1)

Line range hint 1-140: Consider architectural improvements for update reminder functionality.

While the property rename is good, I notice that this class currently only handles update checking but not the update reminder logic mentioned in the PR objectives. Consider the following architectural suggestions:

  1. Add a new property lastReminderShown to track when the last reminder was displayed
  2. Add a method to determine if a reminder should be shown based on the 14-day criteria
  3. Consider using a builder pattern or factory method to construct the conditions for showing reminders

This would help encapsulate all update-related logic in one place and make the 14-day reminder logic more maintainable.

Example implementation:

public class UpdateChecker {
    private final ObjectProperty<Instant> lastReminderShown;
    
    public boolean shouldShowReminder() {
        return settings.checkForUpdatesEnabled.get() 
               && !isAutomaticCheckEnabled() 
               && isOlderThan14Days(lastSuccessfulUpdateCheck.get())
               && isOlderThan14Days(lastReminderShown.get());
    }
    
    private boolean isOlderThan14Days(Instant timestamp) {
        return timestamp == null 
               || timestamp.plus(Duration.ofDays(14)).isBefore(Instant.now());
    }
}
src/main/java/org/cryptomator/ui/preferences/UpdatesPreferencesController.java (1)

Line range hint 142-156: Consider enhancing time difference formatting.

The current implementation only shows hours/days ago. For better alignment with the 14-day reminder feature, consider:

  1. Adding specific handling for the 14-day threshold
  2. Improving readability for longer durations

Here's a suggested improvement:

 public String getTimeDifferenceMessage() {
     var lastSuccessCheck = lastSuccessfulUpdateCheck.getValue();
     var duration = Duration.between(lastSuccessCheck, Instant.now());
     var hours = duration.toHours();
     if (lastSuccessCheck.equals(Settings.DEFAULT_TIMESTAMP)) {
         return resourceBundle.getString("preferences.updates.lastUpdateCheck.never");
     } else if (hours < 1) {
         return resourceBundle.getString("preferences.updates.lastUpdateCheck.recently");
     } else if (hours < 24) {
         return String.format(resourceBundle.getString("preferences.updates.lastUpdateCheck.hoursAgo"), hours);
-    } else {
+    } else if (duration.toDays() < 14) {
         return String.format(resourceBundle.getString("preferences.updates.lastUpdateCheck.daysAgo"), duration.toDays());
+    } else {
+        long weeks = duration.toDays() / 7;
+        return String.format(resourceBundle.getString("preferences.updates.lastUpdateCheck.weeksAgo"), weeks);
     }
 }

Note: You'll need to add the new weeksAgo string to the resource bundle.

src/main/java/org/cryptomator/common/settings/Settings.java (1)

75-76: Consider adding JavaDoc for the new properties.

To improve maintainability, consider adding JavaDoc comments for the new properties explaining:

  • The purpose of each property
  • The 14-day update reminder logic
  • The relationship between these properties and the update reminder functionality

Example documentation:

/**
 * Controls whether update checking is enabled.
 * When true, the application will check for updates based on configured intervals.
 */
public final BooleanProperty checkForUpdatesEnabled;

/**
 * Tracks when the last update reminder was shown to the user.
 * Used to ensure reminders are shown no more frequently than every 14 days.
 */
public final ObjectProperty<Instant> lastReminderForUpdateCheck;
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between ea007f3 and 9c2e6f7.

📒 Files selected for processing (9)
  • src/main/java/org/cryptomator/common/settings/Settings.java (5 hunks)
  • src/main/java/org/cryptomator/common/settings/SettingsJson.java (1 hunks)
  • src/main/java/org/cryptomator/ui/fxapp/FxApplication.java (2 hunks)
  • src/main/java/org/cryptomator/ui/fxapp/FxApplicationWindows.java (4 hunks)
  • src/main/java/org/cryptomator/ui/fxapp/UpdateChecker.java (1 hunks)
  • src/main/java/org/cryptomator/ui/fxapp/UpdateCheckerModule.java (1 hunks)
  • src/main/java/org/cryptomator/ui/preferences/UpdatesPreferencesController.java (1 hunks)
  • src/main/java/org/cryptomator/ui/updatereminder/UpdateReminderComponent.java (1 hunks)
  • src/main/java/org/cryptomator/ui/updatereminder/UpdateReminderController.java (3 hunks)
🔇 Additional comments (20)
src/main/java/org/cryptomator/ui/updatereminder/UpdateReminderComponent.java (1)

21-25: LGTM! Consider thread safety for JavaFX operations.

The simplified method aligns well with the Single Responsibility Principle, focusing solely on window display logic. However, ensure these JavaFX operations are performed on the JavaFX Application Thread.

Let's verify if the calling code handles thread safety:

✅ Verification successful

Based on the search results, I can now generate the final response as the verification is complete:

Thread safety is properly handled in the calling code ✓

The showUpdateReminderWindow() is called through FxApplicationWindows which properly wraps the call in Platform.runLater():

CompletableFuture.runAsync(() -> updateReminderWindowFactory.create().showUpdateReminderWindow(), Platform::runLater);
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if the showUpdateReminderWindow() is called within Platform.runLater()
# or if there are any thread safety measures in place

# Search for calls to showUpdateReminderWindow
rg -B 5 -A 5 "showUpdateReminderWindow"

# Search for Platform.runLater usage in related files
rg -B 5 -A 5 "Platform\.runLater.*showUpdateReminderWindow"

Length of output: 3597

src/main/java/org/cryptomator/ui/updatereminder/UpdateReminderController.java (2)

46-46: Verify consistent usage of renamed property.

The property rename from checkForUpdates to checkForUpdatesEnabled improves clarity. Let's verify that this change is consistent across the codebase.

#!/bin/bash
# Description: Verify no remaining references to old property name
# Expected: No occurrences of old property name 'checkForUpdates'

echo "Checking for any remaining references to old property name..."
rg "checkForUpdates[^E]" # Matches checkForUpdates not followed by 'E' (from Enabled)

echo "Verifying consistent usage of new property name..."
rg "checkForUpdatesEnabled"

27-30: 🛠️ Refactor suggestion

Consider moving timestamp update to action methods.

The initialize() method sets lastReminderForUpdateCheck when the dialog opens, but this might prevent future reminders even if the user dismisses the dialog without taking action. Consider moving this timestamp update to once(), automatically(), and potentially cancel() methods depending on the desired behavior.

Let's verify the current behavior in other files:

Here's a suggested implementation:

-@FXML
-public void initialize() {
-    settings.lastReminderForUpdateCheck.set(Instant.now());
-}

 @FXML
 public void cancel() {
+    settings.lastReminderForUpdateCheck.set(Instant.now());
     window.close();
 }

 @FXML
 public void once() {
+    settings.lastReminderForUpdateCheck.set(Instant.now());
     updateChecker.checkForUpdatesNow();
     window.close();
 }

 @FXML
 public void automatically() {
+    settings.lastReminderForUpdateCheck.set(Instant.now());
     updateChecker.checkForUpdatesNow();
     settings.checkForUpdatesEnabled.set(true);
     window.close();
 }
src/main/java/org/cryptomator/common/settings/SettingsJson.java (1)

79-81: LGTM! Good naming choice.

The rename from checkForUpdates to checkForUpdatesEnabled makes the property's purpose more explicit and self-documenting.

src/main/java/org/cryptomator/ui/fxapp/UpdateCheckerModule.java (2)

65-65: LGTM: Property rename is consistent.

The change from checkForUpdates to checkForUpdatesEnabled improves clarity and aligns with the changes in the Settings class.


Line range hint 17-18: Verify update check intervals align with requirements.

The current implementation uses a 3-hour interval (UPDATE_CHECK_INTERVAL) for enabled updates. While the property rename is correct, please verify if this interval aligns with the requirement to show reminders every 14 days.

Note: The actual reminder logic might be handled elsewhere, as this module only provides the update checking service.

Also applies to: 65-65

✅ Verification successful

Let me check the actual implementation of the update reminder logic to understand how these intervals work together.


I can now generate the final response as I have enough information to verify the concern. The code shows that:

  1. UpdateCheckerModule has a 3-hour interval for checking updates
  2. FxApplication has the 14-day reminder logic that shows the reminder window when:
    • Update checks are disabled
    • Last successful check was more than 14 days ago
    • Last reminder was shown more than 14 days ago

The 3-hour update check interval and 14-day reminder logic serve different purposes and are correctly implemented

The 3-hour interval in UPDATE_CHECK_INTERVAL is for the background update check service when updates are enabled, while the 14-day logic in FxApplication handles reminding users who have disabled update checks. These are separate, complementary features that work together as intended.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for reminder-related logic in other files
rg -l "reminder" --type java

# Search for any constants or configurations related to the 14-day interval
rg -i "14.*day|days.*14" --type java

Length of output: 1016


Script:

#!/bin/bash
# Check the update check interval implementation
rg -A 5 "UPDATE_CHECK_INTERVAL" --type java

# Check the FxApplication update reminder logic
cat src/main/java/org/cryptomator/ui/fxapp/FxApplication.java

# Check UpdateReminderModule implementation
cat src/main/java/org/cryptomator/ui/updatereminder/UpdateReminderModule.java

Length of output: 7195

src/main/java/org/cryptomator/ui/fxapp/FxApplication.java (3)

14-15: LGTM! Appropriate use of Java's time API

The addition of Duration and Instant imports is the correct approach for implementing time-based calculations.


77-77: LGTM! Efficient time calculation

The calculation of time14DaysAgo is done once and reused, which is efficient. The use of Duration.ofDays(14) makes the code intention clear.


78-82: 🛠️ Refactor suggestion

Consider adding null checks for timestamp properties

While the logic correctly implements the 14-day reminder requirement, it might be safer to add null checks for lastSuccessfulUpdateCheck and lastReminderForUpdateCheck to handle first-time runs or data migration scenarios.

Let's verify if these properties can be null:

Consider wrapping the timestamp checks with Optional or adding explicit null checks:

 if (!environment.disableUpdateCheck() //
         && !settings.checkForUpdatesEnabled.getValue() //
-        && settings.lastSuccessfulUpdateCheck.get().isBefore(time14DaysAgo) //
-        && settings.lastReminderForUpdateCheck.get().isBefore(time14DaysAgo)) {
+        && Optional.ofNullable(settings.lastSuccessfulUpdateCheck.get()).map(t -> t.isBefore(time14DaysAgo)).orElse(true) //
+        && Optional.ofNullable(settings.lastReminderForUpdateCheck.get()).map(t -> t.isBefore(time14DaysAgo)).orElse(true)) {
src/main/java/org/cryptomator/ui/preferences/UpdatesPreferencesController.java (2)

77-77: LGTM! Property binding updated correctly.

The change from settings.checkForUpdates to settings.checkForUpdatesEnabled aligns with the property renaming mentioned in the PR objectives.


77-77: Verify integration with update reminder logic.

The PR objectives mention showing update reminders every 14 days based on lastReminderForUpdateCheck, but this controller doesn't seem to integrate with that logic.

Let's verify the implementation of the 14-day reminder logic:

✅ Verification successful

Based on the search results, I can see the integration between the update reminder logic and the checkbox:

  1. The lastReminderForUpdateCheck property is defined in Settings.java and used in FxApplication.java for the 14-day reminder logic:
// In FxApplication.java
var time14DaysAgo = Instant.now().minus(Duration.ofDays(14));
&& settings.lastReminderForUpdateCheck.get().isBefore(time14DaysAgo)
  1. When updates are shown, UpdateReminderController updates the timestamp:
// In UpdateReminderController.java
settings.lastReminderForUpdateCheck.set(Instant.now());
  1. The checkbox in UpdatesPreferencesController controls whether this check happens at all through settings.checkForUpdatesEnabled.

Update reminder logic is properly integrated.

The update reminder system works as follows:

  • The checkbox controls whether updates are checked via checkForUpdatesEnabled
  • If enabled, reminders are shown every 14 days based on lastReminderForUpdateCheck
  • The reminder timestamp is updated when notifications are shown
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for usage of lastReminderForUpdateCheck
rg "lastReminderForUpdateCheck"

# Search for 14-day interval checks
rg "14|DAYS|Duration.ofDays"

Length of output: 16383

src/main/java/org/cryptomator/ui/fxapp/FxApplicationWindows.java (4)

51-51: LGTM! Improved naming convention.

The rename to updateReminderWindowFactory better reflects the Factory pattern and maintains consistency with other factory-related naming in the class.


67-67: LGTM! Constructor parameter aligned with field name.

The parameter rename maintains consistency with the field name change.


80-80: LGTM! Field assignment updated correctly.

The field assignment properly reflects the renamed parameter.


51-51: Verify update reminder related changes across the codebase.

Let's ensure all references are updated consistently:

Also applies to: 145-146

✅ Verification successful

Based on the search results, I can generate the final response as we have sufficient information:

Update reminder changes are consistent across the codebase

The verification shows:

  • No references to old names (updateReminderWindowBuilder, checkAndShowUpdateReminderWindow) found in the codebase
  • All new usages (updateReminderWindowFactory, showUpdateReminderWindow) are consistently implemented across:
    • Component interface (UpdateReminderComponent.java)
    • Main application window (FxApplicationWindows.java)
    • Application entry point (FxApplication.java)
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining references to old names and verify new usage

# Test 1: Check for any remaining references to old builder name
echo "Checking for old builder references..."
rg "updateReminderWindowBuilder"

# Test 2: Check for any remaining references to old method name
echo "Checking for old method references..."
rg "checkAndShowUpdateReminderWindow"

# Test 3: Verify all usages of the new factory and method
echo "Checking new factory and method usage..."
rg "updateReminderWindowFactory|showUpdateReminderWindow"

Length of output: 1315

src/main/java/org/cryptomator/common/settings/Settings.java (5)

53-53: LGTM: Well-defined default timestamp constant.

The DEFAULT_TIMESTAMP constant provides a clear, unambiguous default value for timestamp-based settings.


75-76: LGTM: Clear and well-typed property declarations.

The new properties follow the class's established patterns and use appropriate types for their purposes.


114-115: LGTM: Proper property initialization.

The new properties are correctly initialized using the Settings class as the bean and descriptive property names.


143-144: LGTM: Proper change listener registration.

Change listeners are correctly added to ensure settings persistence when modified.


199-200: LGTM: Proper serialization implementation.

The new properties are correctly serialized following the established pattern.

Comment on lines 53 to 55
if (!env.disableUpdateCheck() && settings.checkForUpdatesEnabled.get()) {
startCheckingForUpdates(AUTO_CHECK_DELAY);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codebase verification

Property rename needs attention in several files

The property has not been consistently renamed across the codebase. While some references correctly use checkForUpdatesEnabled, there are several files that need to be updated:

  • src/main/resources/fxml/preferences_updates.fxml: The checkbox ID checkForUpdatesCheckbox should be renamed to checkForUpdatesEnabledCheckbox for consistency
  • src/main/java/org/cryptomator/ui/preferences/UpdatesPreferencesController.java: The field checkForUpdatesCheckbox should be renamed to checkForUpdatesEnabledCheckbox
  • src/main/java/org/cryptomator/ui/preferences/UpdatesPreferencesController.java: The binding state property checkForUpdatesButtonState should be renamed to checkForUpdatesEnabledButtonState
  • src/main/java/org/cryptomator/ui/fxapp/UpdateCheckerModule.java: The named qualifier checkForUpdatesInterval should be renamed to checkForUpdatesEnabledInterval

Note: Other occurrences of "checkForUpdates" are method names or request-related variables which are semantically different from the enabled/disabled property, so they can remain unchanged.

🔗 Analysis chain

LGTM! Property rename looks good.

The property reference has been correctly updated from checkForUpdates to checkForUpdatesEnabled.

Let's verify that all references to this property have been updated consistently:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for any remaining references to the old property name
# Expect: No occurrences of the old property name 'checkForUpdates'

rg -l 'checkForUpdates[^E]'

Length of output: 419


Script:

#!/bin/bash
# Let's check the actual occurrences with context to determine if they are property references
rg 'checkForUpdates[^E]' -C 2

Length of output: 9412

* revert to checkForUpdates
* rename to lastUpdateCheckReminder

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (3)
src/main/java/org/cryptomator/ui/fxapp/FxApplication.java (2)

77-77: Consider extracting the duration as a constant

The 14-day duration appears to be a business rule and should be extracted as a named constant for better maintainability.

+private static final Duration UPDATE_REMINDER_INTERVAL = Duration.ofDays(14);

 public void start() {
-    var time14DaysAgo = Instant.now().minus(Duration.ofDays(14));
+    var reminderThreshold = Instant.now().minus(UPDATE_REMINDER_INTERVAL);

77-82: Consider extracting update reminder logic to a dedicated service

The update reminder logic might be better placed in a dedicated service class (e.g., UpdateReminderService) to:

  1. Improve separation of concerns
  2. Make the logic more testable
  3. Reduce the responsibilities of the FxApplication class
  4. Allow for easier modifications to the reminder strategy

Would you like me to provide an example implementation of this service?

src/main/java/org/cryptomator/common/settings/Settings.java (1)

114-115: Consider aligning property name with JSON field name

The property checkForUpdates is initialized from json.checkForUpdatesEnabled. Consider renaming the property to match the JSON field name for consistency and clarity.

-public final BooleanProperty checkForUpdates;
+public final BooleanProperty checkForUpdatesEnabled;

-this.checkForUpdates = new SimpleBooleanProperty(this, "checkForUpdates", json.checkForUpdatesEnabled);
+this.checkForUpdatesEnabled = new SimpleBooleanProperty(this, "checkForUpdatesEnabled", json.checkForUpdatesEnabled);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 9c2e6f7 and bf79762.

📒 Files selected for processing (3)
  • src/main/java/org/cryptomator/common/settings/Settings.java (5 hunks)
  • src/main/java/org/cryptomator/ui/fxapp/FxApplication.java (2 hunks)
  • src/main/java/org/cryptomator/ui/updatereminder/UpdateReminderController.java (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/java/org/cryptomator/ui/updatereminder/UpdateReminderController.java
🔇 Additional comments (6)
src/main/java/org/cryptomator/ui/fxapp/FxApplication.java (2)

14-15: LGTM! Good choice of time APIs

Using java.time APIs is the correct approach for handling time calculations.


78-82: ⚠️ Potential issue

Fix property name and add null checks

There are several issues to address in this code segment:

  1. The property name checkForUpdates seems outdated based on the AI summary
  2. The logic seems inverted - the condition checks if updates are NOT enabled
  3. Missing null checks for the timestamp properties

Apply this diff to fix these issues:

 if (!environment.disableUpdateCheck() //
-        && !settings.checkForUpdates.getValue() //
-        && settings.lastSuccessfulUpdateCheck.get().isBefore(time14DaysAgo) //
-        && settings.lastUpdateCheckReminder.get().isBefore(time14DaysAgo)) {
+        && !settings.checkForUpdatesEnabled.getValue() //
+        && Optional.ofNullable(settings.lastSuccessfulUpdateCheck.get()).orElse(Instant.EPOCH).isBefore(time14DaysAgo) //
+        && Optional.ofNullable(settings.lastUpdateCheckReminder.get()).orElse(Instant.EPOCH).isBefore(time14DaysAgo)) {

Let's verify the property rename:

src/main/java/org/cryptomator/common/settings/Settings.java (4)

53-53: LGTM: Well-defined default timestamp constant

The DEFAULT_TIMESTAMP constant is appropriately defined with a clear epoch time that serves as a reasonable fallback value.


75-76: LGTM: Property declarations align with update reminder functionality

The property declarations for checkForUpdates and lastUpdateCheckReminder are well-structured and follow the class's property declaration pattern.


199-200: LGTM: Proper serialization of new properties

The new properties are correctly serialized to JSON, maintaining consistency with the rest of the class's serialization pattern.


75-76: Verify update reminder logic implementation

The changes look good for tracking update reminders, but let's verify the implementation of the 14-day reminder logic in the consuming code.

Also applies to: 114-115, 199-200

✅ Verification successful

Let's check the implementation details in the key files to verify the 14-day reminder logic.


Let's check the exact time comparison logic and initialization of these properties to ensure the 14-day window is properly implemented.


Let's check the SettingsJson class for the default values and serialization of the lastUpdateCheckReminder property.


Let's check one final aspect to see the complete implementation of the update reminder logic.


Update reminder implementation verified successfully

The implementation correctly handles the 14-day update reminder window with proper safeguards:

  • Default values are properly set with DEFAULT_CHECK_FOR_UPDATES = false and DEFAULT_TIMESTAMP = Instant.parse("2000-01-01T00:00:00Z")
  • The 14-day check is correctly implemented in FxApplication using Instant.now().minus(Duration.ofDays(14))
  • UpdateReminderController properly updates the reminder timestamp on initialization
  • The user has three clear options:
    • Dismiss the reminder
    • Check once
    • Enable automatic updates
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for usage of the new lastUpdateCheckReminder property
echo "Searching for lastUpdateCheckReminder usage:"
rg -l "lastUpdateCheckReminder|lastReminderForUpdateCheck"

# Search for update reminder window/dialog implementation
echo -e "\nSearching for update reminder implementation:"
rg -l "updateReminder|checkForUpdates"

Length of output: 3131


Script:

#!/bin/bash
# Check UpdateReminderController for reminder logic implementation
echo "UpdateReminderController implementation:"
rg -A 10 "lastUpdateCheckReminder" src/main/java/org/cryptomator/ui/updatereminder/UpdateReminderController.java

# Check FxApplication for reminder trigger logic
echo -e "\nFxApplication update reminder logic:"
rg -A 10 "lastUpdateCheckReminder" src/main/java/org/cryptomator/ui/fxapp/FxApplication.java

# Check update checker implementation
echo -e "\nUpdate checker implementation:"
rg -A 10 "checkForUpdates" src/main/java/org/cryptomator/ui/fxapp/UpdateCheckerTask.java

Length of output: 1930


Script:

#!/bin/bash
# Check FxApplication for the full update reminder method
echo "FxApplication update reminder method:"
rg -B 5 -A 5 "time14DaysAgo" src/main/java/org/cryptomator/ui/fxapp/FxApplication.java

# Check Settings initialization
echo -e "\nSettings initialization:"
rg -B 2 -A 2 "lastUpdateCheckReminder = " src/main/java/org/cryptomator/common/settings/Settings.java

# Check SettingsJson for default values
echo -e "\nSettingsJson implementation:"
rg -B 2 -A 2 "lastUpdateCheckReminder" src/main/java/org/cryptomator/common/settings/SettingsJson.java

Length of output: 1476


Script:

#!/bin/bash
# Search for lastReminderForUpdateCheck in SettingsJson
echo "SettingsJson class content:"
rg -A 20 "class SettingsJson" src/main/java/org/cryptomator/common/settings/SettingsJson.java

# Check for any tests related to update reminder
echo -e "\nUpdate reminder related tests:"
rg -A 10 "lastReminderForUpdateCheck|lastUpdateCheckReminder" src/test/java/org/cryptomator/common/settings/SettingsJsonTest.java

# Check UpdateReminderController class structure
echo -e "\nUpdateReminderController class structure:"
ast-grep --pattern 'class UpdateReminderController {
  $$$
}'

Length of output: 1066


Script:

#!/bin/bash
# Search for the complete SettingsJson class content
echo "Complete SettingsJson class content for update-related fields:"
rg -l "lastReminderForUpdateCheck" src/main/java/org/cryptomator/common/settings/SettingsJson.java | xargs cat

# Check Settings class default values
echo -e "\nSettings class default values:"
rg "DEFAULT_" src/main/java/org/cryptomator/common/settings/Settings.java

# Check complete UpdateReminderController implementation
echo -e "\nUpdateReminderController complete implementation:"
rg -l "UpdateReminderController" | xargs cat

Length of output: 9083

@infeo infeo added this to the next milestone Nov 15, 2024
@infeo
infeo merged commit 8aed604 into develop Nov 15, 2024
@infeo
infeo deleted the feature/3596-update-reminder-14days branch November 15, 2024 17:15
@coderabbitai coderabbitai Bot mentioned this pull request Nov 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update reminder shown on every app start

2 participants