Skip to content

Commit 3ae4060

Browse files
authored
refactor: converted the remaining components to typescript (#558)
1 parent 855f06e commit 3ae4060

23 files changed

+37
-35
lines changed

src/components/CategoryEditModal.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ b-modal(id="edit" ref="edit" title="Edit category" @show="resetModal" @hidden="h
3434
| Inherit parent color
3535
div.mt-1(v-show="!editing.inherit_color")
3636
color-picker(v-model="editing.color")
37-
37+
3838
hr
3939
div.my-1
4040
b Productivity score
@@ -50,9 +50,9 @@ b-modal(id="edit" ref="edit" title="Edit category" @show="resetModal" @hidden="h
5050
| Remove category
5151
</template>
5252

53-
<script>
53+
<script lang="ts">
5454
import _ from 'lodash';
55-
import ColorPicker from '~/components/ColorPicker';
55+
import ColorPicker from '~/components/ColorPicker.vue';
5656
import { useCategoryStore } from '~/stores/categories';
5757
import { mapState } from 'pinia';
5858
import { validateRegex, isRegexBroad } from '~/util/validate';

src/components/CategoryEditTree.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ div
3131
CategoryEditModal(:categoryId='editingId', @hidden="hideEditModal()")
3232
</template>
3333

34-
<script>
34+
<script lang="ts">
3535
import 'vue-awesome/icons/regular/plus-square';
3636
import 'vue-awesome/icons/regular/minus-square';
3737
import 'vue-awesome/icons/circle';

src/components/ColorPicker.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ div
3232
}
3333
</style>
3434

35-
<script>
35+
<script lang="ts">
3636
// Based on https://codepen.io/Brownsugar/pen/NaGPKy
3737
import 'vue-awesome/icons/sync';
3838

src/components/DevOnly.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ div(v-if="show", style="border: 1px solid #aaa; border-radius: 5px")
88
slot
99
</template>
1010

11-
<script>
11+
<script lang="ts">
1212
export default {
1313
props: {
1414
note: {

src/components/ErrorBoundary.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ div
55
slot
66
</template>
77

8-
<script>
8+
<script lang="ts">
99
// Based on: https://medium.com/@dillonchanis/handling-errors-in-vue-with-error-boundaries-91f6ead0093b
1010
export default {
1111
name: 'ErrorBoundary',

src/components/EventEditor.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ b-modal(v-if="event && event.id", :id="'edit-modal-' + event.id", ref="eventEdit
5151

5252
<style lang="scss"></style>
5353

54-
<script>
54+
<script lang="ts">
5555
// This EventEditor can be used to edit events in a specific bucket.
5656
//
5757
// It is used in:

src/components/Footer.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ div.container(style="color: #555; font-size: 0.9em")
3737
| Donate
3838
</template>
3939

40-
<script>
40+
<script lang="ts">
4141
// only import the icons you use to reduce bundle size
4242
import 'vue-awesome/icons/brands/twitter';
4343
import 'vue-awesome/icons/brands/github';

src/components/Header.vue

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ div(:class="{'fixed-top-padding': fixedTopMenu}")
9595
}
9696
</style>
9797

98-
<script>
98+
<script lang="ts">
9999
// only import the icons you use to reduce bundle size
100100
import 'vue-awesome/icons/calendar-day';
101101
import 'vue-awesome/icons/calendar-week';
@@ -125,6 +125,7 @@ import _ from 'lodash';
125125
import { mapState } from 'pinia';
126126
import { useSettingsStore } from '~/stores/settings';
127127
import { useBucketsStore } from '~/stores/buckets';
128+
import { IBucket } from '~/util/interfaces';
128129
129130
export default {
130131
name: 'Header',
@@ -141,18 +142,18 @@ export default {
141142
mounted: async function () {
142143
const bucketStore = useBucketsStore();
143144
await bucketStore.ensureLoaded();
144-
const buckets = bucketStore.buckets;
145+
const buckets: IBucket[] = bucketStore.buckets;
145146
const types_by_host = {};
146147
147148
const activityViews = [];
148149
149150
// TODO: Change to use same bucket detection logic as get_buckets/set_available in store/modules/activity.ts
150151
_.each(buckets, v => {
151152
types_by_host[v.hostname] = types_by_host[v.hostname] || {};
152-
// The '&& true;' is just to typecoerce into booleans
153-
types_by_host[v.hostname].afk |= v.type == 'afkstatus';
154-
types_by_host[v.hostname].window |= v.type == 'currentwindow';
155-
types_by_host[v.hostname].android |= v.type == 'currentwindow' && v.id.includes('android'); // Use other bucket type ID in the future
153+
types_by_host[v.hostname].afk ||= v.type == 'afkstatus';
154+
types_by_host[v.hostname].window ||= v.type == 'currentwindow';
155+
// TODO: Use other bucket type ID in the future
156+
types_by_host[v.hostname].android ||= v.type == 'currentwindow' && v.id.includes('android');
156157
});
157158
//console.log(types_by_host);
158159
@@ -166,7 +167,7 @@ export default {
166167
icon: 'desktop',
167168
});
168169
}
169-
if (types.android) {
170+
if (types['android']) {
170171
activityViews.push({
171172
name: `${hostname} (Android)`,
172173
hostname: hostname,

src/components/InputTimeInterval.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ div
5151

5252
<style scoped lang="scss"></style>
5353

54-
<script>
54+
<script lang="ts">
5555
import moment from 'moment';
5656
import 'vue-awesome/icons/sync';
5757
export default {

src/components/NewReleaseNotification.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
button(type="button", class="close", @click="isFollowUpVisible=false") &times;
1414
</template>
1515

16-
<script>
16+
<script lang="ts">
1717
import axios from 'axios';
1818
import moment from 'moment';
1919
import semver from 'semver';

0 commit comments

Comments
 (0)