Add ways to navigate through rooms
parent
a95fbbb856
commit
458ea59425
|
@ -1,7 +1,7 @@
|
||||||
module Internal.Values.Vault exposing
|
module Internal.Values.Vault exposing
|
||||||
( Vault, init
|
( Vault, init
|
||||||
, VaultUpdate(..), update
|
, VaultUpdate(..), update
|
||||||
, fromRoomId, mapRoom, updateRoom
|
, rooms, fromRoomId, mapRoom, updateRoom
|
||||||
, getAccountData, setAccountData
|
, getAccountData, setAccountData
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ To update the Vault, one uses VaultUpdate types.
|
||||||
|
|
||||||
Rooms are environments where people can have a conversation with each other.
|
Rooms are environments where people can have a conversation with each other.
|
||||||
|
|
||||||
@docs fromRoomId, mapRoom, updateRoom
|
@docs rooms, fromRoomId, mapRoom, updateRoom
|
||||||
|
|
||||||
|
|
||||||
## Account data
|
## Account data
|
||||||
|
@ -122,6 +122,13 @@ mapRoom roomId f vault =
|
||||||
{ vault | rooms = Hashdict.map roomId f vault.rooms }
|
{ vault | rooms = Hashdict.map roomId f vault.rooms }
|
||||||
|
|
||||||
|
|
||||||
|
{-| Get a list of all joined rooms present in the vault.
|
||||||
|
-}
|
||||||
|
rooms : Vault -> List Room
|
||||||
|
rooms vault =
|
||||||
|
Hashdict.values vault.rooms
|
||||||
|
|
||||||
|
|
||||||
{-| Set a piece of account data as information in the global vault data.
|
{-| Set a piece of account data as information in the global vault data.
|
||||||
-}
|
-}
|
||||||
setAccountData : String -> Json.Value -> Vault -> Vault
|
setAccountData : String -> Json.Value -> Vault -> Vault
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
module Matrix exposing
|
module Matrix exposing
|
||||||
( Vault, fromUserId, fromUsername
|
( Vault, fromUserId, fromUsername
|
||||||
, VaultUpdate, update
|
, VaultUpdate, update
|
||||||
|
, rooms, fromRoomId
|
||||||
, addAccessToken, sendMessageEvent
|
, addAccessToken, sendMessageEvent
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -27,6 +28,11 @@ support a monolithic public registry. (:
|
||||||
@docs VaultUpdate, update
|
@docs VaultUpdate, update
|
||||||
|
|
||||||
|
|
||||||
|
## Exploring the Vault
|
||||||
|
|
||||||
|
@docs rooms, fromRoomId
|
||||||
|
|
||||||
|
|
||||||
## Debugging
|
## Debugging
|
||||||
|
|
||||||
@docs addAccessToken, sendMessageEvent
|
@docs addAccessToken, sendMessageEvent
|
||||||
|
@ -66,6 +72,14 @@ addAccessToken token (Vault vault) =
|
||||||
|> Vault
|
|> Vault
|
||||||
|
|
||||||
|
|
||||||
|
{-| Get a room based on its room ID, if the user is a member of that room.
|
||||||
|
-}
|
||||||
|
fromRoomId : String -> Vault -> Maybe Types.Room
|
||||||
|
fromRoomId roomId (Vault vault) =
|
||||||
|
Envelope.mapMaybe (Internal.fromRoomId roomId) vault
|
||||||
|
|> Maybe.map Types.Room
|
||||||
|
|
||||||
|
|
||||||
{-| Use a fully-fledged Matrix ID to connect.
|
{-| Use a fully-fledged Matrix ID to connect.
|
||||||
|
|
||||||
case Matrix.fromUserId "@alice:example.org" of
|
case Matrix.fromUserId "@alice:example.org" of
|
||||||
|
@ -112,6 +126,14 @@ fromUsername { username, host, port_ } =
|
||||||
|> Vault
|
|> Vault
|
||||||
|
|
||||||
|
|
||||||
|
{-| Get a list of all the rooms that the user has joined.
|
||||||
|
-}
|
||||||
|
rooms : Vault -> List Types.Room
|
||||||
|
rooms (Vault vault) =
|
||||||
|
Envelope.mapList Internal.rooms vault
|
||||||
|
|> List.map Types.Room
|
||||||
|
|
||||||
|
|
||||||
{-| Send a message event to a room.
|
{-| Send a message event to a room.
|
||||||
|
|
||||||
This function can be used in a scenario where the user does not want to sync
|
This function can be used in a scenario where the user does not want to sync
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
module Matrix.Room exposing
|
module Matrix.Room exposing
|
||||||
( Room, mostRecentEvents
|
( Room, mostRecentEvents, roomId
|
||||||
, getAccountData
|
, getAccountData
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ What is usually called a chat, a channel, a conversation or a group chat on
|
||||||
other platforms, the term used in Matrix is a "room". A room is a conversation
|
other platforms, the term used in Matrix is a "room". A room is a conversation
|
||||||
where a group of users talk to each other.
|
where a group of users talk to each other.
|
||||||
|
|
||||||
@docs Room, mostRecentEvents
|
@docs Room, mostRecentEvents, roomId
|
||||||
|
|
||||||
This module exposes various functions that help you inspect various aspects of
|
This module exposes various functions that help you inspect various aspects of
|
||||||
a room.
|
a room.
|
||||||
|
@ -56,6 +56,14 @@ getAccountData key (Room room) =
|
||||||
Envelope.extract (Internal.getAccountData key) room
|
Envelope.extract (Internal.getAccountData key) room
|
||||||
|
|
||||||
|
|
||||||
|
{-| Get a room's room id. This is an opaque string that distinguishes rooms from
|
||||||
|
each other.
|
||||||
|
-}
|
||||||
|
roomId : Room -> String
|
||||||
|
roomId (Room room) =
|
||||||
|
Envelope.extract .roomId room
|
||||||
|
|
||||||
|
|
||||||
{-| Get a list of the most recent events sent in the room.
|
{-| Get a list of the most recent events sent in the room.
|
||||||
-}
|
-}
|
||||||
mostRecentEvents : Room -> List Types.Event
|
mostRecentEvents : Room -> List Types.Event
|
||||||
|
|
Loading…
Reference in New Issue