Skip to content

Commit

Permalink
style: show first snackbar of a certain message for longer
Browse files Browse the repository at this point in the history
Part of #16.

The rationale is that repeated notifications of the same type (like "Practice set recorded.") don't need to be visible for that long. But the first one should be visible for longer.
  • Loading branch information
arxanas committed May 4, 2020
1 parent a7ddec4 commit d1ea3cd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 13 additions & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
</v-container>
</v-content>

<v-snackbar v-model="snackbarEnabled" :timeout="1000">
<v-snackbar v-model="snackbarEnabled" :timeout="timeout">
{{ snackbarText }}
<v-btn color="blue" text @click="snackbarEnabled = false">
Close
Expand All @@ -98,11 +98,16 @@ import {
readSnackbarText,
} from "./store";
const SMALL_TIMEOUT = 1250;
const LARGE_TIMEOUT = 3000;
@Component({ name: "App" })
export default class extends Vue {
private snackbarEnabled: boolean = false;
private snackbarText: string = "";
private drawer: boolean = false;
private seenSnackbarTexts: { [x in string]: boolean } = {};
private timeout: number = SMALL_TIMEOUT;
public created() {
this.$watch(() => this.snackbarEnabled, function(snackbarEnabled) {
Expand All @@ -114,6 +119,13 @@ export default class extends Vue {
if (snackbarText !== null) {
this.snackbarEnabled = true;
this.snackbarText = snackbarText;
if (this.seenSnackbarTexts[snackbarText]) {
this.timeout = SMALL_TIMEOUT;
} else {
this.timeout = LARGE_TIMEOUT;
}
this.seenSnackbarTexts[snackbarText] = true;
} else {
this.snackbarEnabled = false;
this.snackbarText = "";
Expand Down
2 changes: 1 addition & 1 deletion src/views/Training.vue
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ export default class extends Vue {
practiceSet,
});
await dispatchSaveState(this.$store);
commitSnackbarText(this.$store, "Practice set recorded");
commitSnackbarText(this.$store, "Practice set recorded.");
}
}
Expand Down

0 comments on commit d1ea3cd

Please sign in to comment.