Skip to content

Commit

Permalink
Fix objectbox error when opening redacted mode panel. Fix contacts re…
Browse files Browse the repository at this point in the history
…lated errors on desktop. Remove unnecessary files.

Signed-off-by: Joel Jothiprakasam <[email protected]>
  • Loading branch information
jjoelj committed Feb 26, 2022
1 parent 0158b12 commit dad4664
Show file tree
Hide file tree
Showing 24 changed files with 394 additions and 1,560 deletions.
5 changes: 1 addition & 4 deletions lib/layouts/settings/redacted_mode_panel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'dart:math';

import 'package:bluebubbles/helpers/constants.dart';
import 'package:bluebubbles/helpers/hex_color.dart';
import 'package:bluebubbles/helpers/logger.dart';
import 'package:bluebubbles/helpers/themes.dart';
import 'package:bluebubbles/layouts/settings/settings_widgets.dart';
import 'package:bluebubbles/layouts/widgets/message_widget/message_widget.dart';
Expand Down Expand Up @@ -122,10 +123,6 @@ class RedactedModePanel extends StatelessWidget {
children: [
SettingsSwitch(
onChanged: (bool val) {
if (val) {
ContactManager().loadFakeInfo();
}

SettingsManager().settings.redactedMode.value = val;
saveSettings();
},
Expand Down
649 changes: 329 additions & 320 deletions lib/layouts/widgets/message_widget/received_message.dart

Large diffs are not rendered by default.

41 changes: 28 additions & 13 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -181,27 +181,41 @@ Future<Null> initApp(bool isBubble) async {
store = Store.fromReference(getObjectBoxModel(), base64.decode(storeRef).buffer.asByteData());
} catch (_) {
Logger.info("Failed to open store from reference, opening from path");
store = await openStore(directory: join(documentsDirectory.path, 'objectbox'));
if (Platform.isWindows) {
if (!Directory(join(documentsDirectory.path, 'objectbox')).existsSync()) {
Logger.info("Failed to open store from default path. Using custom path");
customStorePath ??= "C:\\bluebubbles_app";
prefs.setBool("use-custom-path", true);
objectBoxDirectory = Directory(join(customStorePath, "objectbox"));
Logger.info("Opening ObjectBox store from custom path: ${objectBoxDirectory.path}");
store = await openStore(directory: join(customStorePath, 'objectbox'));
} else {
Logger.info("Objectbox directory exists.");
try {
if (kIsDesktop) {
Directory(join(documentsDirectory.path, 'objectbox')).createSync(recursive: true);
}
store = await openStore(directory: join(documentsDirectory.path, 'objectbox'));
} catch (_) {
if (Platform.isWindows) {
if (!Directory(join(documentsDirectory.path, 'objectbox')).existsSync()) {
Logger.info("Failed to open store from default path. Using custom path");
customStorePath ??= "C:\\bluebubbles_app";
prefs.setBool("use-custom-path", true);
objectBoxDirectory = Directory(join(customStorePath, "objectbox"));
Logger.info("Opening ObjectBox store from custom path: ${objectBoxDirectory.path}");
store = await openStore(directory: join(customStorePath, 'objectbox'));
} else {
Logger.info("Objectbox directory exists.");
}
}

// TODO Linux fallback
}
}
} else if (useCustomPath == true && Platform.isWindows) {
customStorePath ??= "C:\\bluebubbles_app";
objectBoxDirectory = Directory(join(customStorePath, "objectbox"));
if (kIsDesktop) {
objectBoxDirectory.createSync(recursive: true);
}
Logger.info("Opening ObjectBox store from custom path: ${join(customStorePath, 'objectbox')}");
store = await openStore(directory: join(customStorePath, 'objectbox'));
store = await openStore(directory: join(customStorePath, "objectbox"));
} else {
try {
if (kIsDesktop) {
Directory(join(documentsDirectory.path, 'objectbox')).createSync(recursive: true);
}
Logger.info("Opening ObjectBox store from path: ${join(documentsDirectory.path, 'objectbox')}");
store = await openStore(directory: join(documentsDirectory.path, 'objectbox'));
} catch (_) {
Expand All @@ -217,6 +231,7 @@ Future<Null> initApp(bool isBubble) async {
Logger.info("Objectbox directory exists.");
}
}
// TODO Linux fallback
}
}
attachmentBox = store.box<Attachment>();
Expand Down Expand Up @@ -314,7 +329,7 @@ Future<Null> initApp(bool isBubble) async {
// it doesn't matter if this errors
try {
tz.setLocalLocation(tz.getLocation(await FlutterNativeTimezone.getLocalTimezone()));
} catch(_) {}
} catch (_) {}
if (!await GoogleMlKit.nlp.entityModelManager().isModelDownloaded(EntityExtractorOptions.ENGLISH)) {
GoogleMlKit.nlp.entityModelManager().downloadModel(EntityExtractorOptions.ENGLISH, isWifiRequired: false);
}
Expand Down
38 changes: 27 additions & 11 deletions lib/managers/background_isolate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,27 +52,41 @@ callbackHandler() async {
store = Store.fromReference(getObjectBoxModel(), base64.decode(storeRef).buffer.asByteData());
} catch (_) {
debugPrint("Failed to open store from reference, opening from path");
store = await openStore(directory: join(documentsDirectory.path, 'objectbox'));
if (Platform.isWindows) {
if (!Directory(join(documentsDirectory.path, 'objectbox')).existsSync()) {
debugPrint("Failed to open store from default path. Using custom path");
customStorePath ??= "C:\\bluebubbles_app";
prefs.setBool("use-custom-path", true);
objectBoxDirectory = Directory(join(customStorePath, "objectbox"));
debugPrint("Opening ObjectBox store from custom path: ${objectBoxDirectory.path}");
store = await openStore(directory: join(customStorePath, 'objectbox'));
} else {
debugPrint("Objectbox directory exists.");
try {
if (kIsDesktop) {
Directory(join(documentsDirectory.path, 'objectbox')).createSync(recursive: true);
}
store = await openStore(directory: join(documentsDirectory.path, 'objectbox'));
} catch (_) {
if (Platform.isWindows) {
if (!Directory(join(documentsDirectory.path, 'objectbox')).existsSync()) {
debugPrint("Failed to open store from default path. Using custom path");
customStorePath ??= "C:\\bluebubbles_app";
prefs.setBool("use-custom-path", true);
objectBoxDirectory = Directory(join(customStorePath, "objectbox"));
debugPrint("Opening ObjectBox store from custom path: ${objectBoxDirectory.path}");
store = await openStore(directory: join(customStorePath, 'objectbox'));
} else {
debugPrint("Objectbox directory exists.");
}
}

// TODO Linux fallback
}
}
} else if (useCustomPath == true && Platform.isWindows) {
customStorePath ??= "C:\\bluebubbles_app";
objectBoxDirectory = Directory(join(customStorePath, "objectbox"));
if (kIsDesktop) {
objectBoxDirectory.createSync(recursive: true);
}
debugPrint("Opening ObjectBox store from custom path: ${join(customStorePath, 'objectbox')}");
store = await openStore(directory: join(customStorePath, "objectbox"));
} else {
try {
if (kIsDesktop) {
Directory(join(documentsDirectory.path, 'objectbox')).createSync(recursive: true);
}
debugPrint("Opening ObjectBox store from path: ${join(documentsDirectory.path, 'objectbox')}");
store = await openStore(directory: join(documentsDirectory.path, 'objectbox'));
} catch (_) {
Expand All @@ -88,6 +102,8 @@ callbackHandler() async {
debugPrint("Objectbox directory exists.");
}
}

// TODO Linux fallback
}
}
prefs.setString("objectbox-reference", base64.encode(store.reference.buffer.asUint8List()));
Expand Down
2 changes: 2 additions & 0 deletions lib/managers/contact_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ class ContactManager {
}

Future<void> getAvatarsForChat(Chat chat) async {
if (kIsDesktop || kIsWeb) return;
if (chat.participants.isEmpty) {
chat.getParticipants();
}
Expand All @@ -311,6 +312,7 @@ class ContactManager {

/// Fetch a contact's avatar, first trying the full size image, then the thumbnail if unavailable
Future<void> loadContactAvatar(Contact contact) async {
if (kIsDesktop || kIsWeb) return;
try {
contact.avatar.value ??= await FastContacts.getContactImage(contact.id, size: ContactImageSize.fullSize);
} catch (_) {
Expand Down
1 change: 1 addition & 0 deletions lib/repository/models/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:bluebubbles/helpers/constants.dart';
import 'package:bluebubbles/helpers/reaction.dart';
import 'package:bluebubbles/helpers/utils.dart';
import 'package:bluebubbles/main.dart';
import 'package:bluebubbles/managers/contact_manager.dart';
import 'package:bluebubbles/managers/settings_manager.dart';
import 'package:bluebubbles/repository/models/config_entry.dart';
import 'package:flutter/foundation.dart';
Expand Down
2 changes: 1 addition & 1 deletion windows/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.15)
cmake_minimum_required(VERSION 3.14)
project(bluebubbles_app LANGUAGES CXX)

set(BINARY_NAME "bluebubbles_app")
Expand Down
2 changes: 1 addition & 1 deletion windows/flutter/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.15)
cmake_minimum_required(VERSION 3.14)

set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral")

Expand Down

This file was deleted.

Loading

0 comments on commit dad4664

Please sign in to comment.