feat: add uid to comment and draw
This commit is contained in:
parent
bd5c672b30
commit
cd48997dbd
@ -24,6 +24,7 @@ export enum DrawToolDto {
|
||||
}
|
||||
|
||||
export interface ObjDrawDto {
|
||||
id: string;
|
||||
data: ObjDrawDataDto[];
|
||||
size: ObjSizeDto;
|
||||
createdAt: number;
|
||||
|
@ -19,7 +19,7 @@ import { ObjSnapshotDto } from './obj-snapshot.dto';
|
||||
|
||||
export interface ObjCommentDto {
|
||||
value: string;
|
||||
id?: string;
|
||||
id: string;
|
||||
createdAt: number;
|
||||
updatedAt: number;
|
||||
}
|
||||
@ -28,10 +28,14 @@ export interface ObjCommentListDto {
|
||||
data: ObjCommentDto[];
|
||||
}
|
||||
|
||||
export interface ObjDrawListDto {
|
||||
data: ObjDrawDto[];
|
||||
}
|
||||
|
||||
export interface ObjPageDto {
|
||||
snapshot: ObjSnapshotDto;
|
||||
comments: ObjCommentListDto;
|
||||
draw: ObjDrawDto[];
|
||||
draw: ObjDrawListDto;
|
||||
}
|
||||
|
||||
export interface ObjPagePinDto extends ObjPageDto {
|
||||
|
@ -31,7 +31,7 @@ export enum ServerPathDto {
|
||||
export interface ServerChangeDto {
|
||||
id?: number;
|
||||
path: ServerPathDto;
|
||||
type: 'download' | 'upload';
|
||||
type: 'download' | 'upload' | 'remove';
|
||||
}
|
||||
|
||||
export interface ServerObjDto {
|
||||
|
@ -24,6 +24,7 @@ import { PinModel } from '../pin.model';
|
||||
import { PinUpdateCommand } from '../../../common/command/pin/pin-update.command';
|
||||
import { applyStylesToElement } from '../../../common/style.utils';
|
||||
import { fnConsoleLog } from '../../../common/fn/console.fn';
|
||||
import { fnUid } from '../../../common/fn/uid.fn';
|
||||
|
||||
const canvasStyles = {
|
||||
position: 'absolute',
|
||||
@ -251,6 +252,7 @@ no javascript enabled - drawing not working</h1>`;
|
||||
if (this.model.drawData.length === 0) {
|
||||
const dt = Date.now();
|
||||
this.model.drawData.push({
|
||||
id: fnUid(),
|
||||
data: this.drawData,
|
||||
size: {
|
||||
width: this.rasterCanvas.width,
|
||||
|
@ -89,7 +89,7 @@ export class PinModel {
|
||||
}
|
||||
|
||||
get drawData(): ObjDrawDto[] {
|
||||
return this.obj.data.draw;
|
||||
return this.obj.data.draw.data;
|
||||
}
|
||||
|
||||
get canvas(): ObjCanvasDto | undefined {
|
||||
|
@ -21,6 +21,7 @@ import { PinUpdateCommand } from '../../../common/command/pin/pin-update.command
|
||||
import { TextCommentEditorComponent } from './text-comment-editor.component';
|
||||
import { TextCommentListComponent } from './text-comment-list.component';
|
||||
import { applyStylesToElement } from '../../../common/style.utils';
|
||||
import { fnUid } from '../../../common/fn/uid.fn';
|
||||
|
||||
const elStyles = {
|
||||
'min-height': '40px',
|
||||
@ -79,7 +80,7 @@ export class TextContainerComponent implements HtmlComponent<HTMLElement> {
|
||||
await new ObjAddHashtagsCommand(this.model.id, value).execute();
|
||||
const dt = Date.now();
|
||||
|
||||
this.model.comments.data.push({ value, createdAt: dt, updatedAt: dt });
|
||||
this.model.comments.data.push({ id: fnUid(), value, createdAt: dt, updatedAt: dt });
|
||||
|
||||
await new PinUpdateCommand(this.model.object).execute();
|
||||
this.reloadComments();
|
||||
|
@ -28,7 +28,9 @@ export class PinFactory {
|
||||
comments: {
|
||||
data: []
|
||||
},
|
||||
draw: []
|
||||
draw: {
|
||||
data: []
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -31,8 +31,6 @@ export class SyncServerCommand implements ICommand<Promise<void>> {
|
||||
private static isInSync = false;
|
||||
|
||||
async execute(): Promise<void> {
|
||||
if (SyncServerCommand.isInSync) return;
|
||||
|
||||
if (!(await this.shouldSync())) return;
|
||||
try {
|
||||
SyncServerCommand.isInSync = true;
|
||||
@ -63,6 +61,7 @@ export class SyncServerCommand implements ICommand<Promise<void>> {
|
||||
}
|
||||
|
||||
private async shouldSync(): Promise<boolean> {
|
||||
if (SyncServerCommand.isInSync) return false;
|
||||
const interval = (await BrowserStorageWrapper.get<number | undefined>(ObjectStoreKeys.SYNC_INTERVAL)) || 0;
|
||||
fnConsoleLog('SyncServerCommand->shouldSync', Date.now() - interval);
|
||||
if (Date.now() - interval > 5_000) {
|
||||
|
@ -33,7 +33,7 @@ export class SyncSendChangesCommand implements ICommand<Promise<void>> {
|
||||
switch (changes[0].path) {
|
||||
case ServerPathDto.HASHTAGS:
|
||||
case ServerPathDto.WORDS:
|
||||
case ServerPathDto.COMMENTS:
|
||||
case ServerPathDto.COMMENT:
|
||||
case ServerPathDto.DRAW:
|
||||
case ServerPathDto.NOTE:
|
||||
case ServerPathDto.PIN:
|
||||
|
Loading…
Reference in New Issue
Block a user