Skip to content

Commit

Permalink
fix a few more types
Browse files Browse the repository at this point in the history
  • Loading branch information
davidnewhall committed Apr 10, 2024
1 parent 1911a83 commit 040b28b
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 17 deletions.
2 changes: 1 addition & 1 deletion frontend/src/Starr/Actions/BlockLists.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
const starrApp = instance.App
const caret = sortDir ? "caret-up" : "caret-down"
let all = false
let selected: any = {}
let selected: {[key: string]: boolean}
let str: string = JSON.stringify(info.records)
let form: any = JSON.parse(str)
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/Starr/Actions/DownloadClients.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
let isOpen: any = {} // Modal toggle control.
let all: boolean = false // Toggle for select-all link.
let selected: any = {} // Rows selected by key: ID.
let selected: {[key: string]: boolean} // Rows selected by key: ID.
let str: string = fixFieldValues(info) // Used for equivalence comparison.
let form: any = JSON.parse(str) // Form changes go here.
let starrApp = instance.App
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/Starr/Actions/Exclusions.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import { Table } from "@sveltestrap/sveltestrap"
let all: boolean = false // Toggle for select-all link.
let selected: any = {} // Rows selected by key: ID.
let selected: {[key: string]: boolean} // Rows selected by key: ID.
let str: string = JSON.stringify(info) // Used for equivalence comparison.
let form: any = JSON.parse(str) // Form changes go here.
let starrApp = instance.App
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/Starr/Actions/ImportLists.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
let isOpen: any = {} // Modal toggle control.
let all: boolean = false // Toggle for select-all link.
let selected: any = {} // Rows selected by key: ID.
let selected: {[key: string]: boolean} // Rows selected by key: ID.
let str: string = fixFieldValues(info) // Used for equivalence comparison.
let form: any = JSON.parse(str) // Form changes go here.
let starrApp = instance.App
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/Starr/Actions/Indexers.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
let isOpen: any = {} // Modal toggle control.
let all = false // Toggle for select-all link.
let selected: any = {} // Rows selected by key: ID.
let selected: {[key: string]: boolean} // Rows selected by key: ID.
let str = fixFieldValues(info) // Used for equivalence comparison.
let form = JSON.parse(str) // Form changes go here.
let starrApp = instance.App
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/Starr/Actions/QualityProfiles.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
let isOpen: any = {} // Modal toggle control.
let all: boolean = false // Toggle for select-all link.
let selected: any = {} // Rows selected by key: ID.
let selected: {[key: string]: boolean} // Rows selected by key: ID.
let str: string = JSON.stringify(info) // Used for equivalence comparison.
let form: any = JSON.parse(str) // Form changes go here.
</script>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/Starr/Database/Index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
let instance = $conf.Instances[starrApp][$conf.Instance[starrApp]]
$: if (!$conf.Instances[starrApp].includes(instance)) {
instance = $conf.Instances[starrApp][0]
instance = $conf.Instances[starrApp][$conf.Instance[starrApp]]
}
</script>

Expand Down
4 changes: 2 additions & 2 deletions frontend/src/libs/Translate.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
export { _ } // pass it through
export const isReady = derived(locale, $locale => typeof $locale === 'string')
let formatDate
let formatDate: (arg0: Date|number) => string // type is DateFormatter, but not sure how to import it.
dt.subscribe((val) => formatDate = val)
export function date(date: string|Date): string {
Expand All @@ -16,7 +16,7 @@
</script>

<script lang="ts">
export let id
export let id: string
</script>

{#if $isReady == true}
Expand Down
17 changes: 9 additions & 8 deletions frontend/src/libs/funcs.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { toasts } from "svelte-toasts"
import type { ToastProps, ToastType } from "svelte-toasts/types/common"
import { onDestroy } from "svelte"
import { conf } from "/src/libs/config"
import { _, isReady } from "/src/libs/Translate.svelte"

// Keep track of toasts so their theme may be kept up to date.
const sentToasts = []
const sentToasts: ToastProps[] = []

let errorWord = "ERROR"
isReady.subscribe(ready => {
Expand All @@ -18,14 +19,14 @@ conf.subscribe((value) => {
sentToasts.forEach(t => t.theme = isDark ? "dark" : "light")
})

export function toast(type, msg, title="", seconds=7) {
export function toast(type: ToastType, msg: string, title="", seconds=7) {
const thisToast = toasts.add({
title: title != "" ? title : type == "error" ? errorWord : "",
description: msg,
duration: seconds*1000,
theme: isDark ? "dark" : "light",
type: type,
onClick: () => {thisToast.remove()},
onClick: () => {thisToast.remove?thisToast.remove():''},
showProgress: true,
onRemove: () => { // Remove itself from the running list.
const index = sentToasts.indexOf(thisToast)
Expand All @@ -37,24 +38,24 @@ export function toast(type, msg, title="", seconds=7) {
}

// onInterval sets an interval and destroys it when it when the page changes.
export function onInterval(callback, seconds) {
export function onInterval(callback: () => void, seconds: number) {
const interval = setInterval(callback, seconds*1000)
onDestroy(() => clearInterval(interval))

return interval
}

// onOnce sets a timer and expires it after one invocation.
export function onOnce(callback, seconds) {
const interval = setInterval(input => {
export function onOnce(callback: () => void, seconds: number) {
const interval = setInterval(() => {
clearInterval(interval)
callback(input)
callback()
}, seconds*1000)

return interval
}

export function count(selected, key?): number {
export function count(selected: Record<any, any>, key?: string): number {
let counter = 0

if (key) {
Expand Down

0 comments on commit 040b28b

Please sign in to comment.