()
| 61 | entityId.split("~")[0] as WebId; |
| 62 | |
| 63 | export const getUser = (): Promise<LocalStorage["user"] | null> => { |
| 64 | return queryGraphQlApi<MeQuery, MeQueryVariables>(meQuery) |
| 65 | .then(async ({ data }) => { |
| 66 | const subgraph = mapGqlSubgraphFieldsFragmentToSubgraph< |
| 67 | EntityRootType<HashEntity> |
| 68 | >(data.me.subgraph); |
| 69 | |
| 70 | const user = getRoots(subgraph)[0]!; |
| 71 | |
| 72 | const simpleProperties = simplifyProperties( |
| 73 | user.properties as UserProperties, |
| 74 | ); |
| 75 | |
| 76 | const { email, shortname, displayName } = simpleProperties; |
| 77 | |
| 78 | if (!shortname || !displayName) { |
| 79 | // User has not completed signup |
| 80 | return null; |
| 81 | } |
| 82 | |
| 83 | const userAvatar = getAvatarForEntity( |
| 84 | subgraph, |
| 85 | user.metadata.recordId.entityId, |
| 86 | ); |
| 87 | |
| 88 | const orgLinksAndEntities = getOutgoingLinkAndTargetEntities( |
| 89 | subgraph, |
| 90 | user.metadata.recordId.entityId, |
| 91 | ).filter(({ linkEntity }) => |
| 92 | linkEntity[0]?.metadata.entityTypeIds.includes( |
| 93 | systemLinkEntityTypes.isMemberOf.linkEntityTypeId, |
| 94 | ), |
| 95 | ); |
| 96 | |
| 97 | const userBrowserPreferences = getOutgoingLinkAndTargetEntities( |
| 98 | subgraph, |
| 99 | user.metadata.recordId.entityId, |
| 100 | ).filter( |
| 101 | ({ linkEntity, rightEntity }) => |
| 102 | linkEntity[0]?.metadata.entityTypeIds.includes( |
| 103 | systemLinkEntityTypes.has.linkEntityTypeId, |
| 104 | ) && |
| 105 | rightEntity[0]?.metadata.entityTypeIds.includes( |
| 106 | systemEntityTypes.browserPluginSettings.entityTypeId, |
| 107 | ), |
| 108 | )[0]?.rightEntity[0]; |
| 109 | |
| 110 | let settingsEntityId: EntityId; |
| 111 | |
| 112 | if (userBrowserPreferences) { |
| 113 | settingsEntityId = userBrowserPreferences.metadata.recordId.entityId; |
| 114 | |
| 115 | const { |
| 116 | automaticInferenceConfiguration, |
| 117 | manualInferenceConfiguration, |
| 118 | draftNote, |
| 119 | browserPluginTab, |
| 120 | } = simplifyProperties( |
no test coverage detected