@@ -555,24 +555,24 @@ export default async function Api() {
555555 return users ;
556556 } ,
557557 async add ( user : User ) {
558- const { username, password, pfp, perm, securityQuestion, window } = user ;
558+ const { username, password, pfp, perm, securityQuestion, window : userWinopts } = user ;
559559 const userDir = `/home/${ username } ` ;
560- await parent . tb . fs . promises . mkdir ( userDir ) ;
560+ await window . tb . fs . promises . mkdir ( userDir ) ;
561561 const userJson : User = {
562562 id : username ,
563563 username : username ,
564564 password : password ,
565565 pfp : pfp ,
566566 perm : perm ,
567- window : window ,
567+ window : userWinopts ,
568568 } ;
569569 if ( securityQuestion ) {
570570 userJson . securityQuestion = {
571571 question : securityQuestion . question ,
572572 answer : securityQuestion . answer ,
573573 } ;
574574 }
575- await parent . tb . fs . promises . writeFile ( `${ userDir } /user.json` , JSON . stringify ( userJson ) ) ;
575+ await window . tb . fs . promises . writeFile ( `${ userDir } /user.json` , JSON . stringify ( userJson ) ) ;
576576 const userSettings = {
577577 wallpaper : "/assets/wallpapers/1.png" ,
578578 wallpaperMode : "cover" ,
@@ -588,14 +588,14 @@ export default async function Api() {
588588 showSeconds : false ,
589589 } ,
590590 } ;
591- await parent . tb . fs . promises . writeFile ( `${ userDir } /settings.json` , JSON . stringify ( userSettings ) ) ;
591+ await window . tb . fs . promises . writeFile ( `${ userDir } /settings.json` , JSON . stringify ( userSettings ) ) ;
592592 const defaultDirs = [ "desktop" , "documents" , "downloads" , "music" , "pictures" , "videos" ] ;
593593 defaultDirs . forEach ( async dir => {
594- await parent . tb . fs . promises . mkdir ( `${ userDir } /${ dir } ` ) ;
594+ await window . tb . fs . promises . mkdir ( `${ userDir } /${ dir } ` ) ;
595595 } ) ;
596- await parent . tb . fs . promises . mkdir ( `/apps/user/${ username } ` ) ;
597- await parent . tb . fs . promises . mkdir ( `/apps/user/${ username } /files` ) ;
598- await parent . tb . fs . promises . writeFile (
596+ await window . tb . fs . promises . mkdir ( `/apps/user/${ username } ` ) ;
597+ await window . tb . fs . promises . mkdir ( `/apps/user/${ username } /files` ) ;
598+ await window . tb . fs . promises . writeFile (
599599 `/apps/user/${ username } /files/config.json` ,
600600 JSON . stringify ( {
601601 "quick-center" : true ,
@@ -614,11 +614,11 @@ export default async function Api() {
614614 } ) ,
615615 "utf8" ,
616616 ) ;
617- await parent . tb . fs . promises . writeFile ( `/apps/user/${ username } /files/davs.json` , JSON . stringify ( [ ] ) ) ;
617+ await window . tb . fs . promises . writeFile ( `/apps/user/${ username } /files/davs.json` , JSON . stringify ( [ ] ) ) ;
618618 const response = await fetch ( "/apps/files.tapp/icons.json" ) ;
619619 const dat = await response . json ( ) ;
620- await parent . tb . fs . promises . writeFile ( `/apps/user/${ username } /files/icns.json` , JSON . stringify ( dat ) ) ;
621- await parent . tb . fs . promises . writeFile (
620+ await window . tb . fs . promises . writeFile ( `/apps/user/${ username } /files/icns.json` , JSON . stringify ( dat ) ) ;
621+ await window . tb . fs . promises . writeFile (
622622 `/apps/user/${ username } /files/quick-center.json` ,
623623 JSON . stringify ( {
624624 paths : {
@@ -668,10 +668,10 @@ export default async function Api() {
668668 left : leftPos ,
669669 } ,
670670 } ) ;
671- await parent . tb . fs . promises . symlink ( `/apps/system/${ name } .tapp/index.json` , `/home/${ username } /desktop/${ name } .lnk` ) ;
671+ await window . tb . fs . promises . symlink ( `/apps/system/${ name } .tapp/index.json` , `/home/${ username } /desktop/${ name } .lnk` ) ;
672672 }
673- await parent . tb . fs . promises . writeFile ( `/home/${ username } /desktop/.desktop.json` , JSON . stringify ( items ) ) ;
674- await parent . tb . fs . promises . writeFile (
673+ await window . tb . fs . promises . writeFile ( `/home/${ username } /desktop/.desktop.json` , JSON . stringify ( items ) ) ;
674+ await window . tb . fs . promises . writeFile (
675675 `/apps/user/${ username } /app store/repos.json` ,
676676 JSON . stringify ( [
677677 {
@@ -744,10 +744,10 @@ export default async function Api() {
744744 return true ;
745745 } ,
746746 async update ( user : User ) {
747- const { username, password, pfp, perm, securityQuestion, window } = user ;
747+ const { username, password, pfp, perm, securityQuestion, window : userwinOpts } = user ;
748748 const userDir = `/home/${ username } ` ;
749- const userConfig = JSON . parse ( await parent . tb . fs . promises . readFile ( `${ userDir } /user.json` , "utf8" ) ) ;
750- await parent . tb . fs . promises . writeFile (
749+ const userConfig = JSON . parse ( await window . tb . fs . promises . readFile ( `${ userDir } /user.json` , "utf8" ) ) ;
750+ await window . tb . fs . promises . writeFile (
751751 `${ userDir } /user.json` ,
752752 JSON . stringify ( {
753753 id : userConfig . id ,
@@ -756,10 +756,10 @@ export default async function Api() {
756756 pfp : pfp === userConfig . pfp ? userConfig . pfp : pfp ,
757757 perm : perm === userConfig . perm ? userConfig . perm : perm ,
758758 window : {
759- winAccent : window . winAccent === userConfig . window . winAccent ? userConfig . window . winAccent : "#ffffff" ,
760- blurlevel : window . blurlevel === userConfig . window . blurlevel ? userConfig . window . blurlevel : 0 ,
761- alwaysMaximized : window . alwaysMaximized === userConfig . window . alwaysMaximized ? userConfig . window . alwaysMaximized : false ,
762- alwaysFullscreen : window . alwaysFullscreen === userConfig . window . alwaysFullscreen ? userConfig . window . alwaysFullscreen : false ,
759+ winAccent : userwinOpts ? .winAccent ?? userConfig . window ?. winAccent ?? "#ffffff" ,
760+ blurlevel : userwinOpts ? .blurlevel ?? userConfig . window ? .blurlevel ?? 18 ,
761+ alwaysMaximized : userwinOpts ? .alwaysMaximized ?? userConfig . window ?. alwaysMaximized ?? false ,
762+ alwaysFullscreen : userwinOpts ? .alwaysFullscreen ?? userConfig . window ?. alwaysFullscreen ?? false ,
763763 } ,
764764 ...( securityQuestion !== undefined ? { securityQuestion : securityQuestion === userConfig . securityQuestion ? userConfig . securityQuestion : securityQuestion } : userConfig . securityQuestion !== undefined ? { securityQuestion : userConfig . securityQuestion } : { } ) ,
765765 } ) ,
@@ -807,6 +807,10 @@ export default async function Api() {
807807 password : password ,
808808 fetchOptions : {
809809 onSuccess : async response => {
810+ const exists = await window . tb . fs . promises . exists ( "/system/etc/terbium/taccs.json" ) ;
811+ if ( ! exists ) {
812+ await window . tb . fs . promises . writeFile ( "/system/etc/terbium/taccs.json" , JSON . stringify ( [ ] , null , 2 ) , "utf8" ) ;
813+ }
810814 const conf = JSON . parse ( await window . tb . fs . promises . readFile ( "/system/etc/terbium/taccs.json" , "utf8" ) ) ;
811815 conf . push ( {
812816 username : response . data . user . name ,
@@ -860,8 +864,11 @@ export default async function Api() {
860864 updateInfo : async ( user : Partial < User > ) => {
861865 const target = ( user as any ) . id || user . username || sessionStorage . getItem ( "currAcc" ) ;
862866 if ( ! target ) throw new Error ( "No target account specified" ) ;
863- const raw = await window . tb . fs . promises . readFile ( "/system/etc/terbium/taccs.json" , "utf8" ) ;
864- let conf : any = JSON . parse ( raw ) ;
867+ let conf = JSON . parse ( await window . tb . fs . promises . readFile ( "/system/etc/terbium/taccs.json" , "utf8" ) ) ;
868+ const exists = await window . tb . fs . promises . exists ( "/system/etc/terbium/taccs.json" ) ;
869+ if ( ! exists ) {
870+ await window . tb . fs . promises . writeFile ( "/system/etc/terbium/taccs.json" , JSON . stringify ( [ ] , null , 2 ) , "utf8" ) ;
871+ }
865872 if ( ! Array . isArray ( conf ) ) {
866873 if ( conf && typeof conf === "object" ) conf = Object . values ( conf ) ;
867874 else conf = [ ] ;
@@ -881,6 +888,7 @@ export default async function Api() {
881888 email : updated . email ,
882889 image : updated . pfp ,
883890 } ;
891+ console . log ( "Updating TAuth user info:" , obj ) ;
884892 try {
885893 await window . tb . tauth . client . updateUser ( obj ) ;
886894 } catch ( e ) {
@@ -974,7 +982,6 @@ export default async function Api() {
974982 // @ts -expect-error
975983 const stream = await navigator . mediaDevices . getDisplayMedia ( { preferCurrentTab : true } ) ;
976984 const capture = new ImageCapture ( stream . getVideoTracks ( ) [ 0 ] ) ;
977- // @ts -expect-error
978985 const frame = await capture . grabFrame ( ) ;
979986 stream . getVideoTracks ( ) [ 0 ] . stop ( ) ;
980987 const canvas : HTMLCanvasElement = document . createElement ( "canvas" ) ;
0 commit comments