Skip to content

Commit

Permalink
Allow saving filename in history for cowyodel
Browse files Browse the repository at this point in the history
  • Loading branch information
schollz committed Aug 12, 2017
1 parent 89d0f82 commit c0b6365
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ func handlePageRelinquish(c *gin.Context) {
}
message := "Relinquished"
p := Open(json.Page)
name, _ := p.Text.GetPreviousByIndex(0)
text := p.Text.GetCurrent()
isLocked := p.IsEncrypted
isEncrypted := p.IsEncrypted
Expand All @@ -87,7 +88,13 @@ func handlePageRelinquish(c *gin.Context) {
p.Erase()
message = "Relinquished and erased"
}
c.JSON(http.StatusOK, gin.H{"success": true, "message": message, "text": text, "locked": isLocked, "encrypted": isEncrypted, "destroyed": destroyed})
c.JSON(http.StatusOK, gin.H{"success": true,
"name": name,
"message": message,
"text": text,
"locked": isLocked,
"encrypted": isEncrypted,
"destroyed": destroyed})
}

func handlePageRequest(c *gin.Context) {
Expand Down Expand Up @@ -234,6 +241,7 @@ func handlePageExists(c *gin.Context) {
func handlePageUpdate(c *gin.Context) {
type QueryJSON struct {
Page string `json:"page"`
FileName string `json:"file_name"`
NewText string `json:"new_text"`
IsEncrypted bool `json:"is_encrypted"`
IsPrimed bool `json:"is_primed"`
Expand Down Expand Up @@ -262,6 +270,10 @@ func handlePageUpdate(c *gin.Context) {
} else if p.IsEncrypted {
message = "Encrypted, must decrypt first"
} else {
// Add the page name into the history so it can be retrieved
p.Update(json.FileName)
// time.Sleep(1 * time.Second)
// Add the page text so it can be retried as the latest part of the history
p.Update(json.NewText)
if json.IsEncrypted {
p.IsEncrypted = true
Expand Down

0 comments on commit c0b6365

Please sign in to comment.