Skip to content
Open
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
ce9de77
remove totalAsk and proposalsCount from campaign model
damian-molinski Nov 13, 2025
0f35e10
proposalsCount -> finalProposalsCount
damian-molinski Nov 13, 2025
08d8c92
CampaignCategoryViewModel.id -> CampaignCategoryViewModel.ref
damian-molinski Nov 13, 2025
d382119
little DiscoveryCubit state build cleanup
damian-molinski Nov 13, 2025
83cf26f
watch campaign total ask in discovery
damian-molinski Nov 13, 2025
d926bd6
smaller voting category model
damian-molinski Nov 13, 2025
40259f7
new proposal campaign
damian-molinski Nov 14, 2025
14806ee
safe check
damian-molinski Nov 14, 2025
5bc064d
proposal builder category total ask
damian-molinski Nov 14, 2025
6e69435
chore: missing TODO
damian-molinski Nov 14, 2025
d2d0c39
category details
damian-molinski Nov 14, 2025
06ae095
watch proposals template total ask
damian-molinski Nov 17, 2025
5f4d8ed
finish integration of total_ask
damian-molinski Nov 18, 2025
69946f8
close
damian-molinski Nov 18, 2025
bb50abd
remove print and add TODO
damian-molinski Nov 18, 2025
d977e5c
documents getLatestOf
damian-molinski Nov 18, 2025
e55433f
remove old tables and daos
damian-molinski Nov 18, 2025
520a432
deleteWhere tests
damian-molinski Nov 18, 2025
16090d5
remove old pagination and count methods
damian-molinski Nov 18, 2025
5578eb0
local draft documents dao
damian-molinski Nov 18, 2025
9fb6875
Merge branch 'feat/database_optimization_3528' into feat/campaign_tot…
damian-molinski Nov 19, 2025
c3f69fd
Merge branch 'feat/campaign_total_ask' into chore/remove_old_daos
damian-molinski Nov 19, 2025
98b19df
Merge branch 'feat/database_optimization_3528' into feat/campaign_tot…
damian-molinski Nov 19, 2025
5819aa4
categoryId -> categoryRef
damian-molinski Nov 19, 2025
673d4f1
Merge feat/campaign_total_ask into chore/remove_old_daos
damian-molinski Nov 19, 2025
21e7fdd
Merge branch 'feat/database_optimization_3528' into feat/campaign_tot…
damian-molinski Nov 20, 2025
844478b
Merge branch 'feat/campaign_total_ask' into chore/remove_old_daos
damian-molinski Nov 20, 2025
67b4241
Merge feat/database_optimization_3528 into chore/remove_old_daos
damian-molinski Nov 21, 2025
24e533a
Merge branch 'chore/remove_old_daos' of github.com:input-output-hk/ca…
damian-molinski Nov 21, 2025
3d892f0
chore: notInType -> typeNotIn
damian-molinski Nov 21, 2025
566acd6
chore: move DriftDocumentsV2LocalMetadataDao setup into group
damian-molinski Nov 21, 2025
a5e8acf
separate get and getWhere
damian-molinski Nov 21, 2025
f5e0a59
docs: documents sources interfaces documentation
damian-molinski Nov 21, 2025
ead0664
chore: methods rename
damian-molinski Nov 21, 2025
8a18485
chore: refTo -> referencing
damian-molinski Nov 21, 2025
3a6fa43
chore: typeNotIn -> excludeTypes
damian-molinski Nov 21, 2025
5bb87d0
update content
damian-molinski Nov 21, 2025
9d9356d
feat(cat-voices): smaller proposals query scope (#3747)
damian-molinski Nov 21, 2025
619baaf
Merge branch 'feat/database_optimization_3528' into chore/remove_old_…
damian-molinski Nov 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions catalyst_voices/apps/voices/lib/configs/bootstrap.dart
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ Future<void> cleanUpStorages({
Future<void> cleanUpUserDataFromDatabase() async {
final db = Dependencies.instance.get<CatalystDatabase>();

await db.draftsDao.deleteWhere();
await db.favoritesDao.deleteAll();
await db.localDocumentsV2Dao.deleteWhere();
await db.localMetadataDao.deleteWhere();
}

@visibleForTesting
Expand Down
15 changes: 8 additions & 7 deletions catalyst_voices/apps/voices/lib/dependency/dependencies.dart
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ final class Dependencies extends DependencyProvider {
get<ProposalService>(),
get<CommentService>(),
get<CampaignService>(),
get<DocumentsService>(),
get<DocumentMapper>(),
get<VotingBallotBuilder>(),
get<VotingService>(),
Expand Down Expand Up @@ -261,25 +262,25 @@ final class Dependencies extends DependencyProvider {
get<CatalystProfiler>(),
);
})
..registerLazySingleton<DocumentFavoriteSource>(() {
return DatabaseDocumentFavoriteSource(
get<CatalystDatabase>(),
);
})
..registerLazySingleton<CatGatewayDocumentDataSource>(() {
return CatGatewayDocumentDataSource(
get<ApiServices>(),
get<SignedDocumentManager>(),
);
})
..registerLazySingleton<CampaignRepository>(CampaignRepository.new)
..registerLazySingleton<CampaignRepository>(
() {
return CampaignRepository(
get<DatabaseDocumentsDataSource>(),
);
},
)
..registerLazySingleton<DocumentRepository>(() {
return DocumentRepository(
get<CatalystDatabase>(),
get<DatabaseDraftsDataSource>(),
get<DatabaseDocumentsDataSource>(),
get<CatGatewayDocumentDataSource>(),
get<DocumentFavoriteSource>(),
);
})
..registerLazySingleton<DocumentMapper>(() => const DocumentMapperImpl())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ class CardInformation extends StatelessWidget {
padding: padding,
children: [
CategoryProposalsDetailsCard(
categoryId: category.id,
categoryRef: category.ref,
categoryName: category.formattedName,
categoryProposalsCount: category.proposalsCount,
categoryFinalProposalsCount: category.finalProposalsCount,
),
const SizedBox(height: 16),
Offstage(
offstage: !isActiveProposer,
child: CreateProposalCard(
categoryId: category.id,
categoryRef: category.ref,
categoryName: category.formattedName,
categoryDos: category.dos,
categoryDonts: category.donts,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class CategoryCompactDetailView extends StatelessWidget {
_CategoryBrief(
categoryName: category.formattedName,
categoryDescription: category.description,
categoryRef: category.id,
categoryRef: category.ref,
),
FundsDetailCard(
allFunds: category.availableFunds,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ class CategoryDetailView extends StatelessWidget {
_CategoryBrief(
categoryName: category.formattedName,
categoryDescription: category.description,
categoryRef: category.id,
categoryRef: category.ref,
image: category.image,
proposalCount: category.proposalsCount,
finalProposalsCount: category.finalProposalsCount,
),
const SizedBox(height: 64),
FundsDetailCard(
Expand All @@ -59,14 +59,14 @@ class _CategoryBrief extends StatelessWidget {
final String categoryDescription;
final SignedDocumentRef categoryRef;
final SvgGenImage image;
final int proposalCount;
final int finalProposalsCount;

const _CategoryBrief({
required this.categoryName,
required this.categoryDescription,
required this.categoryRef,
required this.image,
required this.proposalCount,
required this.finalProposalsCount,
});

@override
Expand Down Expand Up @@ -98,7 +98,7 @@ class _CategoryBrief extends StatelessWidget {
categoryName: categoryName,
categoryDescription: categoryDescription,
categoryRef: categoryRef,
showViewAllButton: proposalCount > 0,
showViewAllButton: finalProposalsCount > 0,
),
),
],
Expand Down
31 changes: 16 additions & 15 deletions catalyst_voices/apps/voices/lib/pages/category/category_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import 'package:flutter/material.dart';
import 'package:skeletonizer/skeletonizer.dart';

class CategoryPage extends StatefulWidget {
final SignedDocumentRef categoryId;
final SignedDocumentRef categoryRef;

const CategoryPage({super.key, required this.categoryId});
const CategoryPage({super.key, required this.categoryRef});

@override
State<CategoryPage> createState() => _CategoryPageState();
Expand Down Expand Up @@ -106,6 +106,8 @@ class _CategoryDetailContent extends StatelessWidget {

@override
Widget build(BuildContext context) {
// TODO(damian-molinski): refactor it into single class object in category_detail_state.dart
// and do not rely on context.select<SessionCubit> here.
return BlocSelector<
CategoryDetailCubit,
CategoryDetailState,
Expand All @@ -114,7 +116,7 @@ class _CategoryDetailContent extends StatelessWidget {
selector: (state) {
return (
show: state.isLoading,
data: state.category ?? CampaignCategoryDetailsViewModel.placeholder(),
data: state.selectedCategoryDetails ?? CampaignCategoryDetailsViewModel.placeholder(),
);
},
builder: (context, state) {
Expand All @@ -139,9 +141,9 @@ class _CategoryDetailContent extends StatelessWidget {
}

class _CategoryDetailError extends StatelessWidget {
final SignedDocumentRef categoryId;
final SignedDocumentRef categoryRef;

const _CategoryDetailError({required this.categoryId});
const _CategoryDetailError({required this.categoryRef});

@override
Widget build(BuildContext context) {
Expand All @@ -165,7 +167,7 @@ class _CategoryDetailError extends StatelessWidget {
? null
: () {
unawaited(
context.read<CategoryDetailCubit>().getCategoryDetail(categoryId),
context.read<CategoryDetailCubit>().getCategoryDetail(categoryRef),
);
},
),
Expand All @@ -187,7 +189,7 @@ class _CategoryPageState extends State<CategoryPage> {
children: [
const _CategoryDetailContent(),
_CategoryDetailError(
categoryId: widget.categoryId,
categoryRef: widget.categoryRef,
),
].constrainedDelegate(),
),
Expand All @@ -198,9 +200,9 @@ class _CategoryPageState extends State<CategoryPage> {
void didUpdateWidget(CategoryPage oldWidget) {
super.didUpdateWidget(oldWidget);

if (widget.categoryId != oldWidget.categoryId) {
if (widget.categoryRef != oldWidget.categoryRef) {
unawaited(
context.read<CategoryDetailCubit>().getCategoryDetail(widget.categoryId),
context.read<CategoryDetailCubit>().getCategoryDetail(widget.categoryRef),
);
}
}
Expand All @@ -215,17 +217,16 @@ class _CategoryPageState extends State<CategoryPage> {
@override
void initState() {
super.initState();
unawaited(context.read<CategoryDetailCubit>().getCategories());
unawaited(
context.read<CategoryDetailCubit>().getCategoryDetail(widget.categoryId),
);
_listenForProposalRef(context.read<CategoryDetailCubit>());
final cubit = context.read<CategoryDetailCubit>()..watchActiveCampaignCategories();
unawaited(cubit.getCategoryDetail(widget.categoryRef));
_listenForProposalRef(cubit);
}

// TODO(damian-molinski): refactor it to signal pattern
void _listenForProposalRef(CategoryDetailCubit cubit) {
// listen for updates
_categoryRefSub = cubit.stream
.map((event) => event.category?.id)
.map((event) => event.selectedCategoryRef)
.distinct()
.listen(_onCategoryRefChanged);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,20 @@ class ChangeCategoryButton extends StatelessWidget {

@override
Widget build(BuildContext context) {
return BlocSelector<
CategoryDetailCubit,
CategoryDetailState,
List<DropdownMenuViewModel<ProposalsCategoryFilter>>
>(
selector: (state) {
final selectedCategory = state.category?.id ?? '';
return state.categories
.map(
(e) => DropdownMenuViewModel(
value: ProposalsRefCategoryFilter(ref: e.id),
name: e.formattedName,
isSelected: e.id == selectedCategory,
),
)
.toList();
},
return BlocSelector<CategoryDetailCubit, CategoryDetailState, CategoryDetailStatePicker>(
selector: (state) => state.picker,
builder: (context, state) {
return CampaignCategoryPicker(
onSelected: (value) => unawaited(_changeCategory(context, value)),
items: state,
items: state.items.map(
(item) {
return DropdownMenuViewModel(
value: ProposalsRefCategoryFilter(ref: item.ref),
name: item.name,
isSelected: item.isSelected,
);
},
).toList(),
buttonBuilder:
(
context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class CampaignCategories extends StatelessWidget {
.map(
(e) => Skeletonizer(
enabled: isLoading,
child: CampaignCategoryCard(key: ValueKey(e.id), category: e),
child: CampaignCategoryCard(key: ValueKey(e.ref), category: e),
),
)
.toList(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class _CategoryVotingAppbar extends StatelessWidget {
@override
Widget build(BuildContext context) {
return BlocSelector<VotingCubit, VotingState, bool>(
selector: (state) => state.selectedCategory != null,
selector: (state) => state.hasSelectedCategory,
builder: (context, hasCategory) {
return _VotingAppbar(
showLeading: isAppUnlock && hasCategory,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class VotingProposalsSubHeader extends StatelessWidget {
@override
Widget build(BuildContext context) {
return BlocSelector<VotingCubit, VotingState, bool>(
selector: (state) => state.selectedCategory != null,
selector: (state) => state.hasSelectedCategory,
builder: (context, hasCategory) {
return Text(
hasCategory ? context.l10n.categoryProposals : context.l10n.proposals,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import 'package:catalyst_voices/common/ext/build_context_ext.dart';
import 'package:catalyst_voices/pages/voting/widgets/header/voting_category_picker.dart';
import 'package:catalyst_voices_assets/catalyst_voices_assets.dart';
import 'package:catalyst_voices_blocs/catalyst_voices_blocs.dart';
import 'package:catalyst_voices_brands/catalyst_voices_brands.dart';
import 'package:catalyst_voices_localization/catalyst_voices_localization.dart';
import 'package:catalyst_voices_view_models/catalyst_voices_view_models.dart';
import 'package:flutter/material.dart';

class VotingCategoryHeader extends StatelessWidget {
final CampaignCategoryDetailsViewModel category;
final VotingHeaderCategoryData category;

const VotingCategoryHeader({
super.key,
Expand All @@ -21,7 +22,7 @@ class VotingCategoryHeader extends StatelessWidget {
child: Stack(
children: [
Positioned.fill(
child: _Background(image: category.image),
child: _Background(image: CategoryImageUrl.image(category.imageUrl)),
),
Padding(
padding: const EdgeInsets.fromLTRB(28, 32, 32, 44),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ final class CategoryDetailRoute extends GoRouteData with FadePageTransitionMixin
@override
Widget build(BuildContext context, GoRouterState state) {
return CategoryPage(
categoryId: SignedDocumentRef(id: categoryId),
categoryRef: SignedDocumentRef(id: categoryId),
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,7 @@ class CampaignTimelineState extends State<CampaignTimeline> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
widget.horizontalPadding,
...widget.timelineItems
.where((e) => !e.offstage)
.toList()
.asMap()
.entries
.map(
(entry) => CampaignTimelineCard(
timelineItem: entry.value,
),
),
...widget.timelineItems.map((e) => CampaignTimelineCard(timelineItem: e)),
widget.horizontalPadding,
],
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class CampaignCategoryCard extends StatelessWidget {
const SizedBox(height: 16),
_CampaignStats(
availableFunds: category.availableFundsText,
proposalsCount: category.proposalsCount,
finalProposalsCount: category.finalProposalsCount,
),
const SizedBox(height: 16),
Flexible(
Expand All @@ -61,7 +61,7 @@ class CampaignCategoryCard extends StatelessWidget {
),
),
_Buttons(
categoryRef: category.id,
categoryRef: category.ref,
),
],
),
Expand Down Expand Up @@ -162,11 +162,11 @@ class _Buttons extends StatelessWidget {

class _CampaignStats extends StatelessWidget {
final String availableFunds;
final int proposalsCount;
final int finalProposalsCount;

const _CampaignStats({
required this.availableFunds,
required this.proposalsCount,
required this.finalProposalsCount,
});

@override
Expand Down Expand Up @@ -202,7 +202,7 @@ class _CampaignStats extends StatelessWidget {
_TextStats(
key: const Key('ProposalsCount'),
text: context.l10n.proposals,
value: proposalsCount.toString(),
value: finalProposalsCount.toString(),
),
],
),
Expand Down
Loading