From a51fd90659d2c7f3c691dd7e4d7d7e905759caad Mon Sep 17 00:00:00 2001 From: Trent Larson Date: Fri, 26 Sep 2025 20:13:18 -0600 Subject: [PATCH] feat: add starred project list in search, refactor variable names --- src/db-sql/migration.ts | 6 +- src/db/databaseUtil.ts | 9 +- src/db/tables/settings.ts | 15 +-- src/interfaces/records.ts | 5 +- src/libs/endorserServer.ts | 10 +- src/test/PlatformServiceMixinTest.vue | 7 +- src/utils/PlatformServiceMixin.ts | 14 +-- src/views/DiscoverView.vue | 128 +++++++++++++------------- src/views/HomeView.vue | 18 ++-- src/views/NewActivityView.vue | 26 +++--- src/views/ProjectViewView.vue | 45 ++++----- 11 files changed, 140 insertions(+), 143 deletions(-) diff --git a/src/db-sql/migration.ts b/src/db-sql/migration.ts index 2e00a93d..5167fa3c 100644 --- a/src/db-sql/migration.ts +++ b/src/db-sql/migration.ts @@ -125,10 +125,10 @@ const MIGRATIONS = [ `, }, { - name: "003_add_starredProjectIds_to_settings", + name: "005_add_starredPlanHandleIds_to_settings", sql: ` - ALTER TABLE settings ADD COLUMN starredProjectIds TEXT; - ALTER TABLE settings ADD COLUMN lastAckedStarredProjectChangesJwtId TEXT; + ALTER TABLE settings ADD COLUMN starredPlanHandleIds TEXT DEFAULT '[]'; -- JSON string + ALTER TABLE settings ADD COLUMN lastAckedStarredPlanChangesJwtId TEXT; `, }, ]; diff --git a/src/db/databaseUtil.ts b/src/db/databaseUtil.ts index 458d4e88..1be1513d 100644 --- a/src/db/databaseUtil.ts +++ b/src/db/databaseUtil.ts @@ -158,7 +158,10 @@ export async function retrieveSettingsForDefaultAccount(): Promise { result.values, )[0] as Settings; settings.searchBoxes = parseJsonField(settings.searchBoxes, []); - settings.starredProjectIds = parseJsonField(settings.starredProjectIds, []); + settings.starredPlanHandleIds = parseJsonField( + settings.starredPlanHandleIds, + [], + ); return settings; } } @@ -225,8 +228,8 @@ export async function retrieveSettingsForActiveAccount(): Promise { } settings.searchBoxes = parseJsonField(settings.searchBoxes, []); - settings.starredProjectIds = parseJsonField( - settings.starredProjectIds, + settings.starredPlanHandleIds = parseJsonField( + settings.starredPlanHandleIds, [], ); diff --git a/src/db/tables/settings.ts b/src/db/tables/settings.ts index c81b6786..920fd58e 100644 --- a/src/db/tables/settings.ts +++ b/src/db/tables/settings.ts @@ -36,7 +36,7 @@ export type Settings = { lastAckedOfferToUserJwtId?: string; // the last JWT ID for offer-to-user that they've acknowledged seeing lastAckedOfferToUserProjectsJwtId?: string; // the last JWT ID for offers-to-user's-projects that they've acknowledged seeing - lastAckedStarredProjectChangesJwtId?: string; // the last JWT ID for starred project changes that they've acknowledged seeing + lastAckedStarredPlanChangesJwtId?: string; // the last JWT ID for starred plan changes that they've acknowledged seeing // The claim list has a most recent one used in notifications that's separate from the last viewed lastNotifiedClaimId?: string; @@ -62,19 +62,17 @@ export type Settings = { showGeneralAdvanced?: boolean; // Show advanced features which don't have their own flag showShortcutBvc?: boolean; // Show shortcut for Bountiful Voluntaryist Community actions - // List of starred project handleIds - starredProjectIds?: Array; - + starredPlanHandleIds?: string[]; // Array of starred plan handle IDs vapid?: string; // VAPID (Voluntary Application Server Identification) field for web push warnIfProdServer?: boolean; // Warn if using a production server warnIfTestServer?: boolean; // Warn if using a testing server webPushServer?: string; // Web Push server URL }; -// type of settings where the searchBoxes are JSON strings instead of objects +// type of settings where the values are JSON strings instead of objects export type SettingsWithJsonStrings = Settings & { searchBoxes: string; - starredProjectIds: string; + starredPlanHandleIds: string; }; export function checkIsAnyFeedFilterOn(settings: Settings): boolean { @@ -91,6 +89,11 @@ export const SettingsSchema = { /** * Constants. */ + +/** + * This is deprecated. + * It only remains for those with a PWA who have not migrated, but we'll soon remove it. + */ export const MASTER_SETTINGS_KEY = "1"; export const DEFAULT_PASSKEY_EXPIRATION_MINUTES = 15; diff --git a/src/interfaces/records.ts b/src/interfaces/records.ts index 6c2cf3cf..ca82624c 100644 --- a/src/interfaces/records.ts +++ b/src/interfaces/records.ts @@ -93,7 +93,10 @@ export interface PlanData { name: string; /** * The identifier of the project record -- different from jwtId - * (Maybe we should use the jwtId to iterate through the records instead.) + * + * This has been used to iterate through plan records, because jwtId ordering doesn't match + * chronological create ordering, though it does match most recent edit order (in reverse order). + * (It may be worthwhile to order by jwtId instead. It is an indexed field.) **/ rowId?: string; } diff --git a/src/libs/endorserServer.ts b/src/libs/endorserServer.ts index 5e4815bc..fb3d085b 100644 --- a/src/libs/endorserServer.ts +++ b/src/libs/endorserServer.ts @@ -793,18 +793,18 @@ export async function getNewOffersToUserProjects( * @param axios - axios instance * @param apiServer - endorser API server URL * @param activeDid - user's DID for authentication - * @param starredProjectIds - array of starred project handle IDs - * @param afterId - JWT ID to check for changes after (from lastAckedStarredProjectChangesJwtId) + * @param starredPlanHandleIds - array of starred project handle IDs + * @param afterId - JWT ID to check for changes after (from lastAckedStarredPlanChangesJwtId) * @returns { data: Array, hitLimit: boolean } */ export async function getStarredProjectsWithChanges( axios: Axios, apiServer: string, activeDid: string, - starredProjectIds: string[], + starredPlanHandleIds: string[], afterId?: string, ): Promise<{ data: Array; hitLimit: boolean }> { - if (!starredProjectIds || starredProjectIds.length === 0) { + if (!starredPlanHandleIds || starredPlanHandleIds.length === 0) { return { data: [], hitLimit: false }; } @@ -817,7 +817,7 @@ export async function getStarredProjectsWithChanges( const headers = await getHeaders(activeDid); const requestBody = { - planIds: starredProjectIds, + planIds: starredPlanHandleIds, afterId: afterId, }; diff --git a/src/test/PlatformServiceMixinTest.vue b/src/test/PlatformServiceMixinTest.vue index 219c72cf..98f5325c 100644 --- a/src/test/PlatformServiceMixinTest.vue +++ b/src/test/PlatformServiceMixinTest.vue @@ -85,7 +85,6 @@