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

All: Ensure that timestamps are not changed when sharing or unsharing a note

This commit is contained in:
Laurent Cozic
2021-07-19 10:27:43 +01:00
parent b2de27b6fc
commit cafaa9cac5
4 changed files with 90 additions and 3 deletions

View File

@ -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 {