diff options
-rw-r--r-- | elm/User/Edit.elm | 4 | ||||
-rw-r--r-- | lib/VNWeb/Producers/Page.pm | 7 | ||||
-rw-r--r-- | lib/VNWeb/User/Edit.pm | 5 | ||||
-rw-r--r-- | sql/schema.sql | 3 | ||||
-rw-r--r-- | util/updates/2022-06-18-user-prefs-prodrelexpand.sql | 1 |
5 files changed, 13 insertions, 7 deletions
diff --git a/elm/User/Edit.elm b/elm/User/Edit.elm index bcdeb6fd..f9b9f38c 100644 --- a/elm/User/Edit.elm +++ b/elm/User/Edit.elm @@ -106,6 +106,7 @@ type PrefMsg | TagsCont Bool | TagsEro Bool | TagsTech Bool + | ProdRel Bool | Skin String | Css String | NoAds Bool @@ -206,6 +207,7 @@ updatePrefs msg model = TagsCont b -> { model | tags_cont = b } TagsEro b -> { model | tags_ero = b } TagsTech b -> { model | tags_tech = b } + ProdRel b -> { model | prodrelexpand = b } Skin n -> { model | skin = n } Css n -> { model | customcss = n } NoAds b -> { model | nodistract_noads = b } @@ -390,6 +392,8 @@ view model = , (2, "Show all spoilers") ] ] + , formField "prodrel::Default producer tab" + [ inputSelect "prodrel" m.prodrelexpand (Prefs << ProdRel) [] [ (False, "Visual Novels"), (True, "Releases") ] ] , tr [ class "newpart" ] [ td [ colspan 2 ] [ text "Language" ] ] , formField "Titles" <| [ Html.map (Prefs << TitleLang) (langprefsform m.title_langs False) ] diff --git a/lib/VNWeb/Producers/Page.pm b/lib/VNWeb/Producers/Page.pm index ac722145..4e8000e3 100644 --- a/lib/VNWeb/Producers/Page.pm +++ b/lib/VNWeb/Producers/Page.pm @@ -156,10 +156,9 @@ TUWF::get qr{/$RE{prev}(?:/(?<tab>vn|rel))?}, sub { return tuwf->resNotFound if !$p; enrich_item $p; - my $pref = tuwf->reqCookie('prodrelexpand') ? 'vn' : 'rel'; - my $tab = tuwf->capture('tab') || $pref; - tuwf->resCookie(prodrelexpand => $tab eq 'vn' ? 1 : undef, expires => time + 315360000) if $tab && $tab ne $pref; - $tab = 'rel' if !$tab; + my $tab = tuwf->capture('tab') + || (auth && (tuwf->dbVali('SELECT prodrelexpand FROM users_prefs WHERE id=', \auth->uid) ? 'rel' : 'vn')) + || 'rel'; framework_ title => $p->{name}, index => !tuwf->capture('rev'), dbobj => $p, hiddenmsg => 1, og => { diff --git a/lib/VNWeb/User/Edit.pm b/lib/VNWeb/User/Edit.pm index 8d3934fe..98a09785 100644 --- a/lib/VNWeb/User/Edit.pm +++ b/lib/VNWeb/User/Edit.pm @@ -39,6 +39,7 @@ my $FORM = { tags_cont => { anybool => 1 }, tags_ero => { anybool => 1 }, tags_tech => { anybool => 1 }, + prodrelexpand => { anybool => 1 }, spoilers => { uint => 1, range => [ 0, 2 ] }, skin => { enum => skins }, customcss => { required => 0, default => '', maxlength => 2000 }, @@ -88,7 +89,7 @@ TUWF::get qr{/$RE{uid}/edit}, sub { $u->{prefs} = $u->{id} eq auth->uid || auth->permUsermod ? tuwf->dbRowi( - 'SELECT max_sexual, max_violence, traits_sexual, tags_all, tags_cont, tags_ero, tags_tech, spoilers, skin, customcss + 'SELECT max_sexual, max_violence, traits_sexual, tags_all, tags_cont, tags_ero, tags_tech, prodrelexpand, spoilers, skin, customcss , nodistract_noads, nodistract_nofancy, support_enabled, uniname, pubskin_enabled, title_langs, alttitle_langs FROM users u JOIN users_prefs up ON up.id = u.id WHERE u.id =', \$u->{id} ) : undef; @@ -138,7 +139,7 @@ elm_api UserEdit => $FORM_OUT, $FORM_IN, sub { $p->{alttitle_langs} = undef if $p->{alttitle_langs} && $p->{alttitle_langs} eq langpref_fmt $DEFAULT_ALTTITLE_LANGS; $set{$_} = $p->{$_} for qw/nodistract_noads nodistract_nofancy support_enabled uniname pubskin_enabled/; $setp{$_} = $p->{$_} for qw/ - max_sexual max_violence traits_sexual tags_all tags_cont tags_ero tags_tech spoilers skin customcss title_langs alttitle_langs + max_sexual max_violence traits_sexual tags_all tags_cont tags_ero tags_tech prodrelexpand spoilers skin customcss title_langs alttitle_langs /; tuwf->dbExeci('DELETE FROM users_traits WHERE id =', \$data->{id}); tuwf->dbExeci('INSERT INTO users_traits', { id => $data->{id}, tid => $_->{tid} }) for $p->{traits}->@*; diff --git a/sql/schema.sql b/sql/schema.sql index 3c04cc29..d215546e 100644 --- a/sql/schema.sql +++ b/sql/schema.sql @@ -1059,7 +1059,8 @@ CREATE TABLE users_prefs ( ulist_wish jsonb, vnlang jsonb, -- '$lang(-mtl)?' => true/false, which languages to expand/collapse on VN pages title_langs jsonb, - alttitle_langs jsonb + alttitle_langs jsonb, + prodrelexpand boolean NOT NULL DEFAULT true ); -- Additional fields for the 'users' table, but with some protected columns. diff --git a/util/updates/2022-06-18-user-prefs-prodrelexpand.sql b/util/updates/2022-06-18-user-prefs-prodrelexpand.sql new file mode 100644 index 00000000..96fe5fe5 --- /dev/null +++ b/util/updates/2022-06-18-user-prefs-prodrelexpand.sql @@ -0,0 +1 @@ +ALTER TABLE users_prefs ADD COLUMN prodrelexpand boolean NOT NULL DEFAULT true; |