Skip to content

Commit

Permalink
named export
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Jun 12, 2020
1 parent a7022b1 commit cb0bfd9
Showing 1 changed file with 38 additions and 38 deletions.
76 changes: 38 additions & 38 deletions lib/ui/progress.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
}

0 comments on commit cb0bfd9

Please sign in to comment.