Add function to get username
							parent
							
								
									54f99f0f05
								
							
						
					
					
						commit
						bc2d1a183b
					
				| 
						 | 
				
			
			@ -76,6 +76,11 @@ fromBaseUrl url =
 | 
			
		|||
        , vs = Nothing
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
{-| Get the user id registered by the `Credentials` type.
 | 
			
		||||
-}
 | 
			
		||||
getUserId : Credentials -> Maybe String
 | 
			
		||||
getUserId (Credentials { access }) =
 | 
			
		||||
    Login.getUserId access
 | 
			
		||||
 | 
			
		||||
{-| Retrieves the spec versions from a given `Credentials` value.
 | 
			
		||||
-}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -56,6 +56,20 @@ getToken t =
 | 
			
		|||
        UsernameAndPassword { token } ->
 | 
			
		||||
            token
 | 
			
		||||
 | 
			
		||||
getUserId : AccessToken -> Maybe String
 | 
			
		||||
getUserId t =
 | 
			
		||||
    case t of
 | 
			
		||||
        NoAccess ->
 | 
			
		||||
            Nothing
 | 
			
		||||
        
 | 
			
		||||
        RawAccessToken _ ->
 | 
			
		||||
            Nothing
 | 
			
		||||
        
 | 
			
		||||
        DetailedAccessToken { userId } ->
 | 
			
		||||
            Just userId
 | 
			
		||||
        
 | 
			
		||||
        UsernameAndPassword { userId } ->
 | 
			
		||||
            userId
 | 
			
		||||
 | 
			
		||||
addToken : String -> AccessToken -> AccessToken
 | 
			
		||||
addToken s t =
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,7 +1,7 @@
 | 
			
		|||
module Matrix exposing
 | 
			
		||||
    ( Vault, fromLoginCredentials, fromAccessToken
 | 
			
		||||
    , sync, VaultUpdate, updateWith
 | 
			
		||||
    , getRooms, getRoomById, getInvites, accountData
 | 
			
		||||
    , getRooms, getRoomById, getInvites, accountData, username
 | 
			
		||||
    , joinRoomById, setAccountData
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -21,7 +21,7 @@ interact with the API.
 | 
			
		|||
 | 
			
		||||
# Exploring your vault
 | 
			
		||||
 | 
			
		||||
@docs getRooms, getRoomById, getInvites, accountData
 | 
			
		||||
@docs getRooms, getRoomById, getInvites, accountData, username
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# Taking action
 | 
			
		||||
| 
						 | 
				
			
			@ -133,6 +133,16 @@ accountData =
 | 
			
		|||
    Internal.Vault.accountData
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
{-| Get the username of the account that we're using.
 | 
			
		||||
 | 
			
		||||
The username is a `Maybe String` if the Vault hasn't had its first sync yet,
 | 
			
		||||
and the API might not always be consistent on the username.
 | 
			
		||||
-}
 | 
			
		||||
username : Vault -> Maybe String
 | 
			
		||||
username =
 | 
			
		||||
    Internal.Vault.getUsername
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
{-| Join a Matrix room based on its room id.
 | 
			
		||||
-}
 | 
			
		||||
joinRoomById : String -> Vault -> Task X.Error VaultUpdate
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue