From cb0bfd9fbc5a74a47e672c074163f0e10baab6af Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Thu, 11 Jun 2020 20:17:15 -0500 Subject: [PATCH] named export --- lib/ui/progress.js | 76 +++++++++++++++++++++++----------------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/lib/ui/progress.js b/lib/ui/progress.js index beda3f13..07cb5e40 100644 --- a/lib/ui/progress.js +++ b/lib/ui/progress.js @@ -3,49 +3,50 @@ import { CompositeDisposable } from 'atom'; import client from '../connection/client'; import { formatTimePeriod } from '../misc'; -export default { - progs: {}, +export let progs = {} - activate(ink) { - this.subs = new CompositeDisposable; - this.ink = ink; +let subs; +let ink; +export function activate(ink_in) { + subs = new CompositeDisposable; + ink = ink_in; client.handle({'progress': (t, id, m) => this[t](id, m)}); let status = []; - this.subs.add( + subs.add( client.onWorking(() => { - return status = this.ink.progress.add(null, {description: 'Julia'}); + return status = ink.progress.add(null, {description: 'Julia'}); }), client.onDone(() => (status != null ? status.destroy() : undefined)), // status?.destroy() - client.onAttached(() => this.ink.progress.show()), - client.onDetached(() => this.clear()) + client.onAttached(() => ink.progress.show()), + client.onDetached(() => clear()) ); - }, +} - deactivate() { - this.clear(); - this.subs.dispose(); - }, +export function deactivate() { + clear(); + subs.dispose(); +} - add(id) { - const pr = this.ink.progress.add(); +export function add(id) { + const pr = ink.progress.add(); pr.t0 = Date.now(); pr.showTime = true; - this.progs[id] = pr; - }, + progs[id] = pr; +} - progress(id, prog) { - const pr = this.progs[id]; +export function progress(id, prog) { + const pr = progs[id]; if (pr == null) { return; } pr.level = prog; - if (pr.showTime) { return this.rightText(id, null); } - }, + if (pr.showTime) { return rightText(id, null); } +} - message(id, m) { return (this.progs[id] != null ? this.progs[id].message = m : undefined); }, // this.progs[id]?.message = m +export function message(id, m) { return (progs[id] != null ? progs[id].message = m : undefined); }, // progs[id]?.message = m - leftText(id, m) { return (this.progs[id] != null ? this.progs[id].description = m : undefined); }, // this.progs[id]?.description = m +export function leftText(id, m) { return (progs[id] != null ? progs[id].description = m : undefined); }, // progs[id]?.description = m - rightText(id, m) { - const pr = this.progs[id]; +export function rightText(id, m) { + const pr = progs[id]; if (pr == null) { return; } if (m != null ? m.length : undefined) { pr.rightText = m; @@ -55,23 +56,22 @@ export default { pr.showTime = true; return pr.rightText = formatTimePeriod(dt); } - }, +} - delete(id) { - const pr = this.progs[id]; +export function deleteit(id) { + const pr = progs[id]; if (pr == null) { return; } pr.destroy(); - delete this.progs[id]; - }, + delete progs[id]; +} - clear() { - for (let _ in this.progs) { - const p = this.progs[_]; +export function clear() { + for (let _ in progs) { + const p = progs[_]; if (p != null) { p.destroy(); } } - this.progs = {}; - this.ink.progress.hide(); - } -}; + progs = {}; + ink.progress.hide(); +}