mirror of
https://github.com/simon-ding/polaris.git
synced 2026-06-09 11:39:46 +08:00
fix
This commit is contained in:
7
db/db.go
7
db/db.go
@@ -83,21 +83,20 @@ func (c *Client) AddWatchlist(storageId int, nameCn, nameEn string, detail *tmdb
|
||||
res = R1080p
|
||||
}
|
||||
if storageId == 0 {
|
||||
r, err := c.ent.Storage.Query().Where(storage.Default(true)).First(context.TODO())
|
||||
r, err := c.ent.Storage.Query().Where(storage.And(storage.Default(true), storage.Deleted(false))).First(context.TODO())
|
||||
if err == nil {
|
||||
log.Infof("use default storage: %v", r.Name)
|
||||
storageId = r.ID
|
||||
}
|
||||
}
|
||||
st := c.GetStorage(storageId)
|
||||
|
||||
|
||||
targetDir := fmt.Sprintf("%s %s (%v)", nameCn, nameEn, strings.Split(detail.FirstAirDate, "-")[0])
|
||||
if !utils.IsChineseChar(nameCn) {
|
||||
log.Warnf("name cn is not chinese name: %v", nameCn)
|
||||
targetDir = fmt.Sprintf("%s (%v)", nameEn, strings.Split(detail.FirstAirDate, "-")[0])
|
||||
}
|
||||
|
||||
|
||||
targetDir = filepath.Join(st.GetPath(), targetDir)
|
||||
|
||||
r, err := c.ent.Series.Create().
|
||||
@@ -282,7 +281,7 @@ func (c *Client) AddStorage(st *StorageInfo) error {
|
||||
SetImplementation(storage.Implementation(st.Implementation)).
|
||||
SetSettings(string(data)).Exec(context.TODO())
|
||||
}
|
||||
countAll := c.ent.Storage.Query().CountX(context.TODO())
|
||||
countAll := c.ent.Storage.Query().Where(storage.Deleted(false)).CountX(context.TODO())
|
||||
if countAll == 0 {
|
||||
log.Infof("first storage, make it default: %s", st.Name)
|
||||
st.Default = true
|
||||
|
||||
@@ -35,7 +35,7 @@ func (s *Server) SearchTvSeries(c *gin.Context) (interface{}, error) {
|
||||
|
||||
type addWatchlistIn struct {
|
||||
TmdbID int `json:"tmdb_id" binding:"required"`
|
||||
StorageID int `json:"storage_id" binding:"required"`
|
||||
StorageID int `json:"storage_id" `
|
||||
Resolution db.ResolutionType `json:"resolution" binding:"required"`
|
||||
}
|
||||
|
||||
|
||||
@@ -112,7 +112,7 @@ class _SearchPageState extends ConsumerState<SearchPage> {
|
||||
return StatefulBuilder(
|
||||
builder: (context, setState) {
|
||||
String _resSelected = "1080p";
|
||||
Storage? _storageSelected;
|
||||
int _storageSelected = 0;
|
||||
var storage = ref.watch(storageSettingProvider);
|
||||
|
||||
return AlertDialog(
|
||||
@@ -140,12 +140,12 @@ class _SearchPageState extends ConsumerState<SearchPage> {
|
||||
label: const Text("存储位置"),
|
||||
initialSelection: _storageSelected,
|
||||
dropdownMenuEntries: v
|
||||
.map((s) =>
|
||||
DropdownMenuEntry(label: s.name!, value: s))
|
||||
.map((s) => DropdownMenuEntry(
|
||||
label: s.name!, value: s.id))
|
||||
.toList(),
|
||||
onSelected: (value) {
|
||||
setState(() {
|
||||
_storageSelected = value;
|
||||
_storageSelected = value!;
|
||||
});
|
||||
},
|
||||
);
|
||||
@@ -170,10 +170,11 @@ class _SearchPageState extends ConsumerState<SearchPage> {
|
||||
),
|
||||
child: const Text('确定'),
|
||||
onPressed: () {
|
||||
print(_storageSelected);
|
||||
ref
|
||||
.read(searchPageDataProvider.notifier)
|
||||
.submit2Watchlist(
|
||||
item.id!, _storageSelected!.id!, _resSelected);
|
||||
item.id!, _storageSelected, _resSelected);
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user