Fixed infinite-loading-new-entry bug.
This commit is contained in:
parent
2195a5324c
commit
9824429703
@ -81,7 +81,7 @@ class DatabaseAPI extends ChangeNotifier {
|
||||
var referenceDate = DateTime.parse("2023-01-01");
|
||||
|
||||
final date = DateTime.parse(dateISO);
|
||||
return date.difference(referenceDate).inDays;
|
||||
return date.difference(referenceDate).inDays + 1;
|
||||
}
|
||||
|
||||
getAll() async {
|
||||
@ -109,18 +109,22 @@ class DatabaseAPI extends ChangeNotifier {
|
||||
}
|
||||
|
||||
getOne({required String date}) async {
|
||||
try {
|
||||
// print(date);
|
||||
// print(_entries.last.$id);
|
||||
return _entries.singleWhere((element) => element.$id == date);
|
||||
} catch (e) {
|
||||
int offset =
|
||||
DateTime.parse(date).difference(DateTime.parse("2023-01-01")).inDays;
|
||||
DateTime.parse(date).difference(DateTime.parse("2023-01-01")).inDays +
|
||||
1;
|
||||
|
||||
List<Document> response = await getEntries(
|
||||
limit: 1,
|
||||
paginationQuery: Query.offset(offset),
|
||||
);
|
||||
|
||||
_entries.add(response.first);
|
||||
|
||||
notifyListeners();
|
||||
return response.first;
|
||||
}
|
||||
}
|
||||
|
||||
getEntries({int limit = 100, paginationQuery}) async {
|
||||
|
||||
@ -209,6 +209,7 @@ class _DayViewState extends State<DayView> {
|
||||
Expanded(
|
||||
child: TextFormField(
|
||||
decoration: InputDecoration(hintText: "Comments"),
|
||||
textCapitalization: TextCapitalization.sentences,
|
||||
smartQuotesType: SmartQuotesType.enabled,
|
||||
enableInteractiveSelection: true,
|
||||
controller: commentsController,
|
||||
@ -293,7 +294,7 @@ class _HourGeneratorState extends State<HourGenerator> {
|
||||
double height = double.parse((e['num'] * 36).toString());
|
||||
return Consumer<CategoriesAPI>(
|
||||
builder: (context, categories, child) {
|
||||
Category category = categories.lookUp(e['val'].toString());
|
||||
dynamic category = categories.lookUp(e['val'].toString());
|
||||
return SizedBox(
|
||||
height: height,
|
||||
child: GestureDetector(
|
||||
|
||||
Loading…
Reference in New Issue
Block a user