1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-07-16 00:14:34 +02:00

Tools: Add class member accessibility modifiers and converted rule @typescript-eslint/explicit-member-accessibility to an error

This commit is contained in:
Laurent Cozic
2023-03-06 14:22:01 +00:00
parent aa4af69afc
commit c1db7182ac
129 changed files with 1252 additions and 1296 deletions

View File

@ -6,22 +6,22 @@ class UndoQueue {
private inner_: any[] = [];
private size_: number = 20;
pop() {
public pop() {
return this.inner_.pop();
}
push(e: any) {
public push(e: any) {
this.inner_.push(e);
while (this.length > this.size_) {
this.inner_.splice(0, 1);
}
}
get length(): number {
public get length(): number {
return this.inner_.length;
}
at(index: number): any {
public at(index: number): any {
return this.inner_[index];
}
@ -35,31 +35,31 @@ export default class UndoRedoService {
private eventEmitter: any = new EventEmitter();
private isUndoing: boolean = false;
constructor() {
public constructor() {
this.push = this.push.bind(this);
}
on(eventName: string, callback: Function) {
public on(eventName: string, callback: Function) {
return this.eventEmitter.on(eventName, callback);
}
off(eventName: string, callback: Function) {
public off(eventName: string, callback: Function) {
return this.eventEmitter.removeListener(eventName, callback);
}
push(state: any) {
public push(state: any) {
this.undoStates.push(state);
this.redoStates = new UndoQueue();
this.eventEmitter.emit('stackChange');
}
schedulePush(state: any) {
public schedulePush(state: any) {
this.pushAsyncQueue.push(async () => {
this.push(state);
});
}
async undo(redoState: any) {
public async undo(redoState: any) {
if (this.isUndoing) return;
if (!this.canUndo) throw new Error('Nothing to undo');
this.isUndoing = true;
@ -71,7 +71,7 @@ export default class UndoRedoService {
return state;
}
async redo(undoState: any) {
public async redo(undoState: any) {
if (this.isUndoing) return;
if (!this.canRedo) throw new Error('Nothing to redo');
this.isUndoing = true;
@ -83,7 +83,7 @@ export default class UndoRedoService {
return state;
}
async reset() {
public async reset() {
this.undoStates = new UndoQueue();
this.redoStates = new UndoQueue();
this.isUndoing = false;
@ -92,11 +92,11 @@ export default class UndoRedoService {
return output;
}
get canUndo(): boolean {
public get canUndo(): boolean {
return !!this.undoStates.length;
}
get canRedo(): boolean {
public get canRedo(): boolean {
return !!this.redoStates.length;
}