reorganize clone semantics, implement recently closed tabs history

This commit is contained in:
yggverse 2025-01-12 04:02:41 +02:00
parent 3682b5bf3f
commit ba68019614
17 changed files with 176 additions and 52 deletions

View file

@ -15,8 +15,10 @@ impl Database {
// Constructors
/// Create new `Self`
pub fn new(connection: Rc<RwLock<Connection>>) -> Self {
Self { connection }
pub fn build(connection: &Rc<RwLock<Connection>>) -> Self {
Self {
connection: connection.clone(),
}
}
// Getters
@ -37,7 +39,7 @@ impl Database {
// Setters
/// Create new record in `Self` database connected
pub fn add(&self, profile_id: Rc<i64>, is_active: bool) -> Result<i64, Error> {
pub fn add(&self, profile_id: &Rc<i64>, is_active: bool) -> Result<i64, Error> {
// Begin new transaction
let mut writable = self.connection.write().unwrap();
let tx = writable.transaction()?;
@ -80,7 +82,7 @@ pub fn init(tx: &Transaction) -> Result<usize, Error> {
)
}
pub fn insert(tx: &Transaction, profile_id: Rc<i64>, is_active: bool) -> Result<usize, Error> {
pub fn insert(tx: &Transaction, profile_id: &Rc<i64>, is_active: bool) -> Result<usize, Error> {
tx.execute(
"INSERT INTO `profile_identity` (
`profile_id`,

View file

@ -29,16 +29,16 @@ impl Gemini {
// Constructors
/// Create new `Self`
pub fn new(
connection: Rc<RwLock<Connection>>,
profile_identity_id: Rc<i64>,
pub fn build(
connection: &Rc<RwLock<Connection>>,
profile_identity_id: &Rc<i64>,
) -> Result<Self, Error> {
// Init components
let auth = match Auth::new(connection.clone()) {
let auth = match Auth::new(connection) {
Ok(auth) => Rc::new(auth),
Err(e) => return Err(Error::Auth(e)),
};
let database = Rc::new(Database::new(connection, profile_identity_id.clone()));
let database = Rc::new(Database::build(connection, profile_identity_id));
let memory = Rc::new(Memory::new());
// Init `Self`

View file

@ -21,7 +21,7 @@ impl Auth {
// Constructors
/// Create new `Self`
pub fn new(connection: Rc<RwLock<Connection>>) -> Result<Self, Error> {
pub fn new(connection: &Rc<RwLock<Connection>>) -> Result<Self, Error> {
// Init `Self`
let this = Self {
database: Rc::new(Database::new(connection)),

View file

@ -16,8 +16,10 @@ impl Database {
// Constructors
/// Create new `Self`
pub fn new(connection: Rc<RwLock<Connection>>) -> Self {
Self { connection }
pub fn new(connection: &Rc<RwLock<Connection>>) -> Self {
Self {
connection: connection.clone(),
}
}
// Actions

View file

@ -17,10 +17,10 @@ impl Database {
// Constructors
/// Create new `Self`
pub fn new(connection: Rc<RwLock<Connection>>, profile_identity_id: Rc<i64>) -> Self {
pub fn build(connection: &Rc<RwLock<Connection>>, profile_identity_id: &Rc<i64>) -> Self {
Self {
connection,
profile_identity_id,
connection: connection.clone(),
profile_identity_id: profile_identity_id.clone(),
}
}