From 71845ae091f9dcbad0f72409c258ee6f41fde7c9 Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Wed, 9 Oct 2019 12:52:59 -0700 Subject: [PATCH] Fix sender names not being used --- src/Scylla/Model.elm | 4 ++-- src/Scylla/Room.elm | 3 ++- src/Scylla/UserData.elm | 5 ----- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/Scylla/Model.elm b/src/Scylla/Model.elm index cf0e4e9..958f2fb 100644 --- a/src/Scylla/Model.elm +++ b/src/Scylla/Model.elm @@ -4,7 +4,7 @@ import Scylla.Room exposing (getLocalDisplayName) import Scylla.Sync exposing (SyncResponse, HistoryResponse) import Scylla.ListUtils exposing (findFirst) 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.Push exposing (Ruleset) import Scylla.Sync.AccountData exposing (AccountData, directMessagesDecoder) @@ -93,4 +93,4 @@ roomLocalDisplayName : Model -> RoomId -> Username -> String roomLocalDisplayName m rid u = case Dict.get rid m.rooms of Just rd -> getLocalDisplayName rd u - _ -> u + _ -> getSenderName u diff --git a/src/Scylla/Room.elm b/src/Scylla/Room.elm index f8eb22b..703dd81 100644 --- a/src/Scylla/Room.elm +++ b/src/Scylla/Room.elm @@ -2,6 +2,7 @@ module Scylla.Room exposing (..) import Scylla.Route exposing (RoomId) import Scylla.Sync exposing (SyncResponse) import Scylla.Login exposing (Username) +import Scylla.UserData exposing (getSenderName) import Scylla.Sync exposing (HistoryResponse) import Scylla.Sync.Events exposing (MessageEvent, StateEvent, toStateEvent, toMessageEvent) import Scylla.Sync.AccountData exposing (AccountData, getDirectMessages, applyAccountData) @@ -147,7 +148,7 @@ getRoomName ad rid rd = getLocalDisplayName : RoomData -> Username -> String getLocalDisplayName rd u = getStateData ("m.room.member", u) (field "displayname" string) rd - |> Maybe.withDefault u + |> Maybe.withDefault (getSenderName u) getNotificationCount : RoomData -> (Int, Int) getNotificationCount rd = diff --git a/src/Scylla/UserData.elm b/src/Scylla/UserData.elm index 6555c62..893a1c7 100644 --- a/src/Scylla/UserData.elm +++ b/src/Scylla/UserData.elm @@ -15,11 +15,6 @@ userDataDecoder = |> optional "displayname" (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 s = let