"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "packages/lib/services/share/ShareService.ts" between
joplin-2.1.8.tar.gz and joplin-2.1.9.tar.gz

About: Joplin is a cross-platform note taking and to-do application with synchronisation capabilities.

ShareService.ts  (joplin-2.1.8):ShareService.ts  (joplin-2.1.9)
skipping to change at line 23 skipping to change at line 23
private static instance_: ShareService; private static instance_: ShareService;
private api_: JoplinServerApi = null; private api_: JoplinServerApi = null;
private store_: Store<any> = null; private store_: Store<any> = null;
public static instance(): ShareService { public static instance(): ShareService {
if (this.instance_) return this.instance_; if (this.instance_) return this.instance_;
this.instance_ = new ShareService(); this.instance_ = new ShareService();
return this.instance_; return this.instance_;
} }
public initialize(store: Store<any>) { public initialize(store: Store<any>, api: JoplinServerApi = null) {
this.store_ = store; this.store_ = store;
this.api_ = api;
} }
public get enabled(): boolean { public get enabled(): boolean {
return [9, 10].includes(Setting.value('sync.target')); // Joplin Server, Joplin Cloud targets return [9, 10].includes(Setting.value('sync.target')); // Joplin Server, Joplin Cloud targets
} }
private get store(): Store<any> { private get store(): Store<any> {
return this.store_; return this.store_;
} }
skipping to change at line 123 skipping to change at line 124
// each sync too. // each sync too.
await Folder.updateAllShareIds(); await Folder.updateAllShareIds();
} }
public async shareNote(noteId: string): Promise<StateShare> { public async shareNote(noteId: string): Promise<StateShare> {
const note = await Note.load(noteId); const note = await Note.load(noteId);
if (!note) throw new Error(`No such note: ${noteId}`); if (!note) throw new Error(`No such note: ${noteId}`);
const share = await this.api().exec('POST', 'api/shares', {}, { n ote_id: noteId }); const share = await this.api().exec('POST', 'api/shares', {}, { n ote_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; return share;
} }
public async unshareNote(noteId: string) { public async unshareNote(noteId: string) {
const note = await Note.load(noteId); const note = await Note.load(noteId);
if (!note) throw new Error(`No such note: ${noteId}`); if (!note) throw new Error(`No such note: ${noteId}`);
const shares = await this.refreshShares(); const shares = await this.refreshShares();
const noteShares = shares.filter(s => s.note_id === noteId); const noteShares = shares.filter(s => s.note_id === noteId);
const promises: Promise<void>[] = []; const promises: Promise<void>[] = [];
for (const share of noteShares) { for (const share of noteShares) {
promises.push(this.deleteShare(share.id)); promises.push(this.deleteShare(share.id));
} }
await Promise.all(promises); 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 { public shareUrl(userId: string, share: StateShare): string {
return `${this.api().personalizedUserContentBaseUrl(userId)}/shar es/${share.id}`; return `${this.api().personalizedUserContentBaseUrl(userId)}/shar es/${share.id}`;
} }
public get shares() { public get shares() {
return this.state.shares; return this.state.shares;
} }
 End of changes. 4 change blocks. 
3 lines changed or deleted 18 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)