diff --git a/lib/backend/storage.dart b/lib/backend/storage.dart new file mode 100644 index 0000000..d12a0e9 --- /dev/null +++ b/lib/backend/storage.dart @@ -0,0 +1,38 @@ +import 'package:localstore/localstore.dart'; +import './resolve_url.dart'; + +class LoginDetails { + const LoginDetails( + {required this.username, required this.password, required this.server}); + + final String username; + final String password; + final OutbagServer server; + + void toDisk() async { + final db = Localstore.instance; + await db + .collection('meta') + .doc('auth') + .set({'username': username, 'password': password}); + server.toDisk(); + } + + static Future fromDisk() async { + final db = Localstore.instance; + final data = await db.collection('meta').doc('auth').get(); + final server = await OutbagServer.fromDisk(); + + return LoginDetails( + username: data?['username'], + password: data?['password'], + server: server, + ); + } +} + +// obtain room list +Future?> getRooms() async { + final db = Localstore.instance; + return await db.collection('rooms').get(); +}