Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: issue detail refactor #6768

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
chore: added generator for swr key
  • Loading branch information
vamsikrishnamathala committed Mar 24, 2025
commit a62269772ad157f878e8a2838cccd19e2ca83bbb
1 change: 1 addition & 0 deletions packages/constants/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ export * from "./event-tracker";
export * from "./spreadsheet";
export * from "./dashboard";
export * from "./page";
export * from "./swr-keys";
1 change: 1 addition & 0 deletions packages/constants/src/swr-keys.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export enum SWR_KEYS {}
15 changes: 14 additions & 1 deletion packages/utils/src/common.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { clsx, type ClassValue } from "clsx";
import { twMerge } from "tailwind-merge";

import { SWR_KEYS } from "@plane/constants";
// Support email can be configured by the application
export const getSupportEmail = (defaultEmail: string = ""): string => defaultEmail;

Expand Down Expand Up @@ -39,3 +39,16 @@ export const partitionValidIds = (ids: string[], validIds: string[]): { valid: s

return { valid, invalid };
};

/**
* Generates a unique key for SWR cache
* @param workspaceSlug - The slug of the workspace
* @param label - The label for the cache key
* @param params - The parameters for the cache key
* @returns The unique key in array format
*/
export const getSwrKey = (workspaceSlug: string, label: SWR_KEYS, params: string[] = []) => [
label,
workspaceSlug,
...params,
];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Well-documented utility function, but consider enum values.

The getSwrKey function is well-documented with JSDoc comments and has a clear purpose. However, according to the summary, the SWR_KEYS enum is currently empty. This could lead to inconsistent key usage if developers create their own string literals instead of using predefined enum values.


🏁 Script executed:

#!/bin/bash
# Check if the SWR_KEYS enum has any values defined

echo "Checking content of SWR_KEYS enum:"
fd -e ts -e tsx "swr-keys.ts" --exec cat {} \;

Length of output: 152


Please update the SWR_KEYS enum values.

The getSwrKey utility function is well-documented and clear. However, the verification confirms that the SWR_KEYS enum remains empty (in swr-keys.ts), which risks inconsistent cache key usage if developers start using arbitrary string literals. I suggest either:

  • Defining preset values: Populate the enum with the intended cache keys to ensure consistency.
  • Documenting intentional emptiness: If the enum is intentionally left empty for future expansion, add a clear comment explaining this decision.