Skip to content
Snippets Groups Projects
Commit 5ebb2af7 authored by vjrj's avatar vjrj
Browse files

Support for Android in contact cache

parent 535b7d27
No related branches found
No related tags found
No related merge requests found
import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'package:flutter/foundation.dart';
import 'package:hive/hive.dart';
import 'package:path_provider/path_provider.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
import '../data/models/contact.dart';
......@@ -20,7 +22,13 @@ class ContactsCache {
Box<dynamic>? _box;
Future<void> init() async {
_box = await Hive.openBox(_boxName);
if (kIsWeb) {
_box = await Hive.openBox(_boxName);
} else {
final Directory appDocDir = await getApplicationDocumentsDirectory();
final String appDocPath = appDocDir.path;
_box = await Hive.openBox(_boxName, path: appDocPath);
}
}
Future<void> dispose() async {
......@@ -91,6 +99,8 @@ class ContactsCache {
}
}
Future<void> saveContact(Contact contact) async => addContact(contact);
Future<void> addContact(Contact contact) async {
// Get the cached version of the contact, if it exists
Contact? cachedContact = await _retrieveContact(contact.pubKey);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment