Skip to content

Commit

Permalink
Refactor Omnichannle Filters and Fix lint Issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Shailesh351 committed Apr 29, 2021
1 parent e7fbd11 commit ce595c7
Show file tree
Hide file tree
Showing 21 changed files with 376 additions and 530 deletions.
1 change: 1 addition & 0 deletions app/theme/client/imports/components/read-receipts.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
width: 0.8em;
height: 0.8em;
}

/* Overwriting the color-component-color class defined in colors.less */
.color-component-color {
color: grey;
Expand Down
7 changes: 3 additions & 4 deletions client/components/SortList/SortList.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import { Divider } from '@rocket.chat/fuselage';
import React from 'react';

import { isMobile } from '../../../app/utils/client';
import GroupingList from './GroupingList';
import SortModeList from './SortModeList';
import ViewModeList from './ViewModeList';

import { isMobile } from '../../../app/utils/client';

function SortList() {
return (
<>
<div className='rc-popover__column'>
{!isMobile() && <ViewModeList/>}
{!isMobile() && <Divider/>}
{!isMobile() && <ViewModeList />}
{!isMobile() && <Divider />}
<SortModeList />
<Divider />
<GroupingList />
Expand Down
95 changes: 0 additions & 95 deletions client/components/header/BurgerMenuButton.css

This file was deleted.

80 changes: 0 additions & 80 deletions client/components/header/BurgerMenuButton.js

This file was deleted.

55 changes: 28 additions & 27 deletions client/importServiceWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { Meteor } from 'meteor/meteor';
import { Tracker } from 'meteor/tracker';

import { settings } from '../app/settings';
import { handleError, t } from '../app/utils/client';
import { modal } from '../app/ui-utils/client';
import { handleError, t } from '../app/utils/client';

function urlBase64ToUint8Array(base64String) {
const padding = '='.repeat((4 - (base64String.length % 4)) % 4);
Expand All @@ -18,7 +18,6 @@ function urlBase64ToUint8Array(base64String) {
return outputArray;
}


function isMobile() {
const toMatch = [
/Android/i,
Expand All @@ -35,14 +34,13 @@ function isMobile() {

function subscribeUser() {
if ('serviceWorker' in navigator) {
navigator.serviceWorker.ready.then(async function(reg) {
navigator.serviceWorker.ready.then(async (reg) => {
try {
const vapidKey = await settings.get('Vapid_public_key');
const subscription = await reg.pushManager
.subscribe({
userVisibleOnly: true,
applicationServerKey: urlBase64ToUint8Array(vapidKey),
});
const subscription = await reg.pushManager.subscribe({
userVisibleOnly: true,
applicationServerKey: urlBase64ToUint8Array(vapidKey),
});

const platform = isMobile() ? 'mobile' : 'desktop';
Meteor.call('savePushNotificationSubscription', JSON.stringify(subscription), platform);
Expand All @@ -61,40 +59,43 @@ Meteor.startup(() => {
.register('sw.js', {
scope: './',
})
.then(function(reg) {
.then((reg) => {
if (reg.installing) {
const sw = reg.installing || reg.waiting;
sw.onstatechange = function() {
sw.onstatechange = function () {
if (sw.state === 'installed') {
// SW installed. Reload page.
window.location.reload();
}
};
console.log(`Service worker has been registered for scope: ${ reg.scope }`);
console.log(`Service worker has been registered for scope: ${reg.scope}`);
} else {
if (settings.get('Push_enable') !== true) {
return;
}

reg.pushManager.getSubscription().then(function(sub) {
reg.pushManager.getSubscription().then((sub) => {
if (sub === null) {
console.log('Not subscribed to push service!');
if (settingsReady) {
modal.open({
title: t('Important'),
type: 'info',
text: t('Please subscribe to push notifications to continue'),
showCancelButton: true,
confirmButtonText: t('Subscribe'),
cancelButtonText: t('Cancel'),
closeOnConfirm: true,
}, () => {
Notification.requestPermission().then(function(permission) {
if (permission === 'granted') {
subscribeUser();
}
});
});
modal.open(
{
title: t('Important'),
type: 'info',
text: t('Please subscribe to push notifications to continue'),
showCancelButton: true,
confirmButtonText: t('Subscribe'),
cancelButtonText: t('Cancel'),
closeOnConfirm: true,
},
() => {
Notification.requestPermission().then((permission) => {
if (permission === 'granted') {
subscribeUser();
}
});
},
);
computation.stop();
}
} else {
Expand Down
28 changes: 17 additions & 11 deletions client/methods/deleteMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,36 @@ Meteor.methods({
// We're now only passed in the `_id` property to lower the amount of data sent to the server
const message = ChatMessage.findOne({ _id: msg._id });

if (!message || !canDeleteMessage({
rid: message.rid,
ts: message.ts,
uid: message.u._id,
})) {
if (
!message ||
!canDeleteMessage({
rid: message.rid,
ts: message.ts,
uid: message.u._id,
})
) {
return false;
}

if (message.temp && message.tempActions.send) {
ChatMessage.remove({
_id: message._id,
'_id': message._id,
'u._id': Meteor.userId(),
});
if (message.file) {
SWCache.removeFromCache(message.file);
Session.set(`uploading-cancel-${ message.file._id }`, true);
Session.set(`uploading-cancel-${message.file._id}`, true);
}
} else {
const messageObject = { temp: true, msg: 'Message deleted', tempActions: { delete: true } };

ChatMessage.update({
_id: message._id,
'u._id': Meteor.userId(),
}, { $set: messageObject, $unset: { reactions: 1, file: 1, attachments: 1 } });
ChatMessage.update(
{
'_id': message._id,
'u._id': Meteor.userId(),
},
{ $set: messageObject, $unset: { reactions: 1, file: 1, attachments: 1 } },
);
}
},
});
3 changes: 2 additions & 1 deletion client/methods/updateMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ Meteor.methods({
editedAt: message.editedAt,
editedBy: message.editedBy,
msg: message.msg,
temp: true, tempActions,
temp: true,
tempActions,
};

if (originalMessage.attachments) {
Expand Down
2 changes: 1 addition & 1 deletion client/providers/UserProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Meteor } from 'meteor/meteor';
import React, { useMemo, FC } from 'react';

import { callbacks } from '../../app/callbacks/client';
import { Subscriptions, Rooms } from '../../app/models/client';
import { getUserPreference } from '../../app/utils/client';
import { IRoom } from '../../definition/IRoom';
import { ISubscription } from '../../definition/ISubscription';
import { UserContext } from '../contexts/UserContext';
import { useReactiveValue } from '../hooks/useReactiveValue';
import { createReactiveSubscriptionFactory } from './createReactiveSubscriptionFactory';
import { callbacks } from '../../app/callbacks/client';

const getUserId = (): string | null => Meteor.userId();

Expand Down
Loading

0 comments on commit ce595c7

Please sign in to comment.