@xuda.io/account_module 1.2.1178 → 1.2.1180

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.mjs +22 -2
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -583,7 +583,7 @@ export const get_active_account_profile_info = async function (uid) {
583
583
  } catch (error) {}
584
584
  const account_profile_obj = await db_module.get_couch_doc_native('xuda_accounts', active_account_profile_id);
585
585
 
586
- const app_id = await get_account_default_project_id(account_profile_obj.uid);
586
+ const app_id = await get_account_default_project_id(account_profile_obj.shared_from_uid || account_profile_obj.uid);
587
587
 
588
588
  return { active_account_profile_id, app_id, is_main: acc_obj.account_info.active_account_profile_id === acc_obj.account_profile_id };
589
589
  };
@@ -2640,6 +2640,25 @@ export const get_account_profile_info = async function (uid, contact_profile_doc
2640
2640
  return online;
2641
2641
  };
2642
2642
 
2643
+ const stringToColour = (str) => {
2644
+ let hash = 0;
2645
+ // Generate a numeric hash from the string
2646
+ for (let i = 0; i < str.length; i++) {
2647
+ hash = str.charCodeAt(i) + ((hash << 5) - hash);
2648
+ }
2649
+ let colour = '#';
2650
+ // Convert the hash into a 6-digit hex color code
2651
+ for (let i = 0; i < 3; i++) {
2652
+ const value = (hash >> (i * 8)) & 0xff;
2653
+ colour += ('00' + value.toString(16)).substr(-2);
2654
+ }
2655
+ return colour;
2656
+ };
2657
+
2658
+ // Usage examples:
2659
+ console.log(stringToColour('User A')); // -> Consistent color for "User A"
2660
+ console.log(stringToColour('Project Z')); // -> Consistent color for "Project Z"
2661
+
2643
2662
  doc.avatar_source = account_info_ret.data.avatar_source;
2644
2663
  doc.icon_pattern = await get_pattern(doc);
2645
2664
  doc.name = doc.profile_name;
@@ -2648,7 +2667,8 @@ export const get_account_profile_info = async function (uid, contact_profile_doc
2648
2667
 
2649
2668
  doc.online = await get_online();
2650
2669
 
2651
- doc.border = account_info_ret.data.active_account_profile_id === doc._id ? 'yellow' : ''; //'#1a3557';
2670
+ // doc.border = account_info_ret.data.active_account_profile_id === doc._id ? 'yellow' : ''; //'#1a3557';
2671
+ doc.border = stringToColour(doc._id);
2652
2672
 
2653
2673
  const chats_ret = await ai_module.get_ai_chats({ uid, reference_id: doc._id });
2654
2674
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/account_module",
3
- "version": "1.2.1178",
3
+ "version": "1.2.1180",
4
4
  "description": "Xuda Account Server Module",
5
5
  "main": "index.mjs",
6
6
  "dependencies": {