Skip to content

Commit be63cd3

Browse files
committed
style: 💄 run Prettier
1 parent 9a342d8 commit be63cd3

File tree

4 files changed

+22
-17
lines changed

4 files changed

+22
-17
lines changed

src/__demos__/ui-text/main.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ const main = async () => {
1616
const view = model.view();
1717
if (typeof view !== 'string') model.api.root('');
1818

19-
2019
const Demo: React.FC = () => {
2120
const [remote, setRemote] = React.useState<Model | null>(null);
2221
const ref = React.useRef<HTMLTextAreaElement | null>(null);

src/json-crdt-repo/local/level/LevelLocalRepo.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -734,12 +734,11 @@ export class LevelLocalRepo implements LocalRepo {
734734
private async _syncMerge(req: LocalRepoSyncRequest): Promise<LocalRepoSyncResponse> {
735735
const {id, patches} = req;
736736
let lastKnownTime: number = 0;
737-
const reqTime = req.time
737+
const reqTime = req.time;
738738
if (typeof reqTime === 'number') {
739739
lastKnownTime = reqTime;
740740
const firstPatch = patches?.[0];
741-
if (firstPatch?.getId()?.sid === SESSION.GLOBAL)
742-
lastKnownTime = firstPatch.getId()!.time + firstPatch.span() - 1;
741+
if (firstPatch?.getId()?.sid === SESSION.GLOBAL) lastKnownTime = firstPatch.getId()!.time + firstPatch.span() - 1;
743742
} else if (patches?.length) {
744743
const firstPatchTime = patches?.[0]?.getId()?.time;
745744
if (typeof firstPatchTime === 'number') lastKnownTime = firstPatchTime - 1;

src/json-crdt-repo/session/EditSession.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export class EditSession<N extends JsonNode = JsonNode<any>> {
9393
patches,
9494
time,
9595
cursor: this.cursor,
96-
session: this.session
96+
session: this.session,
9797
});
9898
if (this._stopped) return null;
9999
// TODO: After sync call succeeds, remove the patches from the log.
@@ -123,7 +123,7 @@ export class EditSession<N extends JsonNode = JsonNode<any>> {
123123
if (this._stopped) return;
124124
const get = await this.repo.getIf({
125125
id: this.id,
126-
cursor: this.cursor
126+
cursor: this.cursor,
127127
});
128128
if (this._stopped) return;
129129
if (!get) return;
@@ -149,11 +149,13 @@ export class EditSession<N extends JsonNode = JsonNode<any>> {
149149
public syncLog(): void {
150150
if (!this.log.patches.size()) return;
151151
this._syncRace(() => {
152-
this.sync().then((error) => {
153-
this.onsyncerror?.(error);
154-
}).catch(error => {
155-
this.onsyncerror?.(error);
156-
});
152+
this.sync()
153+
.then((error) => {
154+
this.onsyncerror?.(error);
155+
})
156+
.catch((error) => {
157+
this.onsyncerror?.(error);
158+
});
157159
});
158160
}
159161

src/json-crdt-repo/session/EditSessionFactory.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,19 @@ export class EditSessionFactory {
6161
const {model, cursor} = await (typeof timeoutMs === 'number'
6262
? timeout(timeoutMs, repo.pull(id))
6363
: repo.pull(id));
64-
if (remote.throwIf === 'exists') throw new Error('EXISTS');
65-
const session = new EditSession(repo, id, model, cursor, opts.session);
66-
session.log.end.api.autoFlush();
67-
return session;
68-
} catch (error) {
64+
if (remote.throwIf === 'exists') throw new Error('EXISTS');
65+
const session = new EditSession(repo, id, model, cursor, opts.session);
66+
session.log.end.api.autoFlush();
67+
return session;
68+
} catch (error) {
6969
if (!!error && typeof error === 'object' && (error as Record<string, unknown>).message === 'TIMEOUT') {
7070
if (!opts.make) throw error;
71-
} else if (!!error && typeof error === 'object' && ((error as Record<string, unknown>).message === 'NOT_FOUND' || (error as Record<string, unknown>).code === 'NOT_FOUND')) {
71+
} else if (
72+
!!error &&
73+
typeof error === 'object' &&
74+
((error as Record<string, unknown>).message === 'NOT_FOUND' ||
75+
(error as Record<string, unknown>).code === 'NOT_FOUND')
76+
) {
7277
if (remote.throwIf === 'missing') throw error;
7378
} else throw error;
7479
}

0 commit comments

Comments
 (0)