Skip to content

Commit

Permalink
[objectbox] no admin on release mode
Browse files Browse the repository at this point in the history
  • Loading branch information
liplum committed Sep 26, 2024
1 parent e74a200 commit 598fc8b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
29 changes: 18 additions & 11 deletions lib/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ class _MimirAppState extends ConsumerState<MimirApp> {
if (UniversalPlatform.isIOS || UniversalPlatform.isAndroid) {
// Listen to media sharing coming from outside the app while the app is in the memory.
intentSub = ReceiveSharingIntent.instance.getMediaStream().listen((list) async {
ref.read($intentFiles.notifier).state = [
ref
.read($intentFiles.notifier)
.state = [
...ref.read($intentFiles),
...list,
];
Expand All @@ -84,7 +86,9 @@ class _MimirAppState extends ConsumerState<MimirApp> {

// Get the media sharing coming from outside the app while the app is closed.
ReceiveSharingIntent.instance.getInitialMedia().then((list) async {
ref.read($intentFiles.notifier).state = [
ref
.read($intentFiles.notifier)
.state = [
...ref.read($intentFiles),
...list,
];
Expand Down Expand Up @@ -136,9 +140,9 @@ class _MimirAppState extends ConsumerState<MimirApp> {
colorScheme: themeColor == null
? null
: ColorScheme.fromSeed(
seedColor: themeColor,
brightness: origin.brightness,
),
seedColor: themeColor,
brightness: origin.brightness,
),
visualDensity: VisualDensity.comfortable,
splashFactory: kIsWeb ? null : InkSparkle.splashFactory,
navigationBarTheme: const NavigationBarThemeData(
Expand Down Expand Up @@ -170,10 +174,11 @@ class _MimirAppState extends ConsumerState<MimirApp> {
themeMode: ref.watch(Settings.theme.$themeMode),
theme: bakeTheme(ThemeData.light()),
darkTheme: bakeTheme(ThemeData.dark()),
builder: (ctx, child) => _PostServiceRunner(
key: const ValueKey("Post service runner"),
child: child ?? const SizedBox.shrink(),
),
builder: (ctx, child) =>
_PostServiceRunner(
key: const ValueKey("Post service runner"),
child: child ?? const SizedBox.shrink(),
),
scrollBehavior: const MaterialScrollBehavior().copyWith(
dragDevices: {
PointerDeviceKind.mouse,
Expand All @@ -187,7 +192,9 @@ class _MimirAppState extends ConsumerState<MimirApp> {
}

Future<void> handleUriLink(Uri uri) async {
ref.read($appLinks.notifier).state = [...ref.read($appLinks), (uri: uri, ts: DateTime.now())];
ref
.read($appLinks.notifier)
.state = [...ref.read($appLinks), (uri: uri, ts: DateTime.now())];
final navigateCtx = $key.currentContext;
if (navigateCtx == null) return;
if (!kIsWeb) {
Expand Down Expand Up @@ -253,7 +260,7 @@ class _PostServiceRunnerState extends ConsumerState<_PostServiceRunner> {
initQuickActions();
}
WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
if (Admin.isAvailable()) {
if (kDebugMode && Admin.isAvailable()) {
final admin = Admin(ObjectBoxInit.store);
ObjectBoxInit.objectBoxAdmin = admin;
debugPrint("ObjectBox Admin running at port ${admin.port}.");
Expand Down
2 changes: 1 addition & 1 deletion lib/settings/page/developer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class _DeveloperOptionsPageState extends ConsumerState<DeveloperOptionsPage> {
context.go("/");
},
),
if (Admin.isAvailable() && objectboxAdmin != null && !objectboxAdmin.isClosed())
if (kDebugMode && Admin.isAvailable() && objectboxAdmin != null && !objectboxAdmin.isClosed())
ListTile(
title: "Open Objectbox Admin".text(),
subtitle: "http://localhost:${objectboxAdmin.port}/index.html".text(),
Expand Down

0 comments on commit 598fc8b

Please sign in to comment.