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