Skip to content

Commit

Permalink
Minor Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
R1c4rdCo5t4 committed Jun 25, 2024
1 parent af6f089 commit b1598f4
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 13 deletions.
4 changes: 2 additions & 2 deletions code/client/src/domain/editor/fugue/Fugue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export class Fugue {
* Inserts a new node in the tree based on the given operation.
* @param operation
*/
private addNode = ({id, value, line, styles, parent, side}: InsertOperation) => {
private addNode = ({ id, value, line, styles, parent, side }: InsertOperation) => {
this.tree.addNode(id, value, parent, side, styles, line);
};

Expand Down Expand Up @@ -302,7 +302,7 @@ export class Fugue {

getLineRoot = (line: number): FugueNode => {
return line === 0 ? this.tree.root : this.tree.root.value[line - 1];
}
};

/**
* Returns the string representation of the tree.
Expand Down
8 changes: 4 additions & 4 deletions code/client/src/domain/editor/fugue/FugueTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ export class FugueTree<T> {
* @param styles the styles of the node
* @param line
*/
addNode(id: Id, value: T, parent: Id, side: 'L' | 'R', styles: InlineStyle[] | undefined, line: number){
addNode(id: Id, value: T, parent: Id, side: 'L' | 'R', styles: InlineStyle[] | undefined, line: number) {
// create node
const node : Node<T> = treeNode(id, value, parent, side, 0, styles as InlineStyle[]);
if(value === '\n') {
this._root.value.splice(line, 0, node); // TODO: check if this is correct
const node: Node<T> = treeNode(id, value, parent, side, 0, styles as InlineStyle[]);
if (value === '\n') {
this._root.value.splice(line, 0, node); // TODO: check if this is correct
}
this._addNode(node);
}
Expand Down
4 changes: 2 additions & 2 deletions code/server/src/databases/memory/MemoryWorkspacesDB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ export class MemoryWorkspacesDB implements WorkspacesRepository {
return id;
}

async getWorkspaces(userId: string): Promise<WorkspaceMeta[]> {
async getWorkspaces(userId?: string): Promise<WorkspaceMeta[]> {
return Object.values(Memory.workspaces)
.filter(workspace => !workspace.isPrivate || workspace.members.includes(userId))
.filter(workspace => !workspace.isPrivate || (userId && workspace.members.includes(userId)))
.map(props => {
const workspace = omit(props, ['resources']);
return { ...workspace, members: workspace.members?.length || 0 };
Expand Down
5 changes: 3 additions & 2 deletions code/server/src/databases/postgres/PostgresWorkspacesDB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ export class PostgresWorkspacesDB implements WorkspacesRepository {
return results[0].id;
}

async getWorkspaces(userId: string): Promise<WorkspaceMeta[]> {
async getWorkspaces(userId?: string): Promise<WorkspaceMeta[]> {
const user = userId || null;
return (
await sql`
select row_to_json(t) as workspace
from (
select id, name, private, count(members) as members
from workspace
where private = false or ${userId} = any(members)
where private = false or (${user} is null or ${user} = any(members))
group by id
order by created_at desc
) as t
Expand Down
6 changes: 4 additions & 2 deletions code/server/src/databases/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,11 @@ export interface WorkspacesRepository {
*/
createWorkspace: (name: string, isPrivate: boolean) => Promise<string>;
/**
* Get all workspaces from the database that the user can access
* Get all workspaces from the database
* If userId is provided, get user workspaces
* @param userId
*/
getWorkspaces: (userId: string) => Promise<WorkspaceMeta[]>;
getWorkspaces: (userId?: string) => Promise<WorkspaceMeta[]>;
/**
* Get a workspace from the database
* @param id
Expand Down
2 changes: 1 addition & 1 deletion code/server/src/services/WorkspacesService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class WorkspacesService {
await this.databases.documents.removeWorkspace(id);
}

async getWorkspaces(userId: string): Promise<WorkspaceMeta[]> {
async getWorkspaces(userId?: string): Promise<WorkspaceMeta[]> {
return await this.databases.workspaces.getWorkspaces(userId);
}

Expand Down

0 comments on commit b1598f4

Please sign in to comment.