(displayName = null, isRefresh = false, {priority = FOREGROUND_PRIORITY} = {})
| 183 | * @returns {Promise<object>} - A promise resolving to metadata with Avatar and latestYear |
| 184 | */ |
| 185 | export async function getMetadata(displayName = null, isRefresh = false, {priority = FOREGROUND_PRIORITY} = {}) { |
| 186 | /* |
| 187 | * Get the user metadata from the server or local storage |
| 188 | * @param isRefresh [Boolean]: whether to refresh the data |
| 189 | * @return: metadata |
| 190 | */ |
| 191 | if (!displayName) { |
| 192 | displayName = await getDisplayName(isRefresh, {priority}); |
| 193 | } |
| 194 | if (!displayName) { |
| 195 | return null; |
| 196 | } |
| 197 | const metadata = await getMetadataBatch([displayName], isRefresh, {priority}); |
| 198 | return metadata[displayName] ?? metadataWithLatestYear({}); |
| 199 | } |
| 200 | |
| 201 | export async function getMetadataBatch(displayNames, isRefresh = false, {priority = FOREGROUND_PRIORITY} = {}) { |
| 202 | const uniqueDisplayNames = [...new Set(displayNames)].filter(Boolean); |
no test coverage detected