kohdataan / kohdataan-frontend

Somettamalla uutta kohtaamista -frontend
https://kohdataan.fi/
4 stars 1 forks source link

Frontend/366/add divider for new messages #378

Closed larenala closed 4 years ago

larenala commented 4 years ago

Adds divider for new notifications. The divider is added before any notification, also join and leave channel notifications. When the user opens the chat the page automatically scrolls to the new messages. There was a problem with the divider showing at the bottom of the page if the page is refreshed. I added a counter to check if the message is the last message. It didn't seem like the best solution so if you can think of a better way to do this, please tell. :)

I also added some accessibility fixes to the chat based on the comments, and I think it works nicer now. Screen reader users can skip to new messages using the h2-headline "Uudet tapahtumat".

Pninja commented 4 years ago

And this one, but this seems a bit unclear to me how this works, since I think user's message count updates immediately after channel is viewed

export const countCurrentChannelUnreadMessages: (state: GlobalState) => number = createSelector(
    getCurrentChannel,
    getMyCurrentChannelMembership,
    (channel: Channel, membership?: ChannelMembership | null): number => {
        if (!membership) {
            return 0;
        }
        return channel.total_msg_count - membership.msg_count;
    },
);