Make colloboration module not dependant on page module

* add unloadImmediately to collab
This commit is contained in:
Philipinho
2024-04-22 23:40:50 +01:00
parent f65e5c872b
commit 6a57e3edb2
7 changed files with 41 additions and 55 deletions

View File

@ -1,4 +1,4 @@
import { BadRequestException, Injectable } from '@nestjs/common';
import { Injectable } from '@nestjs/common';
import { PageHistoryRepo } from '@docmost/db/repos/page/page-history.repo';
import { Page, PageHistory } from '@docmost/db/types/entity.types';
import { PaginationOptions } from '@docmost/db/pagination/pagination-options';
@ -9,26 +9,7 @@ export class PageHistoryService {
constructor(private pageHistoryRepo: PageHistoryRepo) {}
async findById(historyId: string): Promise<PageHistory> {
const history = await this.pageHistoryRepo.findById(historyId);
if (!history) {
throw new BadRequestException('History not found');
}
return history;
}
async saveHistory(page: Page): Promise<void> {
await this.pageHistoryRepo.insertPageHistory({
pageId: page.id,
title: page.title,
content: page.content,
slug: page.slug,
icon: page.icon,
version: 1, // TODO: make incremental
coverPhoto: page.coverPhoto,
lastUpdatedById: page.lastUpdatedById ?? page.creatorId,
spaceId: page.spaceId,
workspaceId: page.workspaceId,
});
return await this.pageHistoryRepo.findById(historyId);
}
async findHistoryByPageId(

View File

@ -117,24 +117,6 @@ export class PageService {
return await this.pageRepo.findById(pageId);
}
async updateState(
pageId: string,
content: any,
textContent: string,
ydoc: any,
userId?: string, // TODO: fix this
): Promise<void> {
await this.pageRepo.updatePage(
{
content: content,
textContent: textContent,
ydoc: ydoc,
...(userId && { lastUpdatedById: userId }),
},
pageId,
);
}
withHasChildren(eb: ExpressionBuilder<DB, 'pages'>) {
return eb
.selectFrom('pages as child')