Giter Site home page Giter Site logo

jez500 / private-message-messenger Goto Github PK

View Code? Open in Web Editor NEW
7.0 5.0 4.0 64 KB

A Facebook messenger style UX for the Drupal 8 "Private Message" module

CSS 6.40% JavaScript 33.24% PHP 53.15% HTML 7.20%
drupal-8 drupal messaging marionettejs drupal-module backbonejs

private-message-messenger's Introduction

Private Message Messenger

Private messages in Drupal 8, that look like sweet!

This is "Facebook messenger" style UX for the Private Message module.

The whole UX is build using Backbone & Marionette, making it a snappy single page app. View messages, chnage threads, compose and reply to messages without a single page reload.

It is build with mobile in mind and will switch between mobile/desktop layout as space provides.

Screenshots

Desktop

Desktop

Mobile

Inbox

thread

Dependencies

Private Message

The Private Message module provides the framework for this module to work. It does a great job of handling message and thread structure using entites.

MarionetteJS

This module utilizes MarionetteJS to improve on BackboneJS capabilities. As of writing, it is not on drupal.org yet. Grab it from: https://github.com/jez500/Drupal8-Marionette-JS

This module was built using Marionette v3.5.1, download the zip from https://marionettejs.com/download/ and extract into your /libraries folder.

Selectize

The selectize JS library is used for adding new recipients to messages, install the Selectize drupal module and download the library to your /libraries folder.

Installation

Composer only instructions until I work out what to do with this module.

1. Add repo and install Private Message Messenger with deps

Add the repo to your composer.json

    "repositories": [
        ...

        {
            "type": "git",
            "url": "https://github.com/jez500/Drupal8-Marionette-JS.git"
        },
        {
            "type": "git",
            "url": "https://github.com/jez500/Private-Message-Messenger.git"
        }
    ],

Then... composer require drupal/marionettejs

And... composer require drupal/private_message_messenger

3. Download libraries

Download and extract the following to the /libraries folder

3. Enable

drush en -y private_message_messenger

4. Configure

  • Go to /admin/config/private_message/config and set preferred configuration then Save
  • Set the permission to use private message for the required roles.
  • Visit /messenger to see the messenger page
  • Blocks:
    • The Recent Messenger Messages block provides a dropdown containing recent messages
    • The Private Message Messenger block is the same as the /messenger page just exposed in a block

Docs for private_message: https://www.drupal.org/docs/8/modules/private-message

Paths

  • Thread path /messenger#thread-[THREAD_ID] eg /messenger#thread-1
  • Compose new message path /messenger#new
  • Compose new message to a specific user /messenger#new-[UID] eg /messenger#new-1]
  • Inbox (Only really applies to mobile, but will also refresh inbox) /messenger#new

Optional

Instant updates and notifications without polling

See Private Message NodeJS which was specifically made to compliment this module.

Improved timestamps

To make the dates on threads and messages look a lot nicer and use a live XX mins ago style format, you can include the timeago library library. To include this from a CDN, visit the settings page and tick the Include timeago.js from remote CDN checkbox. To include it locally, you will need to add the library to your theme or module manually. If the timeago() function is detected, this module will use it.

Todo's / Wishlist

  • Look into token validation
  • Email - Correct url / allow override of email notification template
  • Create a private_message_nodejs module that eliminates the need for polling and provides instant updates.
  • Pagination for thread list and message list
    • Currently thread list is limited to specified config
    • Currently ALL messages are shown in a loaded thread, have tested with 100's of messages and JSON response is still very small eg < 30k. More of a problem could potentially be the browser rendering that much, but no issues observed yet.

Author

This module is created by Jeremy Graham but wouldn't be possible without all the great work done by Jaypan on the Private Message module

private-message-messenger's People

Contributors

jez500 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

private-message-messenger's Issues

Feature request - email notifications

Hi first of all thanks for this excellent module.

This is a great module, it solved my many problems associated with the core private message module.

I think it would be an awesome idea to implement the email notifications as well. Or is these anyway we can do it please let me know. I think this module should be part of the core module.

Best regards guys.

How to show unread messages in PMM block?

I found this in pmm-recent.html.twig. I think it is a prepare for actually having the number of unread messages in the block.

<span class="pmm-recent__message-count pmm-recent-count"></span>

But it looks like there is a twig variable missing inside. I am not that good in coding so I just pushed the value inside via javascript from official Private Message block rendered elsewhere but it would be very nice to have.

undefined variable first_thread in JsonEndpoint

Here is the error :

Notice: Undefined variable: first_thread in Drupal\private_message_messenger\Controller\JsonEndpoint->buildThreadCollection() (line 206

Maybe due to the php version i use
I changed line 206 in JsonEndpoint.php to get rid of it.

- if (!$first_thread || $processed_thread['threadId'] != $first_thread['threadId']) {
+ if (!isset($first_thread) || $processed_thread['threadId'] != $first_thread['threadId']) {

Open first conversation in list after opening /messenger page

Thanks for your work on this module, it really is awesome! Let's make it more awesome.

I found that it would be nice that after opening /messenger page, if there is any conversation in threads it should open first one in list. This is same behavior as FB messenger does and user will expect does. Currently /messenger page opens and displays only blank page, and user has to click on thread to see conversation.

Can this be achieved by plain JS? I mean reacting after messenger div is displayed, trigger first thread click? Cheers! ;)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.