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

preliminary targeted conditional solution #2528

Merged
merged 12 commits into from
Nov 6, 2024
1 change: 0 additions & 1 deletion apps/gi-frontend/src/app/teams/[teamId]/TalentContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,6 @@ function SkillDisplayCard({
document={doc}
collapse
// hideHeader={hideHeader}
setConditional={() => {}} // TODO: frzyc setConditional
/>
))}
</CardContent>
Expand Down
3 changes: 2 additions & 1 deletion libs/common/database/src/lib/DataManagerBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export class DataManagerBase<
key: CacheKey,
valueOrFunc:
| Partial<StorageValue>
| ((v: StorageValue) => Partial<StorageValue> | void),
| ((v: StorageValue) => Partial<StorageValue> | void | false),
notify = true
): boolean {
const old = this.getStorage(key)
Expand All @@ -85,6 +85,7 @@ export class DataManagerBase<
}
const value =
typeof valueOrFunc === 'function' ? valueOrFunc(old) ?? old : valueOrFunc
if (value === false) return false
const validated = this.validate({ ...(old ?? {}), ...value }, key)
if (!validated) {
this.trigger(key, 'invalid', value)
Expand Down
17 changes: 17 additions & 0 deletions libs/common/util/src/lib/array.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,20 @@ export function pruneOrPadArray<T>(array: T[], length: number, value: T) {
else array.push(...new Array(length - array.length).fill(value))
return array
}

/**
* Move an element in the array to the front, if it exists.
* @param arr
* @param key
* @returns
*/
export function moveToFront<T>(arr: T[], key: T): T[] {
const index = arr.indexOf(key)
if (index > -1) {
// Remove the element from its current position
const [element] = arr.splice(index, 1)
// Add the element to the front of the array
arr.unshift(element)
}
return arr
}
frzyc marked this conversation as resolved.
Show resolved Hide resolved
Loading
Loading