Removed storage key for filetransfer terminal width

This commit is contained in:
veeso
2021-12-13 17:12:38 +01:00
committed by Christian Visintin
parent e047179ea0
commit b8efe6985f
3 changed files with 14 additions and 21 deletions

View File

@@ -214,11 +214,13 @@ impl FileTransferActivity {
/// Update local file list
pub(super) fn update_local_filelist(&mut self) {
// Get width
let width: usize = self
.context()
.store()
.get_unsigned(super::STORAGE_EXPLORER_WIDTH)
.unwrap_or(256);
let width = self
.context_mut()
.terminal()
.raw()
.size()
.map(|x| (x.width / 2) - 2)
.unwrap_or(0) as usize;
let hostname: String = match hostname::get() {
Ok(h) => {
let hostname: String = h.as_os_str().to_string_lossy().to_string();
@@ -258,11 +260,13 @@ impl FileTransferActivity {
/// Update remote file list
pub(super) fn update_remote_filelist(&mut self) {
let width: usize = self
.context()
.store()
.get_unsigned(super::STORAGE_EXPLORER_WIDTH)
.unwrap_or(256);
let width = self
.context_mut()
.terminal()
.raw()
.size()
.map(|x| (x.width / 2) - 2)
.unwrap_or(0) as usize;
let hostname = self.get_remote_hostname();
let hostname: String = format!(
"{}:{} ",

View File

@@ -54,11 +54,6 @@ use std::time::Duration;
use tempfile::TempDir;
use tuirealm::{Application, EventListenerCfg, NoUserEvent};
// -- Storage keys
/// Stores the explorer width
const STORAGE_EXPLORER_WIDTH: &str = "FT_EW";
// -- components
#[derive(Debug, Eq, PartialEq, Clone, Hash)]

View File

@@ -31,7 +31,6 @@ use super::{
components, Context, FileTransferActivity, Id,
};
use crate::explorer::FileSorting;
use crate::ui::store::Store;
use crate::utils::ui::draw_area_in;
// Ext
use remotefs::fs::Entry;
@@ -117,7 +116,6 @@ impl FileTransferActivity {
pub(super) fn view(&mut self) {
self.redraw = false;
let mut context: Context = self.context.take().unwrap();
let store: &mut Store = &mut context.store;
let _ = context.terminal.raw_mut().draw(|f| {
// Prepare chunks
let body = Layout::default()
@@ -157,10 +155,6 @@ impl FileTransferActivity {
.direction(Direction::Horizontal)
.horizontal_margin(1)
.split(bottom_chunks[0]);
// If width is unset in the storage, set width
if !store.isset(super::STORAGE_EXPLORER_WIDTH) {
store.set_unsigned(super::STORAGE_EXPLORER_WIDTH, tabs_chunks[0].width as usize);
}
// Draw footer
self.app.view(&Id::FooterBar, f, body[1]);
// Draw explorers