TMP disable edit description. Reduce memory footprint

This commit is contained in:
eraden 2021-10-10 17:17:44 +02:00
parent f22944664e
commit d8855bdfec
10 changed files with 66 additions and 77 deletions

View File

@ -1,37 +0,0 @@
server {
listen 80;
# listen 443 ssl http2;
server_name jirs.lvh.me;
charset utf-8;
root /home/eraden/code/eraden/jirs/jirs-client/tmp;
# ssl_certificate /home/eraden/code/eraden/jirs/jirs-client/js/nginx-selfsigned.crt;
# ssl_certificate_key /home/eraden/code/eraden/jirs/jirs-client/js/nginx-selfsigned.key;
# if ($scheme != "https") {
# return 301 https://$host$request_uri;
# }
location ~ .wasm {
default_type application/wasm;
}
location *.js {
default_type application/javascript;
}
location / {
index index.html index.htm;
}
error_page 404 =200 /index.html;
location /ws/ {
proxy_pass http://localhost;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
}
}

View File

@ -402,18 +402,18 @@ fn init(url: Url, orders: &mut impl Orders<Msg>) -> Model {
}); });
{ {
let sender_clone = sender.clone(); // let sender_clone = sender.clone();
let id = FieldId::ProjectSettings(ProjectFieldId::Description); // let id = FieldId::ProjectSettings(ProjectFieldId::Description);
model // model
.distinct_key_up // .distinct_key_up
.keyup_wih_reset(id.to_str(), 20, move |ev| { // .keyup_wih_reset(id.to_str(), 20, move |ev| {
let sender = sender_clone.clone(); // let sender = sender_clone.clone();
let key_ev = seed::to_keyboard_event(&ev); // let key_ev = seed::to_keyboard_event(&ev);
let target = key_ev.target().unwrap(); // let target = key_ev.target().unwrap();
let el = seed::to_html_el(&target); // let el = seed::to_html_el(&target);
let value = el.inner_html(); // let value = el.inner_html();
sender.clone()(Some(Msg::StrInputChanged(id.clone(), value))); // sender.clone()(Some(Msg::StrInputChanged(id.clone(),
}); // value))); });
} }
open_socket(&mut model, orders); open_socket(&mut model, orders);

View File

@ -233,17 +233,19 @@ fn reporter_field(model: &Model, modal: &AddIssueModal) -> Node<Msg> {
variant: SelectVariant::Normal, variant: SelectVariant::Normal,
text_filter: modal.reporter_state.text_filter.as_str(), text_filter: modal.reporter_state.text_filter.as_str(),
opened: modal.reporter_state.opened, opened: modal.reporter_state.opened,
options: Some(model.users.iter().map(reporter_select_option)), options: Some(
model
.user_ids
.iter()
.filter_map(|id| model.users_by_id.get(id))
.map(reporter_select_option),
),
selected: model selected: model
.users .user_ids
.iter() .iter()
.filter_map(|user| { .filter(|id| **id == reporter_id)
if user.id == reporter_id { .filter_map(|id| model.users_by_id.get(id))
Some(reporter_select_option(user)) .map(reporter_select_option)
} else {
None
}
})
.collect(), .collect(),
valid: true, valid: true,
@ -284,10 +286,17 @@ fn assignees_field(model: &Model, modal: &AddIssueModal) -> Node<Msg> {
is_multi: true, is_multi: true,
text_filter: modal.assignees_state.text_filter.as_str(), text_filter: modal.assignees_state.text_filter.as_str(),
opened: modal.assignees_state.opened, opened: modal.assignees_state.opened,
options: Some(model.users.iter().map(assignee_select_option)), options: Some(
model
.user_ids
.iter()
.filter_map(|id| model.users_by_id.get(id))
.map(assignee_select_option),
),
selected: model selected: model
.users .user_ids
.iter() .iter()
.filter_map(|id| model.users_by_id.get(id))
.filter_map(|user| { .filter_map(|user| {
if modal.user_ids.contains(&user.id) { if modal.user_ids.contains(&user.id) {
Some(assignee_select_option(user)) Some(assignee_select_option(user))

View File

@ -452,10 +452,17 @@ fn reporters_select(
opened: reporter_state.opened, opened: reporter_state.opened,
variant: SelectVariant::Empty, variant: SelectVariant::Empty,
text_filter: reporter_state.text_filter.as_str(), text_filter: reporter_state.text_filter.as_str(),
options: Some(model.users.iter().map(reporter_select_option)), options: Some(
model
.user_ids
.iter()
.filter_map(|id| model.users_by_id.get(id))
.map(reporter_select_option),
),
selected: model selected: model
.users .user_ids
.iter() .iter()
.filter_map(|id| model.users_by_id.get(id))
.filter(|user| payload.reporter_id == user.id) .filter(|user| payload.reporter_id == user.id)
.map(reporter_select_option) .map(reporter_select_option)
.collect(), .collect(),
@ -502,10 +509,17 @@ fn assignees_select(
is_multi: true, is_multi: true,
opened: assignees_state.opened, opened: assignees_state.opened,
text_filter: assignees_state.text_filter.as_str(), text_filter: assignees_state.text_filter.as_str(),
options: Some(model.users.iter().map(assignee_select_option)), options: Some(
model
.user_ids
.iter()
.filter_map(|id| model.users_by_id.get(id))
.map(assignee_select_option),
),
selected: model selected: model
.users .user_ids
.iter() .iter()
.filter_map(|id| model.users_by_id.get(id))
.filter(|user| payload.user_ids.contains(&user.id)) .filter(|user| payload.user_ids.contains(&user.id))
.map(assignee_select_option) .map(assignee_select_option)
.collect(), .collect(),

View File

@ -235,7 +235,7 @@ pub struct Model {
// users // users
pub user: Option<User>, pub user: Option<User>,
pub users: Vec<User>, pub user_ids: Vec<UserId>,
pub users_by_id: HashMap<UserId, User>, pub users_by_id: HashMap<UserId, User>,
// user settings // user settings
@ -265,8 +265,7 @@ pub struct Model {
pub epics_by_id: HashMap<EpicId, Epic>, pub epics_by_id: HashMap<EpicId, Epic>,
pub key_triggers: std::rc::Rc<std::cell::RefCell<HashMap<char, Box<dyn BuildMsg>>>>, pub key_triggers: std::rc::Rc<std::cell::RefCell<HashMap<char, Box<dyn BuildMsg>>>>,
pub distinct_key_up: crate::shared::on_event::Distinct, // pub distinct_key_up: crate::shared::on_event::Distinct,
pub show_extras: bool, pub show_extras: bool,
} }
@ -290,7 +289,7 @@ impl Model {
about_tooltip_visible: false, about_tooltip_visible: false,
messages_tooltip_visible: false, messages_tooltip_visible: false,
issues: vec![], issues: vec![],
users: vec![], user_ids: vec![],
users_by_id: HashMap::with_capacity(1_000), users_by_id: HashMap::with_capacity(1_000),
user_settings: None, user_settings: None,
comments: vec![], comments: vec![],
@ -308,7 +307,7 @@ impl Model {
modals_stack: vec![], modals_stack: vec![],
modals: Modals::default(), modals: Modals::default(),
key_triggers: std::rc::Rc::new(std::cell::RefCell::new(HashMap::with_capacity(20))), key_triggers: std::rc::Rc::new(std::cell::RefCell::new(HashMap::with_capacity(20))),
distinct_key_up: crate::shared::on_event::distinct(), // distinct_key_up: crate::shared::on_event::distinct(),
} }
} }

View File

@ -79,7 +79,11 @@ pub fn update(msg: Msg, model: &mut crate::model::Model, orders: &mut impl Order
Some(JqlPart::Field(FieldOption::Assignee)) Some(JqlPart::Field(FieldOption::Assignee))
) => ) =>
{ {
let u = match model.users.get(n as usize) { let id = match model.user_ids.get(n as usize) {
Some(idx) => idx,
_ => return,
};
let u = match model.users_by_id.get(id) {
Some(u) => u, Some(u) => u,
_ => return, _ => return,
}; };

View File

@ -70,8 +70,9 @@ fn options<'l, 'm: 'l>(model: &'m Model, jql: &Jql) -> Vec<StyledSelectOption<'l
if matches!(jql.field(), Some(JqlPart::Field(FieldOption::Assignee))) => if matches!(jql.field(), Some(JqlPart::Field(FieldOption::Assignee))) =>
{ {
model model
.users .user_ids
.iter() .iter()
.filter_map(|id| model.users_by_id.get(id))
.map(|u| StyledSelectOption { .map(|u| StyledSelectOption {
name: Some("user"), name: Some("user"),
icon: None, icon: None,

View File

@ -73,8 +73,9 @@ pub fn avatars_filters(model: &Model) -> Node<Msg> {
}; };
let active_avatar_filters = &project_page.active_avatar_filters; let active_avatar_filters = &project_page.active_avatar_filters;
let avatars: Vec<Node<Msg>> = model let avatars: Vec<Node<Msg>> = model
.users .user_ids
.iter() .iter()
.filter_map(|id| model.users_by_id.get(id))
.enumerate() .enumerate()
.map(|(idx, user)| { .map(|(idx, user)| {
let user_id = user.id; let user_id = user.id;

View File

@ -358,8 +358,9 @@ fn parse_description(model: &Model, desc: &str) -> Node<Msg> {
let child = parse_email(word) let child = parse_email(word)
.and_then(|email| { .and_then(|email| {
model model
.users .user_ids
.iter() .iter()
.filter_map(|id| model.users_by_id.get(id))
.enumerate() .enumerate()
.find(|(_, user)| user.email == email) .find(|(_, user)| user.email == email)
}) })

View File

@ -177,9 +177,6 @@ pub fn update(msg: &mut WsMsg, model: &mut Model, orders: &mut impl Orders<Msg>)
if let Some(user) = model.users_by_id.get_mut(&id) { if let Some(user) = model.users_by_id.get_mut(&id) {
user.avatar_url = Some(url.clone()); user.avatar_url = Some(url.clone());
} }
if let Some(user) = model.users.iter_mut().find(|u| u.id == *id) {
user.avatar_url = Some(url.clone());
}
orders.send_msg(Msg::ResourceChanged( orders.send_msg(Msg::ResourceChanged(
ResourceKind::User, ResourceKind::User,
OperationKind::SingleModified, OperationKind::SingleModified,
@ -308,7 +305,7 @@ pub fn update(msg: &mut WsMsg, model: &mut Model, orders: &mut impl Orders<Msg>)
} }
// users // users
WsMsg::Project(WsMsgProject::ProjectUsersLoaded(v)) => { WsMsg::Project(WsMsgProject::ProjectUsersLoaded(v)) => {
model.users = v.clone(); model.user_ids = v.iter().map(|u| u.id).collect();
model.users_by_id.clear(); model.users_by_id.clear();
for user in v { for user in v {
model.users_by_id.insert(user.id, user.clone()); model.users_by_id.insert(user.id, user.clone());