Fixed components to reload watchlist
This commit is contained in:
21
frontend/src/helperModules/AddAnimeServiceToTable.svelte
Normal file
21
frontend/src/helperModules/AddAnimeServiceToTable.svelte
Normal file
@ -0,0 +1,21 @@
|
||||
<script lang="ts" context="module">
|
||||
import type {TableItem} from "../helperTypes/TableTypes";
|
||||
import { tableItems } from "./GlobalVariablesAndHelperFunctions.svelte"
|
||||
|
||||
export function AddAnimeServiceToTable(animeItem: TableItem) {
|
||||
tableItems.update((table) => {
|
||||
if (table.length === 0) {
|
||||
table.push(animeItem)
|
||||
} else {
|
||||
for (const [index, tableItem] of table.entries()) {
|
||||
if(tableItem.service === animeItem.service) {
|
||||
table[index] = animeItem
|
||||
return table
|
||||
}
|
||||
}
|
||||
table.push(animeItem)
|
||||
}
|
||||
return table
|
||||
})
|
||||
}
|
||||
</script>
|
Reference in New Issue
Block a user