mirror of
https://github.com/Shadowfita/docmost.git
synced 2025-11-18 10:41:04 +10:00
Make colloboration module not dependant on page module
* add unloadImmediately to collab
This commit is contained in:
@ -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(
|
||||
|
||||
@ -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')
|
||||
|
||||
Reference in New Issue
Block a user