Update clear so it no longer archives Running Commands (#110)

* fix clear so it doesn't archive running commands

Clear previously archived every command that existed in the current tab.
This change alters this behavior so the commands with a status of running
or detached are not archived by clear.  As things currently stand,
detached is not used so the only immediate effect will be with running
commands. As before, the clear command only affects the current tab.

* remove unnecessary print

A print statement for debug still existed in the ArchiveScreenLines
function. It has been removed.

* remove isWebShare from ArchiveScreenLines

The isWebShare feature is currently unused and there is not a plan to
add it back soon. For this reason, it has been removed from the
ArchiveScreenLines function.

* clean up query formatting
This commit is contained in:
Sylvie Crowe
2023-11-29 18:29:44 -08:00
committed by GitHub
parent 1c9c470fec
commit 86a86bc756
+4 -12
View File
@@ -1391,17 +1391,9 @@ func ArchiveScreenLines(ctx context.Context, screenId string) (*ModelUpdate, err
if !tx.Exists(query, screenId) {
return fmt.Errorf("screen does not exist")
}
fmt.Printf("** archive-screen-lines: %s\n", screenId)
if isWebShare(tx, screenId) {
query = `INSERT INTO screenupdate (screenid, lineid, updatetype, updatets)
SELECT screenid, lineid, ?, ? FROM line WHERE screenid = ? AND archived = 0`
tx.Exec(query, UpdateType_LineDel, time.Now().UnixMilli(), screenId)
NotifyUpdateWriter()
query = `SELECT count(*) FROM line WHERE screenid = ? AND archived = 0`
count := tx.GetInt(query, screenId)
fmt.Printf("** archive-screen-lines: wrote into screenupdate: %d\n", count)
}
query = `UPDATE line SET archived = 1 WHERE screenid = ? AND archived = 0`
query = `UPDATE line SET archived = 1
WHERE line.archived = 0 AND line.screenid = ? AND NOT EXISTS (SELECT * FROM cmd c
WHERE line.screenid = c.screenid AND line.lineid = c.lineid AND c.status IN ('running', 'detached'))`
tx.Exec(query, screenId)
return nil
})
@@ -1709,7 +1701,7 @@ const (
ScreenField_SelectedLine = "selectedline" // int
ScreenField_Focus = "focustype" // string
ScreenField_TabColor = "tabcolor" // string
ScreenField_TabIcon = "tabicon" // string
ScreenField_TabIcon = "tabicon" // string
ScreenField_PTerm = "pterm" // string
ScreenField_Name = "name" // string
ScreenField_ShareName = "sharename" // string