storage: migration 13: Remove custom_person_list_names setting (we will do differently)

This commit is contained in:
Mike Dilger 2023-10-20 06:28:14 +13:00
parent 5c7942e04b
commit 4ec4158773
4 changed files with 11 additions and 26 deletions

View File

@ -57,7 +57,6 @@ pub struct Settings {
pub replies_chunk: u64, pub replies_chunk: u64,
pub person_feed_chunk: u64, pub person_feed_chunk: u64,
pub overlap: u64, pub overlap: u64,
pub custom_person_list_names: [String; 10],
// Event Selection // Event Selection
pub reposts: bool, pub reposts: bool,
@ -142,7 +141,6 @@ impl Default for Settings {
replies_chunk: default_setting!(replies_chunk), replies_chunk: default_setting!(replies_chunk),
person_feed_chunk: default_setting!(person_feed_chunk), person_feed_chunk: default_setting!(person_feed_chunk),
overlap: default_setting!(overlap), overlap: default_setting!(overlap),
custom_person_list_names: default_setting!(custom_person_list_names),
reposts: default_setting!(reposts), reposts: default_setting!(reposts),
show_long_form: default_setting!(show_long_form), show_long_form: default_setting!(show_long_form),
show_mentions: default_setting!(show_mentions), show_mentions: default_setting!(show_mentions),
@ -223,7 +221,6 @@ impl Settings {
replies_chunk: load_setting!(replies_chunk), replies_chunk: load_setting!(replies_chunk),
person_feed_chunk: load_setting!(person_feed_chunk), person_feed_chunk: load_setting!(person_feed_chunk),
overlap: load_setting!(overlap), overlap: load_setting!(overlap),
custom_person_list_names: load_setting!(custom_person_list_names),
reposts: load_setting!(reposts), reposts: load_setting!(reposts),
show_long_form: load_setting!(show_long_form), show_long_form: load_setting!(show_long_form),
show_mentions: load_setting!(show_mentions), show_mentions: load_setting!(show_mentions),
@ -300,7 +297,6 @@ impl Settings {
save_setting!(replies_chunk, self, txn); save_setting!(replies_chunk, self, txn);
save_setting!(person_feed_chunk, self, txn); save_setting!(person_feed_chunk, self, txn);
save_setting!(overlap, self, txn); save_setting!(overlap, self, txn);
save_setting!(custom_person_list_names, self, txn);
save_setting!(reposts, self, txn); save_setting!(reposts, self, txn);
save_setting!(show_long_form, self, txn); save_setting!(show_long_form, self, txn);
save_setting!(show_mentions, self, txn); save_setting!(show_mentions, self, txn);

View File

@ -10,7 +10,7 @@ use speedy::{Readable, Writable};
use std::collections::HashMap; use std::collections::HashMap;
impl Storage { impl Storage {
const MAX_MIGRATION_LEVEL: u32 = 13; const MAX_MIGRATION_LEVEL: u32 = 14;
pub(super) fn migrate(&self, mut level: u32) -> Result<(), Error> { pub(super) fn migrate(&self, mut level: u32) -> Result<(), Error> {
if level > Self::MAX_MIGRATION_LEVEL { if level > Self::MAX_MIGRATION_LEVEL {
@ -133,6 +133,10 @@ impl Storage {
tracing::info!("{prefix}: migrating lists..."); tracing::info!("{prefix}: migrating lists...");
self.migrate_lists(txn)?; self.migrate_lists(txn)?;
} }
13 => {
tracing::info!("{prefix}: removing a retired setting...");
self.remove_setting_custom_person_list_names(txn)?;
}
_ => panic!("Unreachable migration level"), _ => panic!("Unreachable migration level"),
}; };
@ -591,4 +595,9 @@ impl Storage {
Ok(()) Ok(())
} }
pub fn remove_setting_custom_person_list_names<'a>(&'a self, txn: &mut RwTxn<'a>) -> Result<(), Error> {
self.general.delete(txn, b"custom_person_list_names")?;
Ok(())
}
} }

View File

@ -723,23 +723,6 @@ impl Storage {
60 * 60 * 24 * 30 60 * 60 * 24 * 30
); );
def_setting!(overlap, b"overlap", u64, 300); def_setting!(overlap, b"overlap", u64, 300);
def_setting!(
custom_person_list_names,
b"custom_person_list_names",
[String; 10],
[
"Priority".to_owned(),
"Custom List 2".to_owned(),
"Custom List 3".to_owned(),
"Custom List 4".to_owned(),
"Custom List 5".to_owned(),
"Custom List 6".to_owned(),
"Custom List 7".to_owned(),
"Custom List 8".to_owned(),
"Custom List 9".to_owned(),
"Custom List 10".to_owned(),
]
);
def_setting!(reposts, b"reposts", bool, true); def_setting!(reposts, b"reposts", bool, true);
def_setting!(show_long_form, b"show_long_form", bool, false); def_setting!(show_long_form, b"show_long_form", bool, false);
def_setting!(show_mentions, b"show_mentions", bool, true); def_setting!(show_mentions, b"show_mentions", bool, true);

View File

@ -1,4 +1,3 @@
use crate::globals::GLOBALS;
use speedy::{Readable, Writable}; use speedy::{Readable, Writable};
/// Lists people can be added to /// Lists people can be added to
@ -47,9 +46,7 @@ impl PersonList1 {
PersonList1::Muted => "Muted".to_string(), PersonList1::Muted => "Muted".to_string(),
PersonList1::Followed => "Followed".to_string(), PersonList1::Followed => "Followed".to_string(),
PersonList1::Custom(u) => { PersonList1::Custom(u) => {
if (10..=19).contains(&u) { if u >= 10 {
GLOBALS.storage.read_setting_custom_person_list_names()[u as usize - 10].clone()
} else if u > 19 {
format!("Custom List {}", u - 9) // humans count from 1 format!("Custom List {}", u - 9) // humans count from 1
} else { } else {
format!("Undefined list in slot={}", u) format!("Undefined list in slot={}", u)