RocketChat/Rocket.Chat

View on GitHub
apps/meteor/client/startup/afterLogoutCleanUp/purgeAllDrafts.ts

Summary

Maintainability
A
0 mins
Test Coverage
import { Meteor } from 'meteor/meteor';

import { callbacks } from '../../../lib/callbacks';
import { afterLogoutCleanUpCallback } from '../../../lib/callbacks/afterLogoutCleanUpCallback';

Meteor.startup(() => {
    const purgeAllDrafts = (): void => {
        Object.keys(localStorage)
            .filter((key) => key.indexOf('messagebox_') === 0)
            .forEach((key) => localStorage.removeItem(key));
    };

    afterLogoutCleanUpCallback.add(purgeAllDrafts, callbacks.priority.MEDIUM, 'chatMessages-after-logout-cleanup');
});