-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
volar
committed
Dec 4, 2024
1 parent
e72b7d2
commit 712f610
Showing
5 changed files
with
62 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import type { AnzuUserMinimal } from '@/types/AnzuUser' | ||
import type { DamUser } from '@/components/dam/user/DamUser' | ||
import type { IntegerId } from '@/types/common' | ||
import { defineCached } from '@/composables/system/defineCached' | ||
import { fetchDamUserListByIds } from '@/components/dam/user/userApi' | ||
import { useCommonAdminCoreDamOptions } from '@/components/dam/assetSelect/composables/commonAdminCoreDamOptions' | ||
|
||
const mapFullToMinimal = (source: DamUser): AnzuUserMinimal => { | ||
return { id: source.id, email: source.email, avatar: source.avatar, person: source.person } | ||
} | ||
|
||
const mapIdToMinimal = (id: IntegerId): AnzuUserMinimal => { | ||
return { id: id, email: '', person: { firstName: '', lastName: '', fullName: '' }, avatar: { color: '', text: '' } } | ||
} | ||
|
||
const { cache, fetch, add, addManual, has, get, isLoaded } = defineCached<IntegerId, DamUser, AnzuUserMinimal>( | ||
mapFullToMinimal, | ||
mapIdToMinimal, | ||
(ids: IntegerId[]) => { | ||
const { damClient } = useCommonAdminCoreDamOptions() | ||
return fetchDamUserListByIds(damClient, ids) | ||
} | ||
) | ||
|
||
export const useDamCachedUsers = () => { | ||
return { | ||
addManualToCachedUsers: addManual, | ||
addToCachedUsers: add, | ||
fetchCachedUsers: fetch, | ||
cachedUsers: cache, | ||
hasCachedUser: has, | ||
getCachedUser: get, | ||
isLoadedCachedUser: isLoaded, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters