Skip to content

Commit

Permalink
Merge branch 'dev' into spell-check
Browse files Browse the repository at this point in the history
  • Loading branch information
dhakarRaghu authored Nov 14, 2024
2 parents 26d3a9e + 11b3347 commit 3a49e64
Show file tree
Hide file tree
Showing 15 changed files with 1,972 additions and 1,386 deletions.
6 changes: 4 additions & 2 deletions packages/app-desktop/gui/NoteEditor/utils/useDropHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useCallback } from 'react';
import Note from '@joplin/lib/models/Note';
import { DragEvent as ReactDragEvent } from 'react';
import { DropCommandValue } from './types';
import { webUtils } from 'electron';

interface HookDependencies {
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
Expand Down Expand Up @@ -56,8 +57,9 @@ export default function useDropHandler(dependencies: HookDependencies): DropHand
const paths = [];
for (let i = 0; i < files.length; i++) {
const file = files[i];
if (!file.path) continue;
paths.push(file.path);
const path = webUtils.getPathForFile(file);
if (!path) continue;
paths.push(path);
}

const props: DropCommandValue = {
Expand Down
11 changes: 8 additions & 3 deletions packages/app-desktop/integration-tests/models/MainScreen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,14 @@ export default class MainScreen {
public async createNewNote(title: string) {
await this.waitFor();

await this.newNoteButton.click();
await expect(this.noteEditor.noteTitleInput).toHaveValue('');
await expect(this.noteEditor.noteTitleInput).toHaveJSProperty('placeholder', 'Creating new note...');
// Create the new note. Retry this -- creating new notes can sometimes fail if done just after
// application startup.
await expect.poll(async () => {
await this.newNoteButton.click();
await expect(this.noteEditor.noteTitleInput).toHaveValue('', { timeout: 4_000 });
await expect(this.noteEditor.noteTitleInput).toHaveJSProperty('placeholder', 'Creating new note...', { timeout: 4_000 });
return true;
}, { timeout: 10_000 }).toBe(true);

// Fill the title
await this.noteEditor.noteTitleInput.click();
Expand Down
1 change: 0 additions & 1 deletion packages/app-mobile/components/screens/Note.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ class NoteScreenComponent extends BaseScreenComponent<Props, State> implements B
Keyboard.dismiss();

this.setState({
note: { ...this.state.lastSavedNote },
mode: 'view',
});

Expand Down
2 changes: 1 addition & 1 deletion packages/app-mobile/pluginAssets/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/app-mobile/pluginAssets/index.web.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion packages/lib/Synchronizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ export default class Synchronizer {
public lockHandler() {
if (this.lockHandler_) return this.lockHandler_;
this.lockHandler_ = new LockHandler(this.api());
this.lockHandler_.enabled = Setting.value('featureFlag.syncLockEnabled');
return this.lockHandler_;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/lib/components/shared/note-screen-shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ shared.saveNoteButton_press = async function(comp: BaseNoteScreenComponent, fold

// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
const newState: any = {
lastSavedNote: { ...note },
lastSavedNote: { ...note, ...savedNote },
note: note,
};

Expand Down
11 changes: 0 additions & 11 deletions packages/lib/models/settings/builtInMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1610,17 +1610,6 @@ const builtInMetadata = (Setting: typeof SettingType) => {
isGlobal: true,
},

'featureFlag.syncLockEnabled': {
value: true,
type: SettingItemType.Bool,
public: true,
storage: SettingStorage.File,
label: () => 'Enable sync locks',
description: () => 'This is an experimental setting to disable sync locks',
section: 'sync',
isGlobal: true,
},

'featureFlag.linuxKeychain': {
value: false,
type: SettingItemType.Bool,
Expand Down
18 changes: 17 additions & 1 deletion packages/lib/services/synchronizer/LockHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export default class LockHandler {
private refreshTimers_: RefreshTimers = {};
private autoRefreshInterval_: number = 1000 * 60;
private lockTtl_: number = defaultLockTtl;
private enabled_ = true;
private enabled_ = false;

public constructor(api: FileApi, options: LockHandlerOptions = null) {
if (!options) options = {};
Expand Down Expand Up @@ -206,6 +206,8 @@ export default class LockHandler {
public async locks(lockType: LockType = null): Promise<Lock[]> {
if (!this.enabled) return [];

if (this.enabled) throw new Error('Lock handler is enabled');

if (this.useBuiltInLocks) {
const locks = (await this.api_.listLocks()).items;
return locks;
Expand All @@ -227,6 +229,8 @@ export default class LockHandler {
}

private async saveLock(lock: Lock) {
if (!this.enabled) return;
if (this.enabled) throw new Error('Lock handler is enabled');
await this.api_.put(this.lockFilePath(lock), JSON.stringify(lock));
}

Expand Down Expand Up @@ -285,6 +289,10 @@ export default class LockHandler {
}

private async acquireExclusiveLock(clientType: LockClientType, clientId: string, options: AcquireLockOptions = null): Promise<Lock> {
if (!this.enabled) return nullLock();

if (this.enabled) throw new Error('Lock handler is enabled');

if (this.useBuiltInLocks) return this.api_.acquireLock(LockType.Exclusive, clientType, clientId);

// The logic to acquire an exclusive lock, while avoiding race conditions is as follow:
Expand Down Expand Up @@ -375,6 +383,8 @@ export default class LockHandler {
public startAutoLockRefresh(lock: Lock, errorHandler: Function): string {
if (!this.enabled) return '';

if (this.enabled) throw new Error('Lock handler is enabled');

const handle = this.autoLockRefreshHandle(lock);
if (this.refreshTimers_[handle]) {
throw new Error(`There is already a timer refreshing this lock: ${handle}`);
Expand Down Expand Up @@ -434,6 +444,8 @@ export default class LockHandler {
public stopAutoLockRefresh(lock: Lock) {
if (!this.enabled) return;

if (this.enabled) throw new Error('Lock handler is enabled');

const handle = this.autoLockRefreshHandle(lock);
if (!this.refreshTimers_[handle]) {
// Should not throw an error because lock may have been cleared in startAutoLockRefresh
Expand All @@ -449,6 +461,8 @@ export default class LockHandler {
public async acquireLock(lockType: LockType, clientType: LockClientType, clientId: string, options: AcquireLockOptions = null): Promise<Lock> {
if (!this.enabled) return nullLock();

if (this.enabled) throw new Error('Lock handler is enabled');

options = {
...defaultAcquireLockOptions(),
...options,
Expand All @@ -466,6 +480,8 @@ export default class LockHandler {
public async releaseLock(lockType: LockType, clientType: LockClientType, clientId: string) {
if (!this.enabled) return;

if (this.enabled) throw new Error('Lock handler is enabled');

if (this.useBuiltInLocks) {
await this.api_.releaseLock(lockType, clientType, clientId);
return;
Expand Down
Loading

0 comments on commit 3a49e64

Please sign in to comment.