Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

in-app change log functionality

laurenspriem99681f4e2353
diff --git a/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/HomeView.kt b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/HomeView.kt
index 08fd97bba2..3866f23cd1 100644
--- a/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/HomeView.kt
+++ b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/HomeView.kt
@@ -26,7 +26,6 @@ import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
-import androidx.compose.material3.AlertDialog
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.DrawerValue
import androidx.compose.material3.ModalBottomSheet
@@ -35,6 +34,7 @@ import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
+import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
@@ -68,8 +68,12 @@ import io.ente.ensu.domain.model.LogEntry
import io.ente.ensu.domain.state.AppState
import io.ente.ensu.domain.store.AppStore
import io.ente.ensu.utils.EnsuFeatureFlags
+import io.ente.ensu.whatsnew.PendingWhatsNew
+import io.ente.ensu.whatsnew.WhatsNewDialog
+import io.ente.ensu.whatsnew.WhatsNewService
import io.ente.labs.ensu_db.compressAttachmentImage
import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
@@ -105,6 +109,8 @@ fun HomeView(
var showLogShareDialog by remember { mutableStateOf(false) }
var showSignInComingSoon by remember { mutableStateOf(false) }
var imagePreviewAttachment by remember { mutableStateOf<Attachment?>(null) }
+ val whatsNewService = remember(context) { WhatsNewService(context.applicationContext) }
+ var pendingWhatsNew by remember { mutableStateOf<PendingWhatsNew?>(null) }
val handleSignInRequest: () -> Unit = handle@{
if (!EnsuFeatureFlags.enableSignIn) {
@@ -201,6 +207,11 @@ fun HomeView(
onDispose { lifecycleOwner.lifecycle.removeObserver(observer) }
}
+ LaunchedEffect(whatsNewService) {
+ delay(600)
+ pendingWhatsNew = whatsNewService.getPendingWhatsNew()
+ }
+
// Note: Drawer close is handled in navigation callbacks (onOpenSettings, onAccount, etc.)
// to avoid race conditions with route changes during navigation transitions.
@@ -338,6 +349,16 @@ fun HomeView(
)
}
+ pendingWhatsNew?.let { pending ->
+ WhatsNewDialog(
+ entries = pending.entries,
+ onDismiss = {
+ whatsNewService.markSeen()
+ pendingWhatsNew = null
+ }
+ )
+ }
+
if (deleteSessionTarget != null) {
NativeChoiceDialog(
title = "Delete Chat",
diff --git a/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/whatsnew/WhatsNewContent.kt b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/whatsnew/WhatsNewContent.kt
new file mode 100644
index 0000000000..4297a3f6e3
--- /dev/null
+++ b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/whatsnew/WhatsNewContent.kt
@@ -0,0 +1,17 @@
+package io.ente.ensu.whatsnew
+
+data class WhatsNewEntry(
+ val title: String,
+ val description: String
+)
+
+object WhatsNewContent {
+ const val VERSION: Int = 1
+
+ val entries: List<WhatsNewEntry> = listOf(
+ WhatsNewEntry(
+ title = "In-app release notes",
+ description = "Ensu can now show a short What's new note after updates, with platform-specific entries and a changelog version independent from the app build version."
+ )
+ )
+}
diff --git a/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/whatsnew/WhatsNewDialog.kt b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/whatsnew/WhatsNewDialog.kt
new file mode 100644
index 0000000000..bdc5c626ff
--- /dev/null
+++ b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/whatsnew/WhatsNewDialog.kt
@@ -0,0 +1,73 @@
+package io.ente.ensu.whatsnew
+
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.heightIn
+import androidx.compose.foundation.rememberScrollState
+import androidx.compose.foundation.verticalScroll
+import androidx.compose.material3.AlertDialog
+import androidx.compose.material3.ButtonDefaults
+import androidx.compose.material3.Text
+import androidx.compose.material3.TextButton
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.unit.dp
+import io.ente.ensu.designsystem.EnsuColor
+import io.ente.ensu.designsystem.EnsuSpacing
+import io.ente.ensu.designsystem.EnsuTypography
+
+@Composable
+fun WhatsNewDialog(
+ entries: List<WhatsNewEntry>,
+ onDismiss: () -> Unit
+) {
+ AlertDialog(
+ onDismissRequest = onDismiss,
+ title = {
+ Text(
+ text = "What's new",
+ style = EnsuTypography.h3Bold,
+ color = EnsuColor.textPrimary()
+ )
+ },
+ text = {
+ Column(
+ modifier = Modifier
+ .fillMaxWidth()
+ .heightIn(max = 360.dp)
+ .verticalScroll(rememberScrollState()),
+ verticalArrangement = Arrangement.spacedBy(EnsuSpacing.lg.dp)
+ ) {
+ entries.forEach { entry ->
+ WhatsNewEntryContent(entry)
+ }
+ }
+ },
+ confirmButton = {
+ TextButton(
+ onClick = onDismiss,
+ colors = ButtonDefaults.textButtonColors(contentColor = EnsuColor.textPrimary())
+ ) {
+ Text(text = "Continue", style = EnsuTypography.body)
+ }
+ },
+ containerColor = EnsuColor.backgroundBase()
+ )
+}
+
+@Composable
+private fun WhatsNewEntryContent(entry: WhatsNewEntry) {
+ Column(verticalArrangement = Arrangement.spacedBy(EnsuSpacing.sm.dp)) {
+ Text(
+ text = entry.title,
+ style = EnsuTypography.large,
+ color = EnsuColor.textPrimary()
+ )
+ Text(
+ text = entry.description,
+ style = EnsuTypography.body,
+ color = EnsuColor.textMuted()
+ )
+ }
+}
diff --git a/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/whatsnew/WhatsNewService.kt b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/whatsnew/WhatsNewService.kt
new file mode 100644
index 0000000000..d57004228f
--- /dev/null
+++ b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/whatsnew/WhatsNewService.kt
@@ -0,0 +1,45 @@
+package io.ente.ensu.whatsnew
+
+import android.content.Context
+
+data class PendingWhatsNew(
+ val version: Int,
+ val entries: List<WhatsNewEntry>
+)
+
+class WhatsNewService(context: Context) {
+ private val preferences = context.getSharedPreferences(
+ PREFERENCES_NAME,
+ Context.MODE_PRIVATE
+ )
+
+ fun getPendingWhatsNew(): PendingWhatsNew? {
+ val seenVersion = if (preferences.contains(KEY_SEEN_VERSION)) {
+ preferences.getInt(KEY_SEEN_VERSION, WhatsNewContent.VERSION)
+ } else {
+ 0
+ }
+ if (seenVersion >= WhatsNewContent.VERSION) return null
+
+ if (WhatsNewContent.entries.isEmpty()) {
+ markSeen()
+ return null
+ }
+
+ return PendingWhatsNew(
+ version = WhatsNewContent.VERSION,
+ entries = WhatsNewContent.entries
+ )
+ }
+
+ fun markSeen() {
+ preferences.edit()
+ .putInt(KEY_SEEN_VERSION, WhatsNewContent.VERSION)
+ .apply()
+ }
+
+ private companion object {
+ const val PREFERENCES_NAME = "ensu_whats_new"
+ const val KEY_SEEN_VERSION = "seen_version"
+ }
+}
diff --git a/mobile/native/darwin/Apps/Ensu/Ensu/Chat/ChatView.swift b/mobile/native/darwin/Apps/Ensu/Ensu/Chat/ChatView.swift
index b7501a7542..8d0d13397a 100644
--- a/mobile/native/darwin/Apps/Ensu/Ensu/Chat/ChatView.swift
+++ b/mobile/native/darwin/Apps/Ensu/Ensu/Chat/ChatView.swift
@@ -184,6 +184,13 @@ struct ChatView: View {
onDismiss: { viewState.showAttachmentDownloads = false }
)
}
+ .sheet(item: $viewState.pendingWhatsNew, onDismiss: {
+ markWhatsNewSeen()
+ }) { pending in
+ WhatsNewSheet(entries: pending.entries) {
+ markWhatsNewSeen()
+ }
+ }
.alert(item: $viewState.deleteSession) { session in
Alert(
title: Text("Delete Chat"),
@@ -221,6 +228,16 @@ struct ChatView: View {
.transition(.move(edge: .bottom).combined(with: .opacity))
}
}
+ .task {
+ do {
+ try await Task.sleep(nanoseconds: 600_000_000)
+ } catch {
+ return
+ }
+ if viewState.pendingWhatsNew == nil {
+ viewState.pendingWhatsNew = WhatsNewService.shared.pendingWhatsNew()
+ }
+ }
#if os(iOS)
.ignoresSafeArea(.keyboard)
#endif
@@ -478,6 +495,11 @@ struct ChatView: View {
viewState.showSignInComingSoon = true
}
}
+
+ private func markWhatsNewSeen() {
+ WhatsNewService.shared.markSeen()
+ viewState.pendingWhatsNew = nil
+ }
}
private final class ChatViewState: ObservableObject {
@@ -493,6 +515,7 @@ private final class ChatViewState: ObservableObject {
@Published var wasDrawerOpen = false
@Published var didDismissKeyboard = false
@Published var sessionTransitionId = UUID()
+ @Published var pendingWhatsNew: PendingWhatsNew?
var toastTask: Task<Void, Never>?
}
diff --git a/mobile/native/darwin/Apps/Ensu/Ensu/Components/WhatsNewSheet.swift b/mobile/native/darwin/Apps/Ensu/Ensu/Components/WhatsNewSheet.swift
new file mode 100644
index 0000000000..1a1fd4ff37
--- /dev/null
+++ b/mobile/native/darwin/Apps/Ensu/Ensu/Components/WhatsNewSheet.swift
@@ -0,0 +1,48 @@
+#if canImport(EnteCore)
+import SwiftUI
+
+struct WhatsNewSheet: View {
+ let entries: [WhatsNewEntry]
+ let onContinue: () -> Void
+
+ var body: some View {
+ VStack(alignment: .leading, spacing: EnsuSpacing.lg) {
+ Text("What's new")
+ .font(EnsuTypography.h3Bold)
+ .foregroundStyle(EnsuColor.textPrimary)
+
+ ScrollView {
+ VStack(alignment: .leading, spacing: EnsuSpacing.lg) {
+ ForEach(entries, id: \.title) { entry in
+ WhatsNewEntryView(entry: entry)
+ }
+ }
+ .frame(maxWidth: .infinity, alignment: .leading)
+ }
+
+ PrimaryButton(text: "Continue", action: onContinue)
+ }
+ .padding(EnsuSpacing.lg)
+ .frame(minWidth: 320)
+ .presentationDetents([.medium, .large])
+ .background(EnsuColor.backgroundBase)
+ }
+}
+
+private struct WhatsNewEntryView: View {
+ let entry: WhatsNewEntry
+
+ var body: some View {
+ VStack(alignment: .leading, spacing: EnsuSpacing.sm) {
+ Text(entry.title)
+ .font(EnsuTypography.large)
+ .foregroundStyle(EnsuColor.textPrimary)
+
+ Text(entry.description)
+ .font(EnsuTypography.body)
+ .foregroundStyle(EnsuColor.textMuted)
+ .fixedSize(horizontal: false, vertical: true)
+ }
+ }
+}
+#endif
diff --git a/mobile/native/darwin/Apps/Ensu/Ensu/Services/WhatsNewContent.swift b/mobile/native/darwin/Apps/Ensu/Ensu/Services/WhatsNewContent.swift
new file mode 100644
index 0000000000..df890221d0
--- /dev/null
+++ b/mobile/native/darwin/Apps/Ensu/Ensu/Services/WhatsNewContent.swift
@@ -0,0 +1,18 @@
+#if canImport(EnteCore)
+import Foundation
+
+struct WhatsNewEntry: Equatable {
+ let title: String
+ let description: String
+}
+
+enum WhatsNewContent {
+ static let version = 1
+ static let entries: [WhatsNewEntry] = [
+ WhatsNewEntry(
+ title: "In-app release notes",
+ description: "Ensu can now show a short What's new note after updates, with platform-specific entries and a changelog version independent from the app build version."
+ )
+ ]
+}
+#endif
diff --git a/mobile/native/darwin/Apps/Ensu/Ensu/Services/WhatsNewService.swift b/mobile/native/darwin/Apps/Ensu/Ensu/Services/WhatsNewService.swift
new file mode 100644
index 0000000000..a644593b19
--- /dev/null
+++ b/mobile/native/darwin/Apps/Ensu/Ensu/Services/WhatsNewService.swift
@@ -0,0 +1,48 @@
+#if canImport(EnteCore)
+import Foundation
+
+struct PendingWhatsNew: Identifiable {
+ let version: Int
+ let entries: [WhatsNewEntry]
+
+ var id: Int { version }
+}
+
+final class WhatsNewService {
+ static let shared = WhatsNewService()
+
+ private let defaults: UserDefaults
+ private let seenVersionKey = "ensu.whatsNew.seenVersion"
+
+ init(defaults: UserDefaults = .standard) {
+ self.defaults = defaults
+ }
+
+ func pendingWhatsNew() -> PendingWhatsNew? {
+ let seenVersion: Int
+ if defaults.object(forKey: seenVersionKey) == nil {
+ seenVersion = 0
+ } else {
+ seenVersion = defaults.integer(forKey: seenVersionKey)
+ }
+
+ if seenVersion >= WhatsNewContent.version {
+ return nil
+ }
+
+ if WhatsNewContent.entries.isEmpty {
+ markSeen()
+ return nil
+ }
+
+ return PendingWhatsNew(
+ version: WhatsNewContent.version,
+ entries: WhatsNewContent.entries
+ )
+ }
+
+ func markSeen() {
+ defaults.set(WhatsNewContent.version, forKey: seenVersionKey)
+ }
+}
+#endif
diff --git a/web/apps/ensu/src/components/WhatsNewDialog.tsx b/web/apps/ensu/src/components/WhatsNewDialog.tsx
new file mode 100644
index 0000000000..9a34c0c4b3
--- /dev/null
+++ b/web/apps/ensu/src/components/WhatsNewDialog.tsx
@@ -0,0 +1,44 @@
+import {
+ Button,
+ Dialog,
+ DialogActions,
+ DialogContent,
+ DialogTitle,
+ Stack,
+ Typography,
+} from "@mui/material";
+import React from "react";
+import type { WhatsNewEntry } from "services/whats-new-content";
+
+export interface WhatsNewDialogProps {
+ readonly open: boolean;
+ readonly entries: readonly WhatsNewEntry[];
+ readonly onClose: () => void;
+}
+
+export const WhatsNewDialog: React.FC<WhatsNewDialogProps> = ({
+ open,
+ entries,
+ onClose,
+}) => (
+ <Dialog open={open} onClose={onClose} maxWidth="xs" fullWidth>
+ <DialogTitle sx={{ pb: 1 }}>{"What's new"}</DialogTitle>
+ <DialogContent sx={{ pt: 0 }}>
+ <Stack spacing={2}>
+ {entries.map((entry, index) => (
+ <Stack key={`${entry.title}-${index}`} spacing={1}>
+ <Typography variant="h6">{entry.title}</Typography>
+ <Typography color="text.muted">
+ {entry.description}
+ </Typography>
+ </Stack>
+ ))}
+ </Stack>
+ </DialogContent>
+ <DialogActions sx={{ px: 3, pb: 3 }}>
+ <Button onClick={onClose} variant="contained" fullWidth>
+ Continue
+ </Button>
+ </DialogActions>
+ </Dialog>
+);
diff --git a/web/apps/ensu/src/pages/_app.tsx b/web/apps/ensu/src/pages/_app.tsx
index 807cf83c4c..a6afe56829 100644
--- a/web/apps/ensu/src/pages/_app.tsx
+++ b/web/apps/ensu/src/pages/_app.tsx
@@ -1,5 +1,6 @@
import { CssBaseline } from "@mui/material";
import { ThemeProvider } from "@mui/material/styles";
+import { WhatsNewDialog } from "components/WhatsNewDialog";
import { savedLocalUser } from "ente-accounts/services/accounts-db";
import { staticAppTitle } from "ente-base/app";
import { CustomHead } from "ente-base/components/Head";
@@ -19,9 +20,14 @@ import { BaseContext, deriveBaseContext } from "ente-base/context";
import { logStartupBanner } from "ente-base/log-web";
import "katex/dist/katex.min.css";
import type { AppProps } from "next/app";
-import React, { useCallback, useEffect, useMemo } from "react";
+import React, { useCallback, useEffect, useMemo, useState } from "react";
import { setupAutoAppUpdates } from "services/app-update";
import { ensuLogout } from "services/logout";
+import {
+ getPendingDesktopWhatsNew,
+ markDesktopWhatsNewSeen,
+ type PendingDesktopWhatsNew,
+} from "services/whats-new";
const App: React.FC<AppProps> = ({ Component, pageProps }) => {
useSetupLogs();
@@ -29,6 +35,10 @@ const App: React.FC<AppProps> = ({ Component, pageProps }) => {
const isI18nReady = useSetupI18n();
const isChangingRoute = useIsRouteChangeInProgress();
const { showMiniDialog, miniDialogProps } = useAttributedMiniDialog();
+ const [pendingWhatsNew, setPendingWhatsNew] = useState<
+ PendingDesktopWhatsNew | undefined
+ >();
+ const [isWhatsNewOpen, setIsWhatsNewOpen] = useState(false);
useEffect(() => {
logStartupBanner(savedLocalUser()?.id);
@@ -36,6 +46,20 @@ const App: React.FC<AppProps> = ({ Component, pageProps }) => {
useEffect(() => setupAutoAppUpdates(showMiniDialog), [showMiniDialog]);
+ useEffect(() => {
+ setPendingWhatsNew(getPendingDesktopWhatsNew());
+ }, []);
+
+ useEffect(() => {
+ if (!pendingWhatsNew || miniDialogProps.open || isWhatsNewOpen) return;
+
+ const timeoutId = window.setTimeout(() => {
+ if (!miniDialogProps.open) setIsWhatsNewOpen(true);
+ }, 600);
+
+ return () => window.clearTimeout(timeoutId);
+ }, [isWhatsNewOpen, miniDialogProps.open, pendingWhatsNew]);
+
useEffect(() => {
if (typeof window === "undefined") return;
const isTauri = "__TAURI__" in window || "__TAURI_IPC__" in window;
@@ -74,6 +98,12 @@ const App: React.FC<AppProps> = ({ Component, pageProps }) => {
void ensuLogout();
}, []);
+ const handleWhatsNewClose = useCallback(() => {
+ markDesktopWhatsNewSeen();
+ setIsWhatsNewOpen(false);
+ setPendingWhatsNew(undefined);
+ }, []);
+
const baseContext = useMemo(
() => deriveBaseContext({ logout, showMiniDialog }),
[logout, showMiniDialog],
@@ -86,6 +116,11 @@ const App: React.FC<AppProps> = ({ Component, pageProps }) => {
<CustomHead {...{ title }} />
<CssBaseline enableColorScheme />
<AttributedMiniDialog {...miniDialogProps} />
+ <WhatsNewDialog
+ open={isWhatsNewOpen}
+ entries={pendingWhatsNew?.entries ?? []}
+ onClose={handleWhatsNewClose}
+ />
<BaseContext value={baseContext}>
{!isI18nReady ? (
diff --git a/web/apps/ensu/src/services/whats-new-content.ts b/web/apps/ensu/src/services/whats-new-content.ts
new file mode 100644
index 0000000000..68bff4810b
--- /dev/null
+++ b/web/apps/ensu/src/services/whats-new-content.ts
@@ -0,0 +1,14 @@
+export interface WhatsNewEntry {
+ readonly title: string;
+ readonly description: string;
+}
+
+export const whatsNewVersion = 1;
+
+export const whatsNewEntries: readonly WhatsNewEntry[] = [
+ {
+ title: "In-app release notes",
+ description:
+ "Ensu can now show a short What's new note after updates, with platform-specific entries and a changelog version independent from the app build version.",
+ },
+];
diff --git a/web/apps/ensu/src/services/whats-new.ts b/web/apps/ensu/src/services/whats-new.ts
new file mode 100644
index 0000000000..7716899721
--- /dev/null
+++ b/web/apps/ensu/src/services/whats-new.ts
@@ -0,0 +1,55 @@
+import { isTauriAppRuntime } from "services/secure-storage";
+import {
+ whatsNewEntries,
+ whatsNewVersion,
+ type WhatsNewEntry,
+} from "services/whats-new-content";
+
+const storageKey = "ensu.whatsNew.seenVersion";
+
+export interface PendingDesktopWhatsNew {
+ readonly version: number;
+ readonly entries: readonly WhatsNewEntry[];
+}
+
+export const getPendingDesktopWhatsNew = ():
+ | PendingDesktopWhatsNew
+ | undefined => {
+ if (!isTauriAppRuntime()) return undefined;
+
+ const seenVersion = readSeenVersion();
+ if (seenVersion >= whatsNewVersion) return undefined;
+
+ if (whatsNewEntries.length === 0) {
+ markDesktopWhatsNewSeen();
+ return undefined;
+ }
+
+ return { version: whatsNewVersion, entries: whatsNewEntries };
+};
+
+export const markDesktopWhatsNewSeen = () => {
+ if (!isTauriAppRuntime()) return;
+
+ try {
+ window.localStorage.setItem(storageKey, String(whatsNewVersion));
+ } catch {
+ // localStorage can be unavailable in constrained webviews. In that
+ // case, avoid blocking app startup or showing the dialog repeatedly.
+ }
+};
+
+const readSeenVersion = () => {
+ try {
+ const rawValue = window.localStorage.getItem(storageKey);
+ if (rawValue === null) return 0;
+
+ const parsed = Number(rawValue);
+ if (Number.isInteger(parsed) && parsed > 0) return parsed;
+ } catch {
+ return whatsNewVersion;
+ }
+
+ markDesktopWhatsNewSeen();
+ return whatsNewVersion;
+};