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

🛠 Update knowledge graph #2548

Merged
merged 4 commits into from
Sep 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export default class KnowledgeGraphAPIClient {
channel_name: channel.name,
channel_owner: channel.owner,
workspace_id: channel.workspace_id,
company_id: channel.company_id,
},
},
},
Expand Down Expand Up @@ -134,6 +135,8 @@ export default class KnowledgeGraphAPIClient {
message_updated_at: message.updated_at.toLocaleString(),
user_id: message.user_id,
channel_id: channelId,
workspace_id: message.cache?.workspace_id,
company_id: message.cache?.company_id,
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,16 @@ export default class KnowledgeGraphService
const user = userId ? await gr.services.users.get({ id: userId }) : null;
const forwardedCompanies = this.getConfigurationEntry<string[]>("forwarded_companies");
const isCompanyForwarded = !!(companyIds || []).find(v => forwardedCompanies.includes(v));
return (!userId || (user && user.preferences.knowledge_graph !== "nothing")) &&
if (user?.preferences && !user.preferences.knowledge_graph)
user.preferences.knowledge_graph = "metadata";
return (!userId || (user && user.preferences?.knowledge_graph !== "nothing")) &&
(!companyIds ||
companyIds.length === 0 ||
isCompanyForwarded ||
forwardedCompanies.length === 0)
? (user.preferences.knowledge_graph as "all" | "metadata")
? user
? (user.preferences.knowledge_graph as "all" | "metadata")
: "all"
: false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,20 +127,20 @@ export default class Api {
disableJWTAuthentication?: boolean;
} = {},
): Promise<Response> {
return Api.request(route, {}, callback, raw, { ...options, requestType: 'delete' });
return Api.request(route, null, callback, raw, { ...options, requestType: 'delete' });
}

static request<Request extends { _grouped?: unknown }, Response>(
route: string,
data: Request,
data: Request | null,
callback: any = false,
raw = false,
options: {
disableJWTAuthentication?: boolean;
requestType?: 'post' | 'get' | 'put' | 'delete';
} = {},
): Promise<Response> {
return new Promise((resolve) => {
return new Promise(resolve => {
if (data && data._grouped && route === 'core/collections/init') {
GroupedQueryApiInstance.post(route, data, callback);
return;
Expand All @@ -149,7 +149,7 @@ export default class Api {
Requests.request(
options.requestType ? options.requestType : 'post',
new URL(route, Globals.api_root_url).toString(),
JSON.stringify(data),
data === null ? '' : JSON.stringify(data),
(resp: any) => {
if (raw) {
resolve(resp);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Requests {
method: type,
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
...(data ? { 'Content-Type': 'application/json' } : {}),
Authorization: JWTStorage.getAutorizationHeader(),
},
body: type === 'post' ? data || '{}' : undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,6 @@ export const useNotifications = () => {
'id',
);
setBadges(list);
list.map(notification => {
userNotificationApiClient.acknowledge(notification);
});
},
[setBadges, badges],
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,23 +116,24 @@ export default (props: Props) => {
<Beacon tag="channel_bar_component" />
</div>
)}
{((props.unreadMessages > 0 && props.mentions + props.replies === 0) ||
props.mentions + props.replies > 1) && (
<div
className={
'text-xs font-medium h-5 px-1.5 flex items-center justify-center text-sm rounded-full ml-1' +
(props.notificationLevel === 'all' ||
(props.mentions + props.replies > 0 && props.notificationLevel !== 'none')
? blueBadgeClassName
: grayBadgeClassName)
}
>
{Math.min(
99,
Math.max(1, Math.max(props.mentions + props.replies, props.unreadMessages)),
)}
</div>
)}
{!(props.visibility === 'direct' && props.mentions + props.replies === 0) &&
((props.unreadMessages > 0 && props.mentions + props.replies === 0) ||
props.mentions + props.replies > 1) && (
<div
className={
'text-xs font-medium h-5 px-1.5 flex items-center justify-center text-sm rounded-full ml-1' +
(props.notificationLevel === 'all' ||
(props.mentions + props.replies > 0 && props.notificationLevel !== 'none')
? blueBadgeClassName
: grayBadgeClassName)
}
>
{Math.min(
99,
Math.max(1, Math.max(props.mentions + props.replies, props.unreadMessages)),
)}
</div>
)}
{props.menu}
</div>
</div>
Expand Down