Skip to content

Commit

Permalink
fix: validation and misc improvements/fixes for always-count-as-active
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikBjare committed Oct 17, 2022
1 parent 4a9de96 commit c71e434
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 41 deletions.
65 changes: 65 additions & 0 deletions src/views/settings/ActivePatternSettings.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<template lang="pug">
div
div.d-sm-flex.justify-content-between
div
h5.mb-2.mb-sm-0 Always count as active pattern

small
| Apps or titles matching this regular expression will never be counted as AFK.
|
| Can be used to count time as active, despite no input (like meetings, or games with controllers). An empty string disables it.
|
| Example expression:&nbsp;
code(style="background-color: rgba(200, 200, 200, 0.3); padding: 2px; border-radius: 2px;")
| Zoom Meeting|Google Meet|Microsoft Teams
div
b-form-input(size="sm" v-model="always_active_pattern")
small.text-right
div(v-if="enabled" style="color: #0A0") Enabled
div(v-else, style="color: gray") Disabled
div(v-if="enabled && broad_pattern" style="color: #A00") Pattern too broad

</template>

<script>
import { useSettingsStore } from '~/stores/settings';
export default {
name: 'ActivePatternSettings',
data() {
return {
settingsStore: useSettingsStore(),
};
},
computed: {
enabled: function () {
return this.settingsStore.always_active_pattern != '';
},
broad_pattern: function () {
// Check if the pattern matches random strings that we don't expect it to
// like the alphabet
const pattern = this.settingsStore.always_active_pattern;
if (pattern == '') {
return false;
}
const re = new RegExp(pattern);
const alphabet = 'abcdefghijklmnopqrstuvwxyz';
const numbers = '0123456789';
return re.test(
'THIS STRING SHOULD PROBABLY NOT MATCH: ' + alphabet + alphabet.toUpperCase() + numbers
);
},
always_active_pattern: {
get() {
return this.settingsStore.always_active_pattern;
},
set(value) {
if (value.trim().length != 0 || this.settingsStore.always_active_pattern.length != 0) {
console.log('Setting always_active_pattern to ' + value);
this.settingsStore.update({ always_active_pattern: value });
}
},
},
},
};
</script>
37 changes: 0 additions & 37 deletions src/views/settings/NeverAfkFilterSettings.vue

This file was deleted.

8 changes: 4 additions & 4 deletions src/views/settings/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ div
ColorSettings

hr
NeverAfkFilterSettings

ActivePatternSettings

hr

Expand All @@ -52,7 +52,7 @@ import LandingPageSettings from '~/views/settings/LandingPageSettings.vue';
import DeveloperSettings from '~/views/settings/DeveloperSettings.vue';
import Theme from '~/views/settings/Theme.vue';
import ColorSettings from '~/views/settings/ColorSettings.vue';
import NeverAfkFilterSettings from '~/views/settings/NeverAfkFilterSettings.vue';
import ActivePatternSettings from '~/views/settings/ActivePatternSettings.vue';
export default {
name: 'Settings',
Expand All @@ -65,7 +65,7 @@ export default {
Theme,
ColorSettings,
DeveloperSettings,
NeverAfkFilterSettings,
ActivePatternSettings,
},
async created() {
await this.init();
Expand Down

1 comment on commit c71e434

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here are screenshots of this commit:

Screenshots using aw-server v0.12.0 (click to expand)

Screenshots using aw-server-rust v0.12.0 (click to expand)

CML watermark

Please sign in to comment.