Skip to content

Commit a6277e0

Browse files
committed
fix: lint issues
1 parent 18c1464 commit a6277e0

File tree

5 files changed

+109
-103
lines changed

5 files changed

+109
-103
lines changed

apps/app-frontend/src/components/ui/ScreenshotCard.vue

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,7 @@
1616
<Button icon-only title="Rename" @click="renameScreenshot">
1717
<EditIcon/>
1818
</Button>
19-
<Button
20-
icon-only
21-
title="Copy"
22-
@click="copyImageToClipboard"
23-
>
19+
<Button icon-only title="Copy" @click="copyImageToClipboard">
2420
<ClipboardCopyIcon/>
2521
</Button>
2622
<Button icon-only title="Share" @click="shareScreenshot">
@@ -36,16 +32,16 @@
3632
</template>
3733

3834
<script lang="ts" setup>
39-
import {ClipboardCopyIcon, EditIcon, ShareIcon, TrashIcon} from "@modrinth/assets";
40-
import {Button} from "@modrinth/ui";
41-
import type {Screenshot} from "@/helpers/screenshots.ts";
42-
import {useNotifications} from "@/store/state";
35+
import {ClipboardCopyIcon, EditIcon, ShareIcon, TrashIcon} from '@modrinth/assets'
36+
import {Button} from '@modrinth/ui'
37+
import type {Screenshot} from '@/helpers/screenshots.ts'
38+
import {useNotifications} from '@/store/state'
4339
44-
const notifications = useNotifications();
40+
const notifications = useNotifications()
4541
4642
const props = defineProps<{
4743
screenshot: Screenshot
48-
}>();
44+
}>()
4945
5046
const getFileName = (path: string | undefined) => {
5147
if (!path) return 'Untitled'
@@ -54,26 +50,27 @@ const getFileName = (path: string | undefined) => {
5450
5551
const copyImageToClipboard = async () => {
5652
try {
57-
const base64 = props.screenshot.data;
58-
const binary = atob(base64);
53+
const base64 = props.screenshot.data
54+
const binary = atob(base64)
5955
60-
const bytes = Uint8Array.from(binary, char => char.charCodeAt(0));
56+
const bytes = Uint8Array.from(binary, (char) => char.charCodeAt(0))
6157
62-
const blob = new Blob([bytes], {type: `data:image/png`});
63-
const clipboardItem = new ClipboardItem({"image/png": blob});
58+
const blob = new Blob([bytes], {type: `data:image/png`})
59+
const clipboardItem = new ClipboardItem({'image/png': blob})
6460
65-
await navigator.clipboard.write([clipboardItem]);
61+
await navigator.clipboard.write([clipboardItem])
6662
6763
notifications.addNotification({
68-
title: "Copied to clipboard",
69-
text: "The screenshot has successfully been copied to your clipboard.",
70-
type: 'success'
64+
title: 'Copied to clipboard',
65+
text: 'The screenshot has successfully been copied to your clipboard.',
66+
type: 'success',
7167
})
68+
// eslint-disable-next-line
7269
} catch (error: any) {
7370
notifications.addNotification({
7471
title: 'Failed to copy screenshot',
7572
text: error.message,
76-
type: 'warn'
73+
type: 'warn',
7774
})
7875
}
7976
}
@@ -86,4 +83,4 @@ const deleteScreenshot = () => {
8683
8784
const shareScreenshot = () => {
8885
}
89-
</script>
86+
</script>
Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
1-
import {invoke} from "@tauri-apps/api/core";
1+
import {invoke} from '@tauri-apps/api/core'
22

33
export type Screenshot = {
4-
path: string;
5-
creation_date: string;
6-
data: string;
4+
path: string
5+
creation_date: string
6+
data: string
77
}
88

99
export async function getAllProfileScreenshots(path: string): Promise<Screenshot[]> {
10-
return await invoke('plugin:screenshots|get_all_profile_screenshots', { path })
10+
return await invoke('plugin:screenshots|get_all_profile_screenshots', {path})
1111
}
1212

1313
export async function deleteScreenshotFile(screenshot: Screenshot): Promise<boolean> {
1414
return await invoke('plugin:screenshots|delete_screenshot', {path: screenshot.path})
1515
}
1616

17-
export async function renameScreenshotFile(screenshot: Screenshot, new_filename: string): Promise<boolean> {
18-
return await invoke('plugin:screenshots|rename_screenshot', {path: screenshot.path, new_filename})
19-
}
17+
export async function renameScreenshotFile(
18+
screenshot: Screenshot,
19+
new_filename: string,
20+
): Promise<boolean> {
21+
return await invoke('plugin:screenshots|rename_screenshot', {
22+
path: screenshot.path,
23+
new_filename,
24+
})
25+
}

apps/app-frontend/src/pages/instance/Index.vue

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,7 @@
153153
</div>
154154
</template>
155155
<script setup>
156-
import {
157-
Avatar,
158-
ButtonStyled,
159-
ContentPageHeader,
160-
LoadingIndicator,
161-
OverflowMenu,
162-
} from '@modrinth/ui'
156+
import {Avatar, ButtonStyled, ContentPageHeader, LoadingIndicator, OverflowMenu,} from '@modrinth/ui'
163157
import {
164158
CheckCircleIcon,
165159
ClipboardCopyIcon,
@@ -183,19 +177,19 @@ import {
183177
UserPlusIcon,
184178
XIcon,
185179
} from '@modrinth/assets'
186-
import { finish_install, get, get_full_path, kill, run } from '@/helpers/profile'
187-
import { get_by_profile_path } from '@/helpers/process'
188-
import { process_listener, profile_listener } from '@/helpers/events'
189-
import { useRoute, useRouter } from 'vue-router'
190-
import { computed, onUnmounted, ref, watch } from 'vue'
191-
import { handleError, useBreadcrumbs, useLoading } from '@/store/state'
192-
import { showProfileInFolder } from '@/helpers/utils.js'
180+
import {finish_install, get, get_full_path, kill, run} from '@/helpers/profile'
181+
import {get_by_profile_path} from '@/helpers/process'
182+
import {process_listener, profile_listener} from '@/helpers/events'
183+
import {useRoute, useRouter} from 'vue-router'
184+
import {computed, onUnmounted, ref, watch} from 'vue'
185+
import {handleError, useBreadcrumbs, useLoading} from '@/store/state'
186+
import {showProfileInFolder} from '@/helpers/utils.js'
193187
import ContextMenu from '@/components/ui/ContextMenu.vue'
194188
import NavTabs from '@/components/ui/NavTabs.vue'
195-
import { trackEvent } from '@/helpers/analytics'
196-
import { convertFileSrc } from '@tauri-apps/api/core'
197-
import { handleSevereError } from '@/store/error.js'
198-
import { get_project, get_version_many } from '@/helpers/cache.js'
189+
import {trackEvent} from '@/helpers/analytics'
190+
import {convertFileSrc} from '@tauri-apps/api/core'
191+
import {handleSevereError} from '@/store/error.js'
192+
import {get_project, get_version_many} from '@/helpers/cache.js'
199193
import dayjs from 'dayjs'
200194
import duration from 'dayjs/plugin/duration'
201195
import relativeTime from 'dayjs/plugin/relativeTime'
@@ -274,7 +268,7 @@ const tabs = computed(() => [
274268
},
275269
{
276270
label: 'Screenshots',
277-
href: `${basePath.value}/screenshots`
271+
href: `${basePath.value}/screenshots`,
278272
},
279273
{
280274
label: 'Logs',
Lines changed: 62 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,72 @@
11
<script setup lang="ts">
2-
import type {GameInstance} from "@/helpers/types";
3-
import type ContextMenu from "@/components/ui/ContextMenu.vue";
4-
import {DropdownIcon} from "@modrinth/assets";
5-
import type {Version} from "@modrinth/utils";
6-
import {computed, onMounted, ref} from 'vue';
7-
import dayjs from "dayjs";
8-
import advancedFormat from 'dayjs/plugin/advancedFormat.js';
9-
import type {Screenshot} from "@/helpers/screenshots.ts";
10-
import {getAllProfileScreenshots} from "@/helpers/screenshots.ts";
11-
import ScreenshotCard from "@/components/ui/ScreenshotCard.vue";
2+
import type {GameInstance} from '@/helpers/types'
3+
import type ContextMenu from '@/components/ui/ContextMenu.vue'
4+
import {DropdownIcon} from '@modrinth/assets'
5+
import type {Version} from '@modrinth/utils'
6+
import {computed, onMounted, ref} from 'vue'
7+
import dayjs from 'dayjs'
8+
import advancedFormat from 'dayjs/plugin/advancedFormat.js'
9+
import type {Screenshot} from '@/helpers/screenshots.ts'
10+
import {getAllProfileScreenshots} from '@/helpers/screenshots.ts'
11+
import ScreenshotCard from '@/components/ui/ScreenshotCard.vue'
1212
13-
dayjs.extend(advancedFormat);
13+
dayjs.extend(advancedFormat)
1414
1515
const props = defineProps<{
16-
instance: GameInstance;
17-
options: InstanceType<typeof ContextMenu> | null;
18-
offline: boolean;
19-
playing: boolean;
20-
versions: Version[];
21-
installed: boolean;
22-
}>();
16+
instance: GameInstance
17+
options: InstanceType<typeof ContextMenu> | null
18+
offline: boolean
19+
playing: boolean
20+
versions: Version[]
21+
installed: boolean
22+
}>()
2323
24-
const screenshots = ref<Screenshot[]>([]);
24+
const screenshots = ref<Screenshot[]>([])
2525
2626
onMounted(async () => {
27-
screenshots.value = (await getAllProfileScreenshots(props.instance.path)) ?? [];
28-
});
27+
screenshots.value = (await getAllProfileScreenshots(props.instance.path)) ?? []
28+
})
2929
3030
function groupAndSortByDate(items: Screenshot[]) {
31-
const today = dayjs().startOf('day');
32-
const yesterday = today.subtract(1, 'day');
33-
const map = new Map<string, { labelDate: dayjs.Dayjs; items: any[] }>();
31+
const today = dayjs().startOf('day')
32+
const yesterday = today.subtract(1, 'day')
33+
const map = new Map<string, { labelDate: dayjs.Dayjs; items: Screenshot[] }>()
3434
3535
for (const shot of items) {
36-
const d = dayjs(shot.creation_date).startOf('day');
37-
let label: string;
38-
if (d.isSame(today)) label = 'Today';
39-
else if (d.isSame(yesterday)) label = 'Yesterday';
40-
else label = dayjs(shot.creation_date).format("MMMM Do, YYYY");
36+
const d = dayjs(shot.creation_date).startOf('day')
37+
let label: string
38+
if (d.isSame(today)) label = 'Today'
39+
else if (d.isSame(yesterday)) label = 'Yesterday'
40+
else label = dayjs(shot.creation_date).format('MMMM Do, YYYY')
4141
4242
if (!map.has(label)) {
43-
map.set(label, {labelDate: d, items: []});
43+
map.set(label, {labelDate: d, items: []})
4444
}
4545
46-
map.get(label)!.items.push(shot);
46+
map.get(label)!.items.push(shot)
4747
}
4848
4949
return Array.from(map.entries())
5050
.sort(([a, aData], [b, bData]) => {
51-
if (a === 'Today') return -1;
52-
if (b === 'Today') return 1;
53-
if (a === 'Yesterday') return -1;
54-
if (b === 'Yesterday') return 1;
55-
return bData.labelDate.unix() - aData.labelDate.unix();
51+
if (a === 'Today') return -1
52+
if (b === 'Today') return 1
53+
if (a === 'Yesterday') return -1
54+
if (b === 'Yesterday') return 1
55+
return bData.labelDate.unix() - aData.labelDate.unix()
5656
})
57-
.map(([label, {items}]) => [label, items] as const);
57+
.map(([label, {items}]) => [label, items] as const)
5858
}
5959
60-
const screenshotsByDate = computed(() => groupAndSortByDate(screenshots.value));
61-
const hasToday = computed(() => screenshotsByDate.value.some(([label]) => label === 'Today'));
60+
const screenshotsByDate = computed(() => groupAndSortByDate(screenshots.value))
61+
const hasToday = computed(() => screenshotsByDate.value.some(([label]) => label === 'Today'))
6262
</script>
6363

6464
<template>
6565
<div class="w-full p-5">
66-
<div v-if="!screenshots.length" class="flex flex-col items-center justify-center py-12 text-center">
66+
<div
67+
v-if="!screenshots.length"
68+
class="flex flex-col items-center justify-center py-12 text-center"
69+
>
6770
<div class="text-lg font-medium mb-2">No screenshots yet</div>
6871
<div class="text-sm text-gray-500 dark:text-gray-400">
6972
Screenshots taken in-game will appear here
@@ -74,30 +77,36 @@ const hasToday = computed(() => screenshotsByDate.value.some(([label]) => label
7477
<template v-if="!hasToday">
7578
<details class="group space-y-2" open>
7679
<summary class="cursor-pointer flex items-center justify-between">
77-
<h2 class="text-xxl font-bold underline decoration-4 decoration-brand-green underline-offset-8">Today</h2>
78-
<DropdownIcon class="w-5 h-5 transform transition-transform duration-200 group-open:rotate-180"/>
80+
<h2
81+
class="text-xxl font-bold underline decoration-4 decoration-brand-green underline-offset-8"
82+
>
83+
Today
84+
</h2>
85+
<DropdownIcon
86+
class="w-5 h-5 transform transition-transform duration-200 group-open:rotate-180"
87+
/>
7988
</summary>
8089
<p class="text-lg font-medium mb-2">You haven't taken any screenshots today.</p>
8190
</details>
8291
</template>
8392

84-
<template v-for="([date, shots]) in screenshotsByDate" :key="date">
93+
<template v-for="[date, shots] in screenshotsByDate" :key="date">
8594
<details class="group space-y-2" open>
8695
<summary class="cursor-pointer flex items-center justify-between">
87-
<h2 class="text-xxl font-bold underline decoration-4 decoration-brand-green underline-offset-8">{{
88-
date
89-
}}</h2>
90-
<DropdownIcon class="w-5 h-5 transform transition-transform duration-200 group-open:rotate-180"/>
96+
<h2
97+
class="text-xxl font-bold underline decoration-4 decoration-brand-green underline-offset-8"
98+
>
99+
{{ date }}
100+
</h2>
101+
<DropdownIcon
102+
class="w-5 h-5 transform transition-transform duration-200 group-open:rotate-180"
103+
/>
91104
</summary>
92105
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4 pt-2">
93-
<ScreenshotCard
94-
v-for="s in shots"
95-
:key="s.path"
96-
:screenshot="s"
97-
/>
106+
<ScreenshotCard v-for="s in shots" :key="s.path" :screenshot="s"/>
98107
</div>
99108
</details>
100109
</template>
101110
</div>
102111
</div>
103-
</template>
112+
</template>

apps/app-frontend/src/pages/instance/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ import Overview from './Overview.vue'
33
import Worlds from './Worlds.vue'
44
import Mods from './Mods.vue'
55
import Logs from './Logs.vue'
6-
import Screenshots from "./Screenshots.vue"
6+
import Screenshots from './Screenshots.vue'
77

88
export { Index, Overview, Worlds, Mods, Logs, Screenshots }

0 commit comments

Comments
 (0)