mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
Merge branch 'release-2.1' into dev
This commit is contained in:
commit
d469ac174c
@ -1416,6 +1416,9 @@ packages/lib/services/searchengine/queryBuilder.js.map
|
||||
packages/lib/services/share/ShareService.d.ts
|
||||
packages/lib/services/share/ShareService.js
|
||||
packages/lib/services/share/ShareService.js.map
|
||||
packages/lib/services/share/ShareService.test.d.ts
|
||||
packages/lib/services/share/ShareService.test.js
|
||||
packages/lib/services/share/ShareService.test.js.map
|
||||
packages/lib/services/share/reducer.d.ts
|
||||
packages/lib/services/share/reducer.js
|
||||
packages/lib/services/share/reducer.js.map
|
||||
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -1401,6 +1401,9 @@ packages/lib/services/searchengine/queryBuilder.js.map
|
||||
packages/lib/services/share/ShareService.d.ts
|
||||
packages/lib/services/share/ShareService.js
|
||||
packages/lib/services/share/ShareService.js.map
|
||||
packages/lib/services/share/ShareService.test.d.ts
|
||||
packages/lib/services/share/ShareService.test.js
|
||||
packages/lib/services/share/ShareService.test.js.map
|
||||
packages/lib/services/share/reducer.d.ts
|
||||
packages/lib/services/share/reducer.js
|
||||
packages/lib/services/share/reducer.js.map
|
||||
|
@ -40,6 +40,17 @@ class ClipperConfigScreenComponent extends React.Component {
|
||||
alert(_('Token has been copied to the clipboard!'));
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps) {
|
||||
if (prevProps.needApiAuth !== this.props.needApiAuth && this.props.needApiAuth) {
|
||||
// Ideally when API auth is needed, we should display the
|
||||
// notification in this screen, however it's not setup for it yet.
|
||||
// So instead, we just go back to the main screen where the
|
||||
// notification will be displayed.
|
||||
// https://discourse.joplinapp.org/t/web-clipper-2-1-3-not-working/18582/27
|
||||
this.props.dispatch({ type: 'NAV_BACK' });
|
||||
}
|
||||
}
|
||||
|
||||
renewToken_click() {
|
||||
if (confirm(_('Are you sure you want to renew the authorisation token?'))) {
|
||||
void EncryptionService.instance()
|
||||
@ -171,6 +182,7 @@ const mapStateToProps = state => {
|
||||
clipperServer: state.clipperServer,
|
||||
clipperServerAutoStart: state.settings['clipperServer.autoStart'],
|
||||
apiToken: state.settings['api.token'],
|
||||
needApiAuth: state.needApiAuth,
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -505,7 +505,7 @@
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CODE_SIGN_ENTITLEMENTS = Joplin/Joplin.entitlements;
|
||||
CURRENT_PROJECT_VERSION = 69;
|
||||
CURRENT_PROJECT_VERSION = 70;
|
||||
DEVELOPMENT_TEAM = A9BXAFS6CT;
|
||||
ENABLE_BITCODE = NO;
|
||||
INFOPLIST_FILE = Joplin/Info.plist;
|
||||
@ -533,7 +533,7 @@
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CODE_SIGN_ENTITLEMENTS = Joplin/Joplin.entitlements;
|
||||
CURRENT_PROJECT_VERSION = 69;
|
||||
CURRENT_PROJECT_VERSION = 70;
|
||||
DEVELOPMENT_TEAM = A9BXAFS6CT;
|
||||
INFOPLIST_FILE = Joplin/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
|
||||
@ -678,7 +678,7 @@
|
||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||
CODE_SIGN_ENTITLEMENTS = ShareExtension/ShareExtension.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 69;
|
||||
CURRENT_PROJECT_VERSION = 70;
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
DEVELOPMENT_TEAM = A9BXAFS6CT;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||
@ -709,7 +709,7 @@
|
||||
CODE_SIGN_ENTITLEMENTS = ShareExtension/ShareExtension.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
CURRENT_PROJECT_VERSION = 69;
|
||||
CURRENT_PROJECT_VERSION = 70;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
DEVELOPMENT_TEAM = A9BXAFS6CT;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||
|
@ -132,6 +132,8 @@ export default class Api {
|
||||
}
|
||||
|
||||
public acceptAuthToken(accept: boolean) {
|
||||
if (!this.authToken_) throw new Error('Auth token is not set');
|
||||
|
||||
this.authToken_.status = accept ? AuthTokenStatus.Accepted : AuthTokenStatus.Rejected;
|
||||
|
||||
this.dispatch_({
|
||||
|
@ -19,7 +19,7 @@ export default async function(request: Request, id: string = null, _link: string
|
||||
if (request.method === 'GET') {
|
||||
if (id === 'check') {
|
||||
if ('auth_token' in request.query) {
|
||||
if (request.query.auth_token === context.authToken.value) {
|
||||
if (context.authToken && request.query.auth_token === context.authToken.value) {
|
||||
const output: any = {
|
||||
status: context.authToken.status,
|
||||
};
|
||||
|
66
packages/lib/services/share/ShareService.test.ts
Normal file
66
packages/lib/services/share/ShareService.test.ts
Normal file
@ -0,0 +1,66 @@
|
||||
import Note from '../../models/Note';
|
||||
import { msleep, setupDatabaseAndSynchronizer, switchClient } from '../../testing/test-utils';
|
||||
import ShareService from './ShareService';
|
||||
import reducer from '../../reducer';
|
||||
import { createStore } from 'redux';
|
||||
import { NoteEntity } from '../database/types';
|
||||
|
||||
function mockApi() {
|
||||
return {
|
||||
exec: (method: string, path: string = '', _query: Record<string, any> = null, _body: any = null, _headers: any = null, _options: any = null): Promise<any> => {
|
||||
if (method === 'GET' && path === 'api/shares') return { items: [] } as any;
|
||||
return null;
|
||||
},
|
||||
personalizedUserContentBaseUrl(_userId: string) {
|
||||
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function mockService() {
|
||||
const service = new ShareService();
|
||||
const store = createStore(reducer as any);
|
||||
service.initialize(store, mockApi() as any);
|
||||
return service;
|
||||
}
|
||||
|
||||
describe('ShareService', function() {
|
||||
|
||||
beforeEach(async (done) => {
|
||||
await setupDatabaseAndSynchronizer(1);
|
||||
await switchClient(1);
|
||||
done();
|
||||
});
|
||||
|
||||
it('should not change the note user timestamps when sharing or unsharing', (async () => {
|
||||
let note = await Note.save({});
|
||||
const service = mockService();
|
||||
await msleep(1);
|
||||
await service.shareNote(note.id);
|
||||
|
||||
function checkTimestamps(previousNote: NoteEntity, newNote: NoteEntity) {
|
||||
// After sharing or unsharing, only the updated_time property should
|
||||
// be updated, for sync purposes. All other timestamps shouldn't
|
||||
// change.
|
||||
expect(previousNote.user_created_time).toBe(newNote.user_created_time);
|
||||
expect(previousNote.user_updated_time).toBe(newNote.user_updated_time);
|
||||
expect(previousNote.updated_time < newNote.updated_time).toBe(true);
|
||||
expect(previousNote.created_time).toBe(newNote.created_time);
|
||||
}
|
||||
|
||||
{
|
||||
const noteReloaded = await Note.load(note.id);
|
||||
checkTimestamps(note, noteReloaded);
|
||||
note = noteReloaded;
|
||||
}
|
||||
|
||||
await msleep(1);
|
||||
await service.unshareNote(note.id);
|
||||
|
||||
{
|
||||
const noteReloaded = await Note.load(note.id);
|
||||
checkTimestamps(note, noteReloaded);
|
||||
}
|
||||
}));
|
||||
|
||||
});
|
@ -20,8 +20,9 @@ export default class ShareService {
|
||||
return this.instance_;
|
||||
}
|
||||
|
||||
public initialize(store: Store<any>) {
|
||||
public initialize(store: Store<any>, api: JoplinServerApi = null) {
|
||||
this.store_ = store;
|
||||
this.api_ = api;
|
||||
}
|
||||
|
||||
public get enabled(): boolean {
|
||||
@ -120,7 +121,14 @@ export default class ShareService {
|
||||
|
||||
const share = await this.api().exec('POST', 'api/shares', {}, { note_id: noteId });
|
||||
|
||||
await Note.save({ id: note.id, is_shared: 1 });
|
||||
await Note.save({
|
||||
id: note.id,
|
||||
parent_id: note.parent_id,
|
||||
is_shared: 1,
|
||||
updated_time: Date.now(),
|
||||
}, {
|
||||
autoTimestamp: false,
|
||||
});
|
||||
|
||||
return share;
|
||||
}
|
||||
@ -140,7 +148,14 @@ export default class ShareService {
|
||||
|
||||
await Promise.all(promises);
|
||||
|
||||
await Note.save({ id: note.id, is_shared: 0 });
|
||||
await Note.save({
|
||||
id: note.id,
|
||||
parent_id: note.parent_id,
|
||||
is_shared: 0,
|
||||
updated_time: Date.now(),
|
||||
}, {
|
||||
autoTimestamp: false,
|
||||
});
|
||||
}
|
||||
|
||||
public shareUrl(userId: string, share: StateShare): string {
|
||||
|
Loading…
Reference in New Issue
Block a user