mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 09:35:28 +00:00
reorganize clone semantics, implement recently closed tabs history
This commit is contained in:
parent
3682b5bf3f
commit
ba68019614
17 changed files with 176 additions and 52 deletions
|
|
@ -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`,
|
||||
|
|
|
|||
|
|
@ -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`
|
||||
|
|
|
|||
|
|
@ -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)),
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue