@@ -13,7 +13,6 @@ import {
13
13
copyDirectory ,
14
14
} from "./util.js" ;
15
15
import { languages } from "./common.js" ;
16
- import { rust_template_dir } from "./langs/rust/rust.js" ;
17
16
18
17
export const sessions_dir = data_dir . get_child ( "sessions" ) ;
19
18
@@ -57,16 +56,16 @@ function createSession() {
57
56
return session ;
58
57
}
59
58
60
- export function createSessionFromDemo ( demo ) {
59
+ export async function createSessionFromDemo ( demo ) {
61
60
const { name, panels } = demo ;
62
61
63
62
const session = createSession ( ) ;
64
63
const demo_dir = demos_dir . get_child ( name ) ;
65
64
66
65
const { file, settings } = session ;
67
- copyDirectory ( demo_dir , file ) ;
68
- copyDirectory ( rust_template_dir , file ) ;
66
+ await copyDirectory ( demo_dir , file ) ;
69
67
68
+ settings . delay ( ) ;
70
69
settings . set_string ( "name" , name ) ;
71
70
settings . set_boolean ( "show-code" , panels . includes ( "code" ) ) ;
72
71
settings . set_boolean ( "show-style" , panels . includes ( "style" ) ) ;
@@ -76,6 +75,7 @@ export function createSessionFromDemo(demo) {
76
75
"code-language" ,
77
76
global_settings . get_int ( "recent-code-language" ) ,
78
77
) ;
78
+ settings . apply ( ) ;
79
79
80
80
return session ;
81
81
}
@@ -84,7 +84,13 @@ export async function deleteSession(session) {
84
84
// There is no method to recursively delete a folder so we trash instead
85
85
// https://github.com/flatpak/xdg-desktop-portal/issues/630 :/
86
86
// portal.trash_file(file.get_path(), null).catch(console.error);
87
- session . file . trash ( null ) ;
87
+ try {
88
+ session . file . trash ( null ) ;
89
+ } catch ( err ) {
90
+ if ( ! err . matches ( Gio . IOErrorEnum , Gio . IOErrorEnum . EXISTS ) ) {
91
+ throw err ;
92
+ }
93
+ }
88
94
}
89
95
90
96
export async function saveSessionAsProject ( session , destination ) {
0 commit comments