Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NEW] [Apps] Add new typing bridge method (Typing-Indicator) #19228

Merged
merged 7 commits into from Oct 26, 2020

Conversation

shiqimei
Copy link
Contributor

@shiqimei shiqimei commented Oct 13, 2020

Proposed changes

This PR introduces a new message bridge method typing, which added typing indicator support for Rocket.Chat apps.

Issue(s)

RocketChat/Rocket.Chat.Apps-engine#303

How to test or reproduce

import { IAppAccessors, IHttp, ILogger, IModify, IPersistence, IRead } from '@rocket.chat/apps-engine/definition/accessors';
import { App } from '@rocket.chat/apps-engine/definition/App';
import { IMessage, IPostMessageSent } from '@rocket.chat/apps-engine/definition/messages';
import { IAppInfo } from '@rocket.chat/apps-engine/definition/metadata';

export class TypeIndicatorApp extends App implements IPostMessageSent {
    private stopTypings = [] as Array<Promise<() => Promise<void>>>;

    constructor(info: IAppInfo, logger: ILogger, accessors: IAppAccessors) {
        super(info, logger, accessors);
    }

    public async executePostMessageSent(message: IMessage, read: IRead, http: IHttp, persistence: IPersistence, modify: IModify): Promise<void> {
        switch (message.text) {
            case 't':
                [
                    undefined, // use app user's name by default
                    'Shiqi Mei', // custom name
                ].forEach((username) => {
                    const stopTyping = modify.getNotifier().typing({ id: message.room.id, username });
                    this.stopTypings.push(stopTyping);
                });
                break;
            default:
                for (const stopTyping of this.stopTypings) {
                    await (await stopTyping)();
                }
                this.stopTypings = [];
        }
    }
}

Zip:
type-indicator_0.0.1.zip

Screenshots

image

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • Improvement (non-breaking change which improves a current function)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Hotfix (a major bugfix that has to be merged asap)
  • Documentation Update (if none of the other choices apply)

Checklist

  • I have read the CONTRIBUTING doc
  • I have signed the CLA
  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works (if applicable)
  • I have added necessary documentation (if applicable)
  • Any dependent changes have been merged and published in downstream modules

Changelog

Further comments

@shiqimei
Copy link
Contributor Author

Depends on RocketChat/Rocket.Chat.Apps-engine#332

@d-gubert d-gubert added this to the 3.8.0 milestone Oct 16, 2020
d-gubert
d-gubert previously approved these changes Oct 19, 2020
@d-gubert d-gubert changed the title [NEW] [Apps] Add new typing bridge method [NEW] [Apps] Add new typing bridge method (Typing-Indicator) Oct 20, 2020
d-gubert
d-gubert previously approved these changes Oct 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants