1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-28 21:32:07 +00:00

LibGUI: Don't show "last saved" information for never-saved documents

When showing the "unsaved changes" dialog for an empty path, we should
say "last saved at ..." since that would be a lie.
This commit is contained in:
Andreas Kling 2022-01-04 18:07:06 +01:00
parent 219339d2a5
commit 0c09617b48

View file

@ -37,7 +37,7 @@ int MessageBox::ask_about_unsaved_changes(Window* parent_window, StringView path
builder.appendff("\"{}\"", LexicalPath::basename(path));
builder.append(" before closing?");
if (last_unmodified_timestamp.has_value()) {
if (!path.is_empty() && last_unmodified_timestamp.has_value()) {
auto age = (Time::now_monotonic() - *last_unmodified_timestamp).to_seconds();
builder.appendff("\nLast saved {} second{} ago.", age, age == 1 ? "" : "s");
}