diff --git a/src/UI/UIDesktop.js b/src/UI/UIDesktop.js
index 936ba9b9..18ad3251 100644
--- a/src/UI/UIDesktop.js
+++ b/src/UI/UIDesktop.js
@@ -502,10 +502,18 @@ async function UIDesktop(options){
// update local user preferences
const user_preferences = {
- show_hidden_files: (await puter.kv.get('user_preferences.show_hidden_files')) === 'true',
- language: (await puter.kv.get('user_preferences.language'))
+ show_hidden_files: JSON.parse(await puter.kv.get('user_preferences.show_hidden_files')),
+ language: await puter.kv.get('user_preferences.language'),
};
- update_user_preferences(user_preferences);
+
+ // update default apps
+ puter.kv.list('user_preferences.default_apps.*').then(async (default_app_keys) => {
+ for(let key in default_app_keys){
+ user_preferences[default_app_keys[key].substring(17)] = await puter.kv.get(default_app_keys[key]);
+ }
+
+ update_user_preferences(user_preferences);
+ });
// Append to
$('body').append(h);
diff --git a/src/UI/UIItem.js b/src/UI/UIItem.js
index 00b10e77..6681af48 100644
--- a/src/UI/UIItem.js
+++ b/src/UI/UIItem.js
@@ -975,6 +975,26 @@ function UIItem(options){
html: suggested_app.title,
icon: `
`,
onClick: async function(){
+ var extension = path.extname($(el_item).attr('data-path')).toLowerCase();
+ if(user_preferences[`default_apps${extension}`] !== suggested_app.name){
+ const alert_resp = await UIAlert({
+ message: `${i18n('change_allways_open_with')} ` + suggested_app.title + '?',
+ buttons:[
+ {
+ label: i18n('yes'),
+ type: 'primary',
+ value: 'yes'
+ },
+ {
+ label: i18n('no')
+ },
+ ]
+ })
+ if((alert_resp) === 'yes'){
+ user_preferences['default_apps' + extension] = suggested_app.name;
+ window.mutate_user_preferences(user_preferences);
+ }
+ }
launch_app({
name: suggested_app.name,
file_path: $(el_item).attr('data-path'),
diff --git a/src/helpers.js b/src/helpers.js
index 8738632b..f2df8807 100644
--- a/src/helpers.js
+++ b/src/helpers.js
@@ -713,7 +713,7 @@ window.update_auth_data = (auth_token, user)=>{
window.mutate_user_preferences = function(user_preferences_delta) {
for (const [key, value] of Object.entries(user_preferences_delta)) {
// Don't wait for set to be done for better efficiency
- puter.kv.set(`user_preferences.${key}`, String(value));
+ puter.kv.set(`user_preferences.${key}`, value);
}
// There may be syncing issues across multiple devices
update_user_preferences({ ...window.user_preferences, ...user_preferences_delta });
@@ -2031,6 +2031,7 @@ window.open_item = async function(options){
const is_shortcut = $(el_item).attr('data-is_shortcut') === '1';
const shortcut_to_path = $(el_item).attr('data-shortcut_to_path');
const associated_app_name = $(el_item).attr('data-associated_app_name');
+ const file_uid = $(el_item).attr('data-uid')
//----------------------------------------------------------------
// Is this a shortcut whose source is perma-deleted?
//----------------------------------------------------------------
@@ -2125,6 +2126,19 @@ window.open_item = async function(options){
}
}
//----------------------------------------------------------------
+ // Do the user have a preference for this file type?
+ //----------------------------------------------------------------
+ else if(user_preferences[`default_apps${path.extname(item_path).toLowerCase()}`]) {
+ console.log('launching default app')
+ launch_app({
+ name: user_preferences[`default_apps${path.extname(item_path).toLowerCase()}`],
+ file_path: item_path,
+ window_title: path.basename(item_path),
+ maximized: options.maximized,
+ file_uid: file_uid,
+ });
+ }
+ //----------------------------------------------------------------
// Is there an app associated with this item?
//----------------------------------------------------------------
else if(associated_app_name !== ''){
diff --git a/src/i18n/translations/en.js b/src/i18n/translations/en.js
index 03541cb9..706d765d 100644
--- a/src/i18n/translations/en.js
+++ b/src/i18n/translations/en.js
@@ -36,6 +36,7 @@ const en = {
change_username: "Change Username",
close_all_windows: "Close All Windows",
close_all_windows_and_log_out: 'Close Windows and Log Out',
+ change_allways_open_with: "Do you want to always open this type of file with",
color: 'Color',
confirm_account_for_free_referral_storage_c2a: 'Create an account and confirm your email address to receive 1 GB of free storage. Your friend will get 1 GB of free storage too.',
confirm_delete_multiple_items: 'Are you sure you want to permanently delete these items?',
diff --git a/src/i18n/translations/nb.js b/src/i18n/translations/nb.js
index ede9362b..b5e309ff 100644
--- a/src/i18n/translations/nb.js
+++ b/src/i18n/translations/nb.js
@@ -35,6 +35,7 @@ const nb = {
change_username: "Endre brukernavn",
close_all_windows: "Lukk alle vinduer",
close_all_windows_and_log_out: 'Lukk alle vinduer og logg ut',
+ change_allways_open_with: "Ønsker du å alltid åpne denne filtypen med",
color: "Farge",
confirm_account_for_free_referral_storage_c2a: "Opprett en konto og bekreft e-postadressen din for å motta 1 GB gratis lagringsplass. Din venn vil også få 1 GB gratis lagringsplass.",
confirm_delete_multiple_items: 'Er du sikker på at du vil slette disse elementene permanent?',