import 'dart:convert';

import 'package:cloud_firestore/cloud_firestore.dart';

class FirebaseRepository {
  static FirebaseFirestore get _firestore => FirebaseFirestore.instance;

  static ConfigModel? _lastConfig;

  static ConfigModel get appConfig {
    update();
    return _lastConfig!;
  }

  static Future<void> update() async {
    _lastConfig = await _firestore
        .collection('config')
        .get()
        .then((v) => v.docs.first)
        .then((value) => value.data())
        .then((value) => ConfigModel(value['path'] as String));
  }
}

class ConfigModel {
  final String path;

  ConfigModel(this.path);
}
