mirror of
https://github.com/ente-io/ente.git
synced 2025-08-08 07:28:26 +00:00
[auth] Fix case when all codes are trashed
This commit is contained in:
parent
0275d08e27
commit
b5f8964dc4
@ -1,5 +1,6 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:app_links/app_links.dart';
|
import 'package:app_links/app_links.dart';
|
||||||
import 'package:collection/collection.dart';
|
import 'package:collection/collection.dart';
|
||||||
@ -76,6 +77,7 @@ class _HomePageState extends State<HomePage> {
|
|||||||
String selectedTag = "";
|
String selectedTag = "";
|
||||||
bool _isTrashOpen = false;
|
bool _isTrashOpen = false;
|
||||||
bool hasTrashedCodes = false;
|
bool hasTrashedCodes = false;
|
||||||
|
bool hasNonTrashedCodes = false;
|
||||||
bool isCompactMode = false;
|
bool isCompactMode = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -107,15 +109,23 @@ class _HomePageState extends State<HomePage> {
|
|||||||
CodeStore.instance.getAllCodes().then((codes) {
|
CodeStore.instance.getAllCodes().then((codes) {
|
||||||
_allCodes = codes;
|
_allCodes = codes;
|
||||||
hasTrashedCodes = false;
|
hasTrashedCodes = false;
|
||||||
|
hasNonTrashedCodes = false;
|
||||||
for (final c in _allCodes ?? []) {
|
for (final c in _allCodes ?? []) {
|
||||||
if (c.isTrashed) {
|
if (c.isTrashed) {
|
||||||
hasTrashedCodes = true;
|
hasTrashedCodes = true;
|
||||||
|
} else {
|
||||||
|
hasNonTrashedCodes = true;
|
||||||
|
}
|
||||||
|
if (hasNonTrashedCodes && hasTrashedCodes) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!hasTrashedCodes) {
|
if (!hasTrashedCodes) {
|
||||||
_isTrashOpen = false;
|
_isTrashOpen = false;
|
||||||
}
|
}
|
||||||
|
if (!hasNonTrashedCodes && hasTrashedCodes) {
|
||||||
|
_isTrashOpen = true;
|
||||||
|
}
|
||||||
|
|
||||||
CodeDisplayStore.instance.getAllTags(allCodes: _allCodes).then((value) {
|
CodeDisplayStore.instance.getAllTags(allCodes: _allCodes).then((value) {
|
||||||
tags = value;
|
tags = value;
|
||||||
@ -362,7 +372,8 @@ class _HomePageState extends State<HomePage> {
|
|||||||
final anyCodeHasError =
|
final anyCodeHasError =
|
||||||
_allCodes?.firstWhereOrNull((element) => element.hasError) != null;
|
_allCodes?.firstWhereOrNull((element) => element.hasError) != null;
|
||||||
final indexOffset = anyCodeHasError ? 1 : 0;
|
final indexOffset = anyCodeHasError ? 1 : 0;
|
||||||
final itemCount = tags.length + 1 + (hasTrashedCodes ? 1 : 0);
|
final itemCount = (hasNonTrashedCodes ? tags.length + 1 : 0) +
|
||||||
|
(hasTrashedCodes ? 1 : 0);
|
||||||
|
|
||||||
final list = Column(
|
final list = Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
@ -378,7 +389,7 @@ class _HomePageState extends State<HomePage> {
|
|||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
itemCount: itemCount,
|
itemCount: itemCount,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
if (index == 0) {
|
if (index == 0 && hasNonTrashedCodes) {
|
||||||
return TagChip(
|
return TagChip(
|
||||||
label: "All",
|
label: "All",
|
||||||
state: selectedTag == "" && _isTrashOpen == false
|
state: selectedTag == "" && _isTrashOpen == false
|
||||||
|
Loading…
x
Reference in New Issue
Block a user