Fix sender names not being used

This commit is contained in:
Danila Fedorin 2019-10-09 12:52:59 -07:00
parent 4505b4ba27
commit 71845ae091
3 changed files with 4 additions and 8 deletions

View File

@ -4,7 +4,7 @@ import Scylla.Room exposing (getLocalDisplayName)
import Scylla.Sync exposing (SyncResponse, HistoryResponse) import Scylla.Sync exposing (SyncResponse, HistoryResponse)
import Scylla.ListUtils exposing (findFirst) import Scylla.ListUtils exposing (findFirst)
import Scylla.Room exposing (OpenRooms) import Scylla.Room exposing (OpenRooms)
import Scylla.UserData exposing (UserData) import Scylla.UserData exposing (UserData, getSenderName)
import Scylla.Sync.Rooms exposing (JoinedRoom) import Scylla.Sync.Rooms exposing (JoinedRoom)
import Scylla.Sync.Push exposing (Ruleset) import Scylla.Sync.Push exposing (Ruleset)
import Scylla.Sync.AccountData exposing (AccountData, directMessagesDecoder) import Scylla.Sync.AccountData exposing (AccountData, directMessagesDecoder)
@ -93,4 +93,4 @@ roomLocalDisplayName : Model -> RoomId -> Username -> String
roomLocalDisplayName m rid u = roomLocalDisplayName m rid u =
case Dict.get rid m.rooms of case Dict.get rid m.rooms of
Just rd -> getLocalDisplayName rd u Just rd -> getLocalDisplayName rd u
_ -> u _ -> getSenderName u

View File

@ -2,6 +2,7 @@ module Scylla.Room exposing (..)
import Scylla.Route exposing (RoomId) import Scylla.Route exposing (RoomId)
import Scylla.Sync exposing (SyncResponse) import Scylla.Sync exposing (SyncResponse)
import Scylla.Login exposing (Username) import Scylla.Login exposing (Username)
import Scylla.UserData exposing (getSenderName)
import Scylla.Sync exposing (HistoryResponse) import Scylla.Sync exposing (HistoryResponse)
import Scylla.Sync.Events exposing (MessageEvent, StateEvent, toStateEvent, toMessageEvent) import Scylla.Sync.Events exposing (MessageEvent, StateEvent, toStateEvent, toMessageEvent)
import Scylla.Sync.AccountData exposing (AccountData, getDirectMessages, applyAccountData) import Scylla.Sync.AccountData exposing (AccountData, getDirectMessages, applyAccountData)
@ -147,7 +148,7 @@ getRoomName ad rid rd =
getLocalDisplayName : RoomData -> Username -> String getLocalDisplayName : RoomData -> Username -> String
getLocalDisplayName rd u = getLocalDisplayName rd u =
getStateData ("m.room.member", u) (field "displayname" string) rd getStateData ("m.room.member", u) (field "displayname" string) rd
|> Maybe.withDefault u |> Maybe.withDefault (getSenderName u)
getNotificationCount : RoomData -> (Int, Int) getNotificationCount : RoomData -> (Int, Int)
getNotificationCount rd = getNotificationCount rd =

View File

@ -15,11 +15,6 @@ userDataDecoder =
|> optional "displayname" (Decode.map Just string) Nothing |> optional "displayname" (Decode.map Just string) Nothing
|> optional "avatar_url" (Decode.map Just string) Nothing |> optional "avatar_url" (Decode.map Just string) Nothing
getDisplayName : Dict Username UserData -> Username -> String
getDisplayName ud s = Dict.get s ud
|> Maybe.andThen .displayName
|> Maybe.withDefault (getSenderName s)
getSenderName : Username -> String getSenderName : Username -> String
getSenderName s = getSenderName s =
let let