Skip to content

Commit 16670e8

Browse files
committed
feat: add feature checkboxes to getting started page
feat: bump version
1 parent b52cddc commit 16670e8

File tree

12 files changed

+289
-19
lines changed

12 files changed

+289
-19
lines changed

Diff for: CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file.
66

77
- ⚡️ Reduced memory usage
88
- ⚡️ Automatic Transcoding cache cleanup on server startup
9+
- ⚡️ Added more fields to getting started screen
910
- 🚀 Added Docker image for Linux arm64 #63
1011
- 🚑️ Fixed occasional runtime error caused by internal module
1112
- 💄 UI: Improved stream page layouts

Diff for: codegen/generated/handlers.json

+96
Original file line numberDiff line numberDiff line change
@@ -4627,6 +4627,102 @@
46274627
"returnTypescriptType": "Models_Settings"
46284628
}
46294629
},
4630+
{
4631+
"name": "HandleGettingStarted",
4632+
"trimmedName": "GettingStarted",
4633+
"comments": [
4634+
"HandleGettingStarted",
4635+
"",
4636+
"\t@summary updates the app settings.",
4637+
"\t@desc This will update the app settings.",
4638+
"\t@desc The client should re-fetch the server status after this.",
4639+
"\t@route /api/v1/start [POST]",
4640+
"\t@returns handlers.Status",
4641+
""
4642+
],
4643+
"filepath": "internal/handlers/settings.go",
4644+
"filename": "settings.go",
4645+
"api": {
4646+
"summary": "updates the app settings.",
4647+
"descriptions": [
4648+
"This will update the app settings.",
4649+
"The client should re-fetch the server status after this."
4650+
],
4651+
"endpoint": "/api/v1/start",
4652+
"methods": [
4653+
"POST"
4654+
],
4655+
"params": [],
4656+
"bodyFields": [
4657+
{
4658+
"name": "Library",
4659+
"jsonName": "library",
4660+
"goType": "models.LibrarySettings",
4661+
"usedStructType": "models.LibrarySettings",
4662+
"typescriptType": "Models_LibrarySettings",
4663+
"required": true,
4664+
"descriptions": []
4665+
},
4666+
{
4667+
"name": "MediaPlayer",
4668+
"jsonName": "mediaPlayer",
4669+
"goType": "models.MediaPlayerSettings",
4670+
"usedStructType": "models.MediaPlayerSettings",
4671+
"typescriptType": "Models_MediaPlayerSettings",
4672+
"required": true,
4673+
"descriptions": []
4674+
},
4675+
{
4676+
"name": "Torrent",
4677+
"jsonName": "torrent",
4678+
"goType": "models.TorrentSettings",
4679+
"usedStructType": "models.TorrentSettings",
4680+
"typescriptType": "Models_TorrentSettings",
4681+
"required": true,
4682+
"descriptions": []
4683+
},
4684+
{
4685+
"name": "Anilist",
4686+
"jsonName": "anilist",
4687+
"goType": "models.AnilistSettings",
4688+
"usedStructType": "models.AnilistSettings",
4689+
"typescriptType": "Models_AnilistSettings",
4690+
"required": true,
4691+
"descriptions": []
4692+
},
4693+
{
4694+
"name": "Discord",
4695+
"jsonName": "discord",
4696+
"goType": "models.DiscordSettings",
4697+
"usedStructType": "models.DiscordSettings",
4698+
"typescriptType": "Models_DiscordSettings",
4699+
"required": true,
4700+
"descriptions": []
4701+
},
4702+
{
4703+
"name": "EnableTranscode",
4704+
"jsonName": "enableTranscode",
4705+
"goType": "bool",
4706+
"usedStructType": "",
4707+
"typescriptType": "boolean",
4708+
"required": true,
4709+
"descriptions": []
4710+
},
4711+
{
4712+
"name": "EnableTorrentStreaming",
4713+
"jsonName": "enableTorrentStreaming",
4714+
"goType": "bool",
4715+
"usedStructType": "",
4716+
"typescriptType": "boolean",
4717+
"required": true,
4718+
"descriptions": []
4719+
}
4720+
],
4721+
"returns": "handlers.Status",
4722+
"returnGoType": "handlers.Status",
4723+
"returnTypescriptType": "Status"
4724+
}
4725+
},
46304726
{
46314727
"name": "HandleSaveSettings",
46324728
"trimmedName": "SaveSettings",

Diff for: codegen/generated/public_structs.json

+12-12
Original file line numberDiff line numberDiff line change
@@ -34915,9 +34915,8 @@
3491534915
{
3491634916
"name": "subscribers",
3491734917
"jsonName": "subscribers",
34918-
"goType": "map[string]RepositorySubscriber",
34919-
"typescriptType": "Record\u003cstring, RepositorySubscriber\u003e",
34920-
"usedStructName": "mediaplayer.RepositorySubscriber",
34918+
"goType": "",
34919+
"typescriptType": "any",
3492134920
"required": false,
3492234921
"public": false,
3492334922
"comments": []
@@ -36550,15 +36549,6 @@
3655036549
" The current media being played."
3655136550
]
3655236551
},
36553-
{
36554-
"name": "transcoderSettings",
36555-
"jsonName": "transcoderSettings",
36556-
"goType": "",
36557-
"typescriptType": "any",
36558-
"required": true,
36559-
"public": false,
36560-
"comments": []
36561-
},
3656236552
{
3656336553
"name": "repository",
3656436554
"jsonName": "repository",
@@ -36750,6 +36740,16 @@
3675036740
"public": false,
3675136741
"comments": []
3675236742
},
36743+
{
36744+
"name": "reqMu",
36745+
"jsonName": "reqMu",
36746+
"goType": "sync.Mutex",
36747+
"typescriptType": "Mutex",
36748+
"usedStructName": "sync.Mutex",
36749+
"required": false,
36750+
"public": false,
36751+
"comments": []
36752+
},
3675336753
{
3675436754
"name": "cacheDir",
3675536755
"jsonName": "cacheDir",

Diff for: internal/constants/constants.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package constants
33
import "time"
44

55
const (
6-
Version = "1.5.0"
6+
Version = "1.5.1"
77
VersionName = "Blackbeard"
88
GcTime = time.Minute * 30
99
ConfigFileName = "config.toml"

Diff for: internal/handlers/routes.go

+1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ func InitRoutes(app *core.App, fiberApp *fiber.App) {
8585
// Settings
8686
v1.Get("/settings", makeHandler(app, HandleGetSettings))
8787
v1.Patch("/settings", makeHandler(app, HandleSaveSettings))
88+
v1.Post("/start", makeHandler(app, HandleGettingStarted))
8889
v1.Patch("/settings/list-sync", makeHandler(app, HandleSaveListSyncSettings))
8990
v1.Patch("/settings/auto-downloader", makeHandler(app, HandleSaveAutoDownloaderSettings))
9091

Diff for: internal/handlers/settings.go

+81
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,87 @@ func HandleGetSettings(c *RouteCtx) error {
2525
return c.RespondWithData(settings)
2626
}
2727

28+
// HandleGettingStarted
29+
//
30+
// @summary updates the app settings.
31+
// @desc This will update the app settings.
32+
// @desc The client should re-fetch the server status after this.
33+
// @route /api/v1/start [POST]
34+
// @returns handlers.Status
35+
func HandleGettingStarted(c *RouteCtx) error {
36+
37+
type body struct {
38+
Library models.LibrarySettings `json:"library"`
39+
MediaPlayer models.MediaPlayerSettings `json:"mediaPlayer"`
40+
Torrent models.TorrentSettings `json:"torrent"`
41+
Anilist models.AnilistSettings `json:"anilist"`
42+
Discord models.DiscordSettings `json:"discord"`
43+
EnableTranscode bool `json:"enableTranscode"`
44+
EnableTorrentStreaming bool `json:"enableTorrentStreaming"`
45+
}
46+
var b body
47+
48+
if err := c.Fiber.BodyParser(&b); err != nil {
49+
return c.RespondWithError(err)
50+
}
51+
52+
listSyncSettings := &models.ListSyncSettings{}
53+
autoDownloaderSettings := &models.AutoDownloaderSettings{}
54+
prevSettings, err := c.App.Database.GetSettings()
55+
if err == nil && prevSettings.ListSync != nil {
56+
listSyncSettings = prevSettings.ListSync
57+
}
58+
if err == nil && prevSettings.AutoDownloader != nil {
59+
autoDownloaderSettings = prevSettings.AutoDownloader
60+
}
61+
62+
settings, err := c.App.Database.UpsertSettings(&models.Settings{
63+
BaseModel: models.BaseModel{
64+
ID: 1,
65+
UpdatedAt: time.Now(),
66+
},
67+
Library: &b.Library,
68+
MediaPlayer: &b.MediaPlayer,
69+
Torrent: &b.Torrent,
70+
Anilist: &b.Anilist,
71+
Discord: &b.Discord,
72+
ListSync: listSyncSettings,
73+
AutoDownloader: autoDownloaderSettings,
74+
})
75+
76+
if err != nil {
77+
return c.RespondWithError(err)
78+
}
79+
80+
go func() {
81+
if b.EnableTranscode {
82+
stt := c.App.SecondarySettings.Mediastream
83+
stt.TranscodeEnabled = true
84+
_, err = c.App.Database.UpsertMediastreamSettings(stt)
85+
if err != nil {
86+
c.App.Logger.Error().Err(err).Msg("app: Failed to update mediastream settings")
87+
}
88+
}
89+
if b.EnableTorrentStreaming {
90+
stt := c.App.SecondarySettings.Torrentstream
91+
stt.Enabled = true
92+
_, err = c.App.Database.UpsertTorrentstreamSettings(stt)
93+
if err != nil {
94+
c.App.Logger.Error().Err(err).Msg("app: Failed to update mediastream settings")
95+
}
96+
}
97+
}()
98+
99+
c.App.WSEventManager.SendEvent("settings", settings)
100+
101+
status := NewStatus(c)
102+
103+
// Refresh modules that depend on the settings
104+
c.App.InitOrRefreshModules()
105+
106+
return c.RespondWithData(status)
107+
}
108+
28109
// HandleSaveSettings
29110
//
30111
// @summary updates the app settings.

Diff for: seanime-web/src/api/generated/endpoint.types.ts

+17
Original file line numberDiff line numberDiff line change
@@ -932,6 +932,23 @@ export type ScanLocalFiles_Variables = {
932932
// settings
933933
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
934934

935+
/**
936+
* - Filepath: internal/handlers/settings.go
937+
* - Filename: settings.go
938+
* - Endpoint: /api/v1/start
939+
* @description
940+
* Route updates the app settings.
941+
*/
942+
export type GettingStarted_Variables = {
943+
library: Models_LibrarySettings
944+
mediaPlayer: Models_MediaPlayerSettings
945+
torrent: Models_TorrentSettings
946+
anilist: Models_AnilistSettings
947+
discord: Models_DiscordSettings
948+
enableTranscode: boolean
949+
enableTorrentStreaming: boolean
950+
}
951+
935952
/**
936953
* - Filepath: internal/handlers/settings.go
937954
* - Filename: settings.go

Diff for: seanime-web/src/api/generated/endpoints.ts

+11
Original file line numberDiff line numberDiff line change
@@ -1031,6 +1031,17 @@ export const API_ENDPOINTS = {
10311031
methods: ["GET"],
10321032
endpoint: "/api/v1/settings",
10331033
},
1034+
/**
1035+
* @description
1036+
* Route updates the app settings.
1037+
* This will update the app settings.
1038+
* The client should re-fetch the server status after this.
1039+
*/
1040+
GettingStarted: {
1041+
key: "SETTINGS-getting-started",
1042+
methods: ["POST"],
1043+
endpoint: "/api/v1/start",
1044+
},
10341045
/**
10351046
* @description
10361047
* Route updates the app settings.

Diff for: seanime-web/src/api/generated/hooks_template.ts

+11
Original file line numberDiff line numberDiff line change
@@ -1185,6 +1185,17 @@
11851185
// })
11861186
// }
11871187

1188+
// export function useGettingStarted() {
1189+
// return useServerMutation<Status, GettingStarted_Variables>({
1190+
// endpoint: API_ENDPOINTS.SETTINGS.GettingStarted.endpoint,
1191+
// method: API_ENDPOINTS.SETTINGS.GettingStarted.methods[0],
1192+
// mutationKey: [API_ENDPOINTS.SETTINGS.GettingStarted.key],
1193+
// onSuccess: async () => {
1194+
//
1195+
// },
1196+
// })
1197+
// }
1198+
11881199
// export function useSaveSettings() {
11891200
// return useServerMutation<Status, SaveSettings_Variables>({
11901201
// endpoint: API_ENDPOINTS.SETTINGS.SaveSettings.endpoint,

Diff for: seanime-web/src/api/hooks/settings.hooks.ts

+20-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import { useServerMutation, useServerQuery } from "@/api/client/requests"
2-
import { SaveAutoDownloaderSettings_Variables, SaveListSyncSettings_Variables, SaveSettings_Variables } from "@/api/generated/endpoint.types"
2+
import {
3+
GettingStarted_Variables,
4+
SaveAutoDownloaderSettings_Variables,
5+
SaveListSyncSettings_Variables,
6+
SaveSettings_Variables,
7+
} from "@/api/generated/endpoint.types"
38
import { API_ENDPOINTS } from "@/api/generated/endpoints"
49
import { Models_Settings, Status } from "@/api/generated/types"
510
import { useQueryClient } from "@tanstack/react-query"
@@ -14,6 +19,20 @@ export function useGetSettings() {
1419
})
1520
}
1621

22+
export function useGettingStarted() {
23+
const queryClient = useQueryClient()
24+
25+
return useServerMutation<Status, GettingStarted_Variables>({
26+
endpoint: API_ENDPOINTS.SETTINGS.GettingStarted.endpoint,
27+
method: API_ENDPOINTS.SETTINGS.GettingStarted.methods[0],
28+
mutationKey: [API_ENDPOINTS.SETTINGS.GettingStarted.key],
29+
onSuccess: async () => {
30+
await queryClient.invalidateQueries({ queryKey: [API_ENDPOINTS.SETTINGS.GetSettings.key] })
31+
await queryClient.invalidateQueries({ queryKey: [API_ENDPOINTS.STATUS.GetStatus.key] })
32+
},
33+
})
34+
}
35+
1736
export function useSaveSettings() {
1837
const queryClient = useQueryClient()
1938

0 commit comments

Comments
 (0)