Corrige sessões duplicadas ao reabrir uma sessão recente
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
627eae1b8b
commit
b1ac320193
2 files changed
+19
-2
No files matched your search
+8
-2
@@ -215,8 +215,11 @@ async function openRecent(r) {
|
|||||||
try {
|
try {
|
||||||
const { job } = await rpc('session_load', { path: r.path });
|
const { job } = await rpc('session_load', { path: r.path });
|
||||||
const st = await rpc('status', { job });
|
const st = await rpc('status', { job });
|
||||||
const s = { job, target: st.target, label: 'Sessão: ' + st.target.split(/[\\/]/).pop() };
|
let s = S.sessions.find((x) => x.job === job);
|
||||||
|
if (!s) {
|
||||||
|
s = { job, target: st.target, label: 'Sessão: ' + st.target.split(/[\\/]/).pop() };
|
||||||
S.sessions.unshift(s);
|
S.sessions.unshift(s);
|
||||||
|
}
|
||||||
openJob(s);
|
openJob(s);
|
||||||
} catch (e) { info({ title: 'Não foi possível abrir a sessão', html: `<p>${esc(e.message)}</p>` }); }
|
} catch (e) { info({ title: 'Não foi possível abrir a sessão', html: `<p>${esc(e.message)}</p>` }); }
|
||||||
}
|
}
|
||||||
@@ -246,8 +249,11 @@ $('#loadSessionBtn').onclick = async () => {
|
|||||||
try {
|
try {
|
||||||
const { job } = await rpc('session_load', { path });
|
const { job } = await rpc('session_load', { path });
|
||||||
const st = await rpc('status', { job });
|
const st = await rpc('status', { job });
|
||||||
const s = { job, target: st.target, label: 'Sessão: ' + st.target.split(/[\\/]/).pop() };
|
let s = S.sessions.find((x) => x.job === job);
|
||||||
|
if (!s) {
|
||||||
|
s = { job, target: st.target, label: 'Sessão: ' + st.target.split(/[\\/]/).pop() };
|
||||||
S.sessions.unshift(s);
|
S.sessions.unshift(s);
|
||||||
|
}
|
||||||
openJob(s);
|
openJob(s);
|
||||||
} catch (e) { info({ title: 'Não foi possível abrir a sessão', html: `<p>${esc(e.message)}</p>` }); }
|
} catch (e) { info({ title: 'Não foi possível abrir a sessão', html: `<p>${esc(e.message)}</p>` }); }
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -721,6 +721,17 @@ impl Engine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn load_session(&self, path: &str) -> Result<String> {
|
pub fn load_session(&self, path: &str) -> Result<String> {
|
||||||
|
// Clicar de novo numa sessão já aberta reaproveita o job em vez de criar outro igual.
|
||||||
|
let want = Path::new(path);
|
||||||
|
if let Some(j) = self
|
||||||
|
.jobs
|
||||||
|
.lock()
|
||||||
|
.unwrap()
|
||||||
|
.values()
|
||||||
|
.find(|j| j.session_file.lock().unwrap().as_deref() == Some(want))
|
||||||
|
{
|
||||||
|
return Ok(j.id.clone());
|
||||||
|
}
|
||||||
let bytes = std::fs::read(path).map_err(|e| {
|
let bytes = std::fs::read(path).map_err(|e| {
|
||||||
if e.kind() == std::io::ErrorKind::PermissionDenied {
|
if e.kind() == std::io::ErrorKind::PermissionDenied {
|
||||||
Error::msg(format!(
|
Error::msg(format!(
|
||||||
|
|||||||
Reference in new issue
Block a user