Skip to content

Commit

Permalink
refactor: small improvement to history factory
Browse files Browse the repository at this point in the history
  • Loading branch information
diegopvlk committed Jan 2, 2025
1 parent 00dee4c commit 480e3ba
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 23 deletions.
12 changes: 2 additions & 10 deletions data/styles/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -300,21 +300,13 @@ button.time-group-selection:hover {
border-top-left-radius: 0;
border-bottom-left-radius: 0;
padding-left: 4px;
margin-left: -4px;
}
.badge-icon:dir(rtl) {
border-top-right-radius: 0;
border-bottom-right-radius: 0;
padding-right: 4px;
}
.badge-end-border:dir(ltr) {
border-top-right-radius: 0;
border-bottom-right-radius: 0;
padding-right: 4px;
}
.badge-end-border:dir(rtl) {
border-top-left-radius: 0;
border-bottom-left-radius: 0;
padding-left: 4px;
margin-right: -4px;
}

.empty-history,
Expand Down
18 changes: 5 additions & 13 deletions src/historyFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,19 +161,11 @@ historyItemFactory.connect('bind', (factory, listItem) => {
nameLabel.label = item.name;
doseLabel.label = `${item.dose} ${item.unit} • ${time}`;

if (item.taken[1] === 1) {
takenLabel.label = `${timeTaken}`;
takenIcon.set_visible(true);
takenLabel.add_css_class('badge-end-border');
} else if (item.taken[1] === 0) {
takenLabel.label = _('Skipped');
takenIcon.set_visible(false);
takenLabel.remove_css_class('badge-end-border');
} else if (item.taken[1] === -1) {
takenLabel.label = _('Missed');
takenIcon.set_visible(false);
takenLabel.remove_css_class('badge-end-border');
}
takenIcon.set_visible(item.taken[1] === 1);

if (item.taken[1] === 1) takenLabel.label = `${timeTaken}`;
else if (item.taken[1] === 0) takenLabel.label = _('Skipped');
else if (item.taken[1] === -1) takenLabel.label = _('Missed');

box.set_css_classes(['item-box', item.color]);
});

0 comments on commit 480e3ba

Please sign in to comment.