Skip to content

Instantly share code, notes, and snippets.

@helderjnpinto
Created March 29, 2017 18:50
Show Gist options
  • Save helderjnpinto/5bab88dafd346232755b69a57cf672aa to your computer and use it in GitHub Desktop.
Save helderjnpinto/5bab88dafd346232755b69a57cf672aa to your computer and use it in GitHub Desktop.
itemListConvos : Model -> ( Convo, String ) -> Html Msg
itemListConvos model tup =
let
convo : Convo
convo =
Tuple.first tup
nameConvo =
Utils.getNameOfConvo model.userProfile convo model.usersList
existUnreadMsg =
Dict.member convo.id model.unreadMsgs
classUnreadMsg =
[ ( "icon-check-circle-blank color-white", not existUnreadMsg )
, ( "icon-check-circle-blank color-lime-500", existUnreadMsg )
]
isAdmin partDict =
let
userType =
Dict.get "value" partDict |> Utils.parseMaybeStringToString
userId =
Dict.get "key" partDict |> Utils.parseMaybeStringToString
in
(userType == "admin" && userId == model.userProfile.id)
thisIsAdminOfChannel =
List.any isAdmin convo.participants
draftedMessages =
if Dict.member convo.id model.bufferDraftMessages then
div [ class "icon-create custom-drafted" ] []
else
div [] []
unReadCounter =
let
filterUnread =
filterUnReadByConvoAndUserID convo (model.userProfile).id (model.readStatusList).read_status
compareUnread =
compareLastUnread (model.userProfile).id filterUnread convo model.messages
in
if compareUnread == 0 then
div [] []
else
div [ class "unReadStatus" ] [ text (toString compareUnread) ]
html =
(ul [ class "list listConvos disable-selection" ]
[ li [ attribute "ripple" "", onClick (OpenConvo convo) ]
[ Avatar.genAvatar nameConvo
, span [ class "item-text" ]
[ text nameConvo
, span [ class "secondary-text" ]
[ div [ id "cont-secondary-text" ]
[ div [ id "cont-secondary-last-msg" ] [ ]
, div [ id "cont-secondary-date-msg" ] [ ]
, draftedMessages
]
]
]
, i [ classList classUnreadMsg ] []
, unReadCounter
, span [ CtxtMenu.open ContextMenuMsg (ConvoOptions convo thisIsAdminOfChannel), onMouseUp (OpenConvo convo) ]
[ i [ class "icon-message icon-more-vertical" ] []
]
]
]
)
in
html
-- and i have one function with more stuff and one list map
...
in
div [] (List.map (itemListConvos model) listReverse)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment