Skip to content

Releases: bubasuma/yii2-simplechat

Never Give Up

19 Jun 07:06
Compare
Choose a tag to compare

Yii2-SimpleChat 2.0.0 is released

Thank you for your support and patience!

Lion

29 May 11:43
Compare
Choose a tag to compare
Lion Pre-release
Pre-release

Yii2-SimpleChat 2.0.0 Beta is released

I am very pleased to announce the the Beta release of yii2-simplechat version 2. You may follow the instructions on Github to install or upgrade to this version.

Major Changes since 2.0 Alpha

Below i am summarizing the most important new features and changes.

Structure

Model class has been broken in two classes Conversation class and Message class.
Now, formatters have been removed from controller to models Conversation and Message by using fields method.

Performance

The most notable change is that conversation query eager loads last message. This allows the count query to not use the unnecessary join with last message.

Demo (Testing)

I also added more flexibility when generating and loading test data to the database thanks to Fixtures and yii2-faker extension. You can now specify how many fixtures per user and message you need to generate and in what language.

php yii simplechat/start --users=50 --messages=10000 --language="ru_RU"

Thank you!

Thank you all for making this release possible.

Buba

07 Feb 16:09
Compare
Choose a tag to compare
Buba Pre-release
Pre-release

Yii2-SimpleChat 2.0.0 alpha is released

I am very pleased to announce the release of yii2-simplechat 2.0.0-alpha. You may follow the instructions on github to install or upgrade to this version.
The version 2 is a complete rewrite of the version 1. This version inherits the main spirit behind yii2-simplechat for being a simple, fast and flexible.
The alpha release of yii2-simplechat 2 marks a major milestone in the course of development. It means that the code base of the version 2 has reached a certain degree of stability. If you just start to use yii2-simplechat or you do not have a tight project schedule, you may consider using this version. Please do not use this version in production as i may still introduce significant changes without prior notices.

Genab

23 Jan 14:12
Compare
Choose a tag to compare

Yii2-SimpleChat 1.0.0 is released

I am very pleased to announce the release of yii2-simplechat 1.0.0. You may follow the instructions on github to install or upgrade to this version.

laho

13 Dec 16:52
Compare
Choose a tag to compare
laho Pre-release
Pre-release

Yii2-SimpleChat 1.0.0 RC is released

I am very pleased to announce the release of yii2-simplechat 1.0.0 RC (Release Candidate). You may follow the instructions on github to install or upgrade to this version.

This RC release includes many bug fixes. It is a result of one month of intensive development since the prior Beta release. During this period, I have received a lot of help from my colleague. I thank everyone who has contributed to yii2-simplechat and made this release possible . I thank Big Drop Inc where I acquired enough of skills to develop this extension. You are the best!

Major Enhancements in 1.0.0 RC

In this release, I have included many useful features and changes. Below I summarize some of the most important ones.

Unread Messages Count of Conversation

yii2-simplechat now has built-in support for getting unread messages count for each conversation. You can see the code below:

    public function getNewMessages()
    {
        return $this->hasOne(static::className(), ['sender_id' => 'contact_id'])
            ->where(['is_new' => 1])
            ->groupBy('sender_id');
    }


    /**
     * @param string $userId
     * @return ConversationQuery
     * @throws \yii\base\InvalidConfigException
     */
    public static function conversations($userId)
    {
        /**@var ConversationQuery $query * */
        $query = \Yii::createObject(ConversationQuery::className(),
            [
                get_called_class(),
                ['userId' => $userId]
            ]
        );
        // load unread messages count for each conversation
        return $query->with([
            'newMessages' => function ($msg) use ($userId) {
                /**@var $msg ConversationQuery * */
                $msg->andOnCondition(['receiver_id' => $userId])->select(['sender_id', 'COUNT(*) AS count']);
            }
        ]);
    }

Delete Conversation

yii2-simplechat now has built-in support for deleting conversation. is_deleted_by_sender is set to 1 if who deletes conversation is the sender of the message and is_deleted_by_receiver to 1 if who deletes conversation is the receiver of the message. You can see the code below:

   /**
     * @param string $userId
     * @param string $contactId
     * @return array the number of rows updated
     */
    public static function deleteConversation($userId, $contactId)
    {
        $count = static::updateAll(
            [
                'is_deleted_by_sender' => new Expression('IF([[sender_id]] =:userId, 1, is_deleted_by_sender)'),
                'is_deleted_by_receiver' => new Expression('IF([[receiver_id]] =:userId, 1, is_deleted_by_receiver)')
            ],
            ['or',
                [
                    'receiver_id' => $userId,
                    'sender_id' => $contactId,
                    'is_deleted_by_receiver' => 0
                ],
                [
                    'sender_id' => $userId,
                    'receiver_id' => $contactId,
                    'is_deleted_by_sender' => 0
                ],
            ],
            [
                ':userId' => $userId
            ]
        );
        return compact('count');
    }

Mark Conversation as Read

yii2-simplechat now has built-in support for marking conversation as read. is_new is set to 0 where it is equal to 1. You can see the code below:

   /**
     * @param $userId
     * @param $contactId
     * @return array the number of rows updated
     */
    public static function markConversationAsRead($userId, $contactId)
    {
        $count = static::updateAll(
            ['is_new' => 0,],
            ['receiver_id' => $userId, 'sender_id' => $contactId, 'is_new' => 1]
        );
        return compact('count');
    }

Mark Conversation as Unread

yii2-simplechat now has built-in support for marking conversation as unread. Mark the last received message in the conversation as unread by setting is_new to 1. You can see the code below:

   /**
     * @param $userId
     * @param $contactId
     * @return array
     */
    public static function markConversationAsUnread($userId, $contactId)
    {
        /** @var self $last_received_message */
        $last_received_message = static::find()
            ->where(['sender_id' => $contactId, 'receiver_id' => $userId])
            ->orderBy(['id' => SORT_DESC])
            ->limit(1)
            ->one();
        $count = 0;
        if ($last_received_message) {
            $last_received_message->is_new = 1;
            $count = intval($last_received_message->update());
        }
        return compact('count');
    }