* added config to support code split * splitting config * moved the window declaration in EE file as its dependency will be updated in EE * CE: Splitting ApiConstants and SocialLogin constants * CE: split login page * CE: moved getSocialLoginButtonProps func to EE file as it's dependencies will be updated in EE * added key icon * CE: created a factory class to share social auths list * Minor style fix for social btns * Updated the third party auth styles * updated jest config * updated third party login registry class
103 lines
3.3 KiB
TypeScript
103 lines
3.3 KiB
TypeScript
import { put, select } from "redux-saga/effects";
|
|
import { APP_LEVEL_SOCKET_EVENTS } from "./socketEvents";
|
|
|
|
import {
|
|
newCommentEvent,
|
|
newCommentThreadEvent,
|
|
updateCommentThreadEvent,
|
|
updateCommentEvent,
|
|
deleteCommentThreadEvent,
|
|
deleteCommentEvent,
|
|
} from "actions/commentActions";
|
|
import { collabSetAppEditors } from "actions/appCollabActions";
|
|
import { newNotificationEvent } from "actions/notificationActions";
|
|
import { getCurrentUser } from "selectors/usersSelectors";
|
|
import { Toaster } from "components/ads/Toast";
|
|
import {
|
|
createMessage,
|
|
INFO_VERSION_MISMATCH_FOUND_RELOAD_REQUEST,
|
|
} from "constants/messages";
|
|
import { Variant } from "components/ads/common";
|
|
import React from "react";
|
|
import { getAppsmithConfigs } from "@appsmith/configs";
|
|
|
|
export default function* handleAppLevelSocketEvents(event: any) {
|
|
const currentUser = yield select(getCurrentUser);
|
|
|
|
switch (event.type) {
|
|
// comments
|
|
case APP_LEVEL_SOCKET_EVENTS.INSERT_COMMENT_THREAD: {
|
|
const { thread } = event.payload[0];
|
|
const isThreadFromEventViewed = thread?.viewedByUsers?.includes(
|
|
currentUser?.username,
|
|
);
|
|
yield put(
|
|
newCommentThreadEvent({
|
|
...thread,
|
|
// This is necessary to be done from the start, as client depends on
|
|
// these values to find if there is an unread thread.
|
|
isViewed: isThreadFromEventViewed || thread?.resolvedState?.active,
|
|
}),
|
|
);
|
|
return;
|
|
}
|
|
case APP_LEVEL_SOCKET_EVENTS.INSERT_COMMENT: {
|
|
yield put(newCommentEvent(event.payload[0]));
|
|
return;
|
|
}
|
|
case APP_LEVEL_SOCKET_EVENTS.REPLACE_COMMENT_THREAD:
|
|
case APP_LEVEL_SOCKET_EVENTS.UPDATE_COMMENT_THREAD: {
|
|
const { thread } = event.payload[0];
|
|
|
|
const isThreadFromEventViewed = thread?.viewedByUsers?.includes(
|
|
currentUser?.username,
|
|
);
|
|
|
|
yield put(
|
|
updateCommentThreadEvent({
|
|
...thread,
|
|
isViewed: isThreadFromEventViewed || thread?.resolvedState?.active, // resolved threads can't be unread
|
|
}),
|
|
);
|
|
return;
|
|
}
|
|
case APP_LEVEL_SOCKET_EVENTS.UPDATE_COMMENT: {
|
|
yield put(updateCommentEvent(event.payload[0].comment));
|
|
return;
|
|
}
|
|
case APP_LEVEL_SOCKET_EVENTS.DELETE_COMMENT_THREAD: {
|
|
yield put(deleteCommentThreadEvent(event.payload[0].thread));
|
|
return;
|
|
}
|
|
case APP_LEVEL_SOCKET_EVENTS.DELETE_COMMENT: {
|
|
yield put(deleteCommentEvent(event.payload[0].comment));
|
|
return;
|
|
}
|
|
// notifications
|
|
case APP_LEVEL_SOCKET_EVENTS.INSERT_NOTIFICATION: {
|
|
yield put(newNotificationEvent(event.payload[0].notification));
|
|
return;
|
|
}
|
|
// Collab V2 - Realtime Editing
|
|
case APP_LEVEL_SOCKET_EVENTS.LIST_ONLINE_APP_EDITORS: {
|
|
yield put(collabSetAppEditors(event.payload[0]));
|
|
return;
|
|
}
|
|
// notification on release version
|
|
case APP_LEVEL_SOCKET_EVENTS.RELEASE_VERSION_NOTIFICATION: {
|
|
const { appVersion } = getAppsmithConfigs();
|
|
if (appVersion.id != event.payload[0]) {
|
|
Toaster.show({
|
|
text: createMessage(INFO_VERSION_MISMATCH_FOUND_RELOAD_REQUEST),
|
|
variant: Variant.info,
|
|
actionElement: (
|
|
<span onClick={() => location.reload(true)}>REFRESH</span>
|
|
),
|
|
autoClose: false,
|
|
});
|
|
}
|
|
return;
|
|
}
|
|
}
|
|
}
|