mirror of
https://github.com/colanode/colanode.git
synced 2025-12-29 00:25:03 +01:00
Fix a case of handling workspace node created event
This commit is contained in:
@@ -4,6 +4,7 @@ import { EmailLogin } from '@/renderer/components/accounts/email-login';
|
||||
import { ServerDropdown } from '@/renderer/components/servers/server-dropdown';
|
||||
import { useApp } from '@/renderer/contexts/app';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { Separator } from '@/renderer/components/ui/separator';
|
||||
|
||||
export const LoginForm = () => {
|
||||
const app = useApp();
|
||||
@@ -31,14 +32,17 @@ export const LoginForm = () => {
|
||||
: 'No account yet? Register'}
|
||||
</p>
|
||||
{app.accounts.length > 0 && (
|
||||
<p
|
||||
className="text-center text-sm text-muted-foreground hover:cursor-pointer hover:underline"
|
||||
onClick={() => {
|
||||
navigate(-1);
|
||||
}}
|
||||
>
|
||||
Cancel
|
||||
</p>
|
||||
<React.Fragment>
|
||||
<Separator className="w-full" />
|
||||
<p
|
||||
className="text-center text-sm text-muted-foreground hover:cursor-pointer hover:underline"
|
||||
onClick={() => {
|
||||
navigate(-1);
|
||||
}}
|
||||
>
|
||||
Cancel
|
||||
</p>
|
||||
</React.Fragment>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -100,11 +100,16 @@ const handleNodeDeletedEvent = async (
|
||||
const createUserNodes = async (event: NodeCreatedEvent): Promise<void> => {
|
||||
const userNodesToCreate: CreateUserNode[] = [];
|
||||
|
||||
const isForEveryone =
|
||||
event.attributes.type === NodeTypes.User ||
|
||||
event.attributes.type === NodeTypes.Workspace;
|
||||
if (event.attributes.type === NodeTypes.User) {
|
||||
userNodesToCreate.push({
|
||||
user_id: event.id,
|
||||
node_id: event.workspaceId,
|
||||
workspace_id: event.workspaceId,
|
||||
mentions_count: 0,
|
||||
created_at: new Date(),
|
||||
version_id: generateId(IdType.Version),
|
||||
});
|
||||
|
||||
if (isForEveryone) {
|
||||
const userIds = await fetchWorkspaceUsers(event.workspaceId);
|
||||
|
||||
for (const userId of userIds) {
|
||||
@@ -138,6 +143,23 @@ const createUserNodes = async (event: NodeCreatedEvent): Promise<void> => {
|
||||
updated_at: null,
|
||||
});
|
||||
}
|
||||
} else if (event.attributes.type === NodeTypes.Workspace) {
|
||||
const userIds = await fetchWorkspaceUsers(event.workspaceId);
|
||||
|
||||
for (const userId of userIds) {
|
||||
userNodesToCreate.push({
|
||||
user_id: userId,
|
||||
node_id: event.id,
|
||||
workspace_id: event.workspaceId,
|
||||
last_seen_at: null,
|
||||
last_seen_version_id: null,
|
||||
mentions_count: 0,
|
||||
created_at: new Date(),
|
||||
access_removed_at: null,
|
||||
version_id: generateId(IdType.Version),
|
||||
updated_at: null,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
const collaborators = await fetchNodeCollaborators(event.id);
|
||||
const collaboratorIds = collaborators.map((c) => c.collaboratorId);
|
||||
|
||||
Reference in New Issue
Block a user