| 1 | package main |
| 2 | |
| 3 | import ( |
| 4 | "encoding/json" |
| 5 | "strings" |
| 6 | ) |
| 7 | |
| 8 | // seedPreviousDraftForTarget models an installation that created a draft before |
| 9 | // the manual-new rollback. Production APIs may only reopen this stored record. |
| 10 | func (a *App) seedPreviousDraftForTarget(scope, root string) (SessionDraftView, error) { |
| 11 | id, err := a.ensureDesktopWorkspace(a.bootContext(), scope, root) |
| 12 | if err != nil { |
| 13 | return SessionDraftView{}, err |
| 14 | } |
| 15 | settings, err := json.Marshal(a.defaultDraftSettings(scope, root)) |
| 16 | if err != nil { |
| 17 | return SessionDraftView{}, err |
| 18 | } |
| 19 | _, _, err = a.draftStore().Open(a.bootContext(), id, scope, root, "draft-"+strings.TrimPrefix(newTabID(), "tab_"), string(settings)) |
| 20 | if err != nil { |
| 21 | return SessionDraftView{}, err |
| 22 | } |
| 23 | return a.OpenSessionDraftForTarget(scope, root) |
| 24 | } |
| 25 |