Skip to content

Conversation

@ad1992
Copy link
Member

@ad1992 ad1992 commented Feb 7, 2024

for #7500

import { getDefaultAppState } from "../appState";

The above import results in 👇

uploaded image

Since getDefaultAppState is using t for computing default value of name, it ends up importing all locales, react and jotai as well.

This is a default state and should be independent of t. So we can stop using t in getDefaultAppState. Allowing t to be nullable and created a function getAppName in App.tsx which is used through out the app to get the ap name and exposed via the excalidrawAPI as well so host can use it as well.

This way the code stays simple and less error prone compared to just allowing the t to be empty string and the dependency of t is also removed from getDefaultState

  • update docs

@vercel
Copy link

vercel bot commented Feb 7, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
excalidraw ✅ Ready (Inspect) Visit Preview Feb 15, 2024 5:38am
excalidraw-package-example ✅ Ready (Inspect) Visit Preview Feb 15, 2024 5:38am
excalidraw-package-example-with-nextjs ✅ Ready (Inspect) Visit Preview Feb 15, 2024 5:38am
1 Ignored Deployment
Name Status Preview Updated (UTC)
docs ⬜️ Ignored (Inspect) Visit Preview Feb 15, 2024 5:38am

@github-actions
Copy link

github-actions bot commented Feb 7, 2024

Coverage Report

Status Category Percentage Covered / Total
🔴 Lines 64.98% / 70% 45748 / 70393
🔴 Statements 64.98% / 70% 45748 / 70393
🔴 Functions 66.22% / 68% 1396 / 2108
🟢 Branches 80.14% / 70% 5662 / 7065
File Coverage
File Stmts % Branch % Funcs % Lines Uncovered Lines
Changed Files
excalidraw-app/App.tsx 49.83% 64.4% 33.33% 49.83% 115-124, 169-204, 206-228, 231-262, 265-270, 273-274, 301, 329-330, 332-346, 350-353, 357-368, 371-383, 397-419, 427-481, 485-486, 489-498, 521-531, 574-597, 607-644, 647-657, 664-665, 679-692, 714-734, 754, 777-783, 792-845, 849-851, 854-858, 867-878, 882-884
excalidraw-app/components/ExportToExcalidrawPlus.tsx 28.35% 100% 0% 28.35% 30-87, 97-134
packages/excalidraw/appState.ts 98.14% 90% 71.42% 98.14% 14, 247-248, 255-256
packages/excalidraw/constants.ts 99.48% 33.33% 100% 99.48% 10-11
packages/excalidraw/types.ts 100% 100% 100% 100%
packages/excalidraw/actions/actionClipboard.tsx 28.68% 72.72% 45.45% 28.68% 21-42, 52-99, 109-111, 120-157, 168-216, 228-245, 249-254
packages/excalidraw/actions/actionExport.tsx 32.88% 61.53% 26.31% 32.88% 27-28, 30-35, 43-47, 49-85, 92-96, 98-103, 111-115, 117-125, 136, 140-177, 187-214, 218-227, 240-264, 272-276, 278-293
packages/excalidraw/components/App.tsx 68.86% 75.15% 67.37% 68.86% 454-455, 564-573, 668-669, 687-688, 708-768, 771-777, 780-783, 786-862, 865-884, 887-892, 900-910, 912-913, 918-919, 923-925, 939, 946-1204, 1264-1265, 1276-1277, 1304-1306, 1316-1361, 1387, 1397, 1404-1407, 1416-1420, 1451-1452, 1536-1545, 1550-1564, 1568-1614, 1685-1690, 1719-1724, 1727-1757, 1765-1790, 1793-1802, 1805-1917, 1920-1928, 1937-1950, 1953-1979, 1982-2053, 2056-2096, 2142-2143, 2157-2158, 2195-2196, 2200-2201, 2217-2224, 2229-2242, 2248-2249, 2254-2262, 2264-2272, 2284, 2324-2325, 2347-2348, 2355, 2416-2418, 2421-2426, 2431-2432, 2469-2477, 2482-2491, 2529-2530, 2613-2614, 2618, 2621-2622, 2630-2633, 2642-2655, 2661-2664, 2667, 2669-2670, 2677-2678, 2684-2685, 2688-2689, 2697-2698, 2701-2702, 2705-2708, 2719-2727, 2732-2733, 2789-2790, 2804-2810, 2816-2824, 2828-2836, 2840-2841, 2844-2877, 2880-2892, 2903-2904, 2915-2916, 2933-2937, 2941-2944, 2951-2953, 2971-2978, 2981, 2983-2988, 2992-2994, 3015-3016, 3023-3025, 3027-3050, 3076, 3082, 3134-3135, 3152-3154, 3176-3177, 3183-3186, 3192-3267, 3339-3340, 3345-3348, 3411, 3421-3439, 3442-3448, 3451-3452, 3458-3471, 3557-3558, 3560-3561, 3566-3568, 3576-3577, 3600-3614, 3619-3638, 3661-3662, 3722, 3741-3745, 3756-3757, 3760-3764, 3766-3767, 3769-3772, 3797-3798, 3807-3809, 3811, 3890-3893, 3915-3917, 3927-3928, 3930-3950, 3953-3959, 3976-3979, 3985-3988, 3998-4005, 4009-4010, 4015, 4043-4047, 4051, 4056-4057, 4062-4066, 4098-4099, 4102-4103, 4111-4115, 4120-4121, 4127-4137, 4142-4169, 4174-4185, 4251, 4277-4278, 4370, 4560-4561, 4564-4565, 4573, 4585, 4587-4588, 4629-4633, 4688-4694, 4700-4763, 4806, 4855, 4881, 4888-4889, 4898-4901, 4931, 4979-4982, 4985-4991, 4993-4996, 5011-5020, 5023-5024, 5105-5106, 5109, 5111-5112, 5118-5120, 5122, 5131, 5153-5158, 5160-5163, 5167-5168, 5178-5278, 5282-5283, 5297-5298, 5352-5353, 5380-5381, 5414-5440, 5447-5448, 5470-5471, 5490, 5492-5535, 5540-5541, 5543-5544, 5560-5561, 5567-5568, 5572-5575, 5578-5579, 5594-5621, 5629-5630, 5634-5637, 5639-5643, 5661-5665, 5711-5716, 5718-5720, 5736, 5738-5749, 5774-5777, 5821, 5838-5839, 5841-5864, 5879-5880, 5991-6019, 6084-6088, 6112-6113, 6133-6134, 6228, 6234-6235, 6258-6277, 6292, 6425, 6447-6488, 6492-6545, 6560, 6569, 6603-6609, 6624-6626, 6768-6771, 6795-6829, 6842, 6844-6851, 6865, 6867-6874, 6881-6884, 6892-6897, 6924-6925, 6930-6932, 6935-6936, 6961-6962, 6990-6991, 7074-7075, 7124-7137, 7197-7200, 7226-7227, 7258-7259, 7272, 7290-7296, 7303-7306, 7329-7334, 7405-7408, 7414, 7429-7436, 7439-7446, 7503, 7577-7578, 7599-7601, 7604, 7618-7642, 7748-7766, 7776-7815, 7828-7829, 7838-7845, 7859-7871, 7884-7889, 7945-7971, 7973-7974, 8048-8052, 8059, 8061-8097, 8126, 8177, 8196-8198, 8223-8228, 8230-8231, 8236-8238, 8241-8261, 8275-8276, 8282-8291, 8296, 8300-8304, 8313-8317, 8320-8325, 8329-8336, 8366, 8368-8372, 8374-8384, 8400-8402, 8413-8421, 8425-8461, 8464-8535, 8543, 8561-8568, 8570-8586, 8601-8623, 8642-8644, 8689-8690, 8720-8721, 8737, 8814-8817, 8819-8835, 8837-8841, 8853-8854, 8864-8880, 8914-8915, 8919-8931, 8941, 8943-8946, 8948-8949, 8989, 9010-9011, 9037, 9040, 9080, 9094-9101, 9118-9119, 9151-9154, 9242-9249, 9275-9276, 9317-9371, 9419-9420, 9429-9432, 9437-9438, 9459-9461, 9463-9467, 9505
packages/excalidraw/components/ImageExportDialog.tsx 73.47% 58.33% 23.07% 73.47% 43-52, 101-102, 108-134, 162-168, 176-187, 197-203, 215-221, 234-240, 251-253, 266-268, 278-280, 287-298
packages/excalidraw/components/LayerUI.tsx 83.7% 85.45% 46.42% 83.7% 322, 343-346, 366-371, 416-461, 464-468, 471-487, 494-502, 545-553, 559-562
packages/excalidraw/components/ProjectName.tsx 29.82% 100% 0% 29.82% 18-57
packages/excalidraw/data/index.ts 42.13% 100% 50% 42.13% 84-197
packages/excalidraw/data/json.ts 63.46% 57.14% 62.5% 63.46% 34-35, 37-38, 56, 60, 64-65, 72-92, 95-110, 145-156
packages/excalidraw/data/resave.ts 14.63% 100% 0% 14.63% 7-41
Generated in workflow #1895

@dwelle
Copy link
Member

dwelle commented Feb 14, 2024

Since we're keeping appState.name, I propose document it as the "user preferred (file)name for current editor session", and prefer it to props.name even when props.name is defined.

This goes hand in hand with my previous suggestion to stop preventing editing the filename when props.name is defined: #7653 (comment)

We could then even remove getAppName() (or not make it public) except it still has value for getting a canonical default name when appState.name/props.name isn't defined. So yes, we can keep it (though let's rename to getName() to align).

If we agree, there let's also do:

  • stop updating appState.name on props.name changes
  • stop preventing filename update when props.name defined

@dwelle
Copy link
Member

dwelle commented Feb 14, 2024

Made a change here to keep name as optional for user-facing export functions f1c038b (#7666) to not break the API

Makes it slightly less safe for us too, alas.

@ad1992 ad1992 merged commit 73bf50e into master Feb 15, 2024
@ad1992 ad1992 deleted the aakansha/name-removal-2 branch February 15, 2024 05:41
IvanLi-CN pushed a commit to IvanLi-CN/excalidraw that referenced this pull request Feb 24, 2024
…xcalidraw#7666)

* fix: remove t and allow name to be nullable

* pass name as required prop

* remove Unnamed

* pass name to excalidrawPlus as well for better type safe

* render once we have excalidrawAPI to avoid defaulting

* rename `getAppName` -> `getName` (temporary)

* stop preventing editing filenames when `props.name` supplied

* keep `name` as optional param for export functions

* keep `appState.name` on `props.name` state separate

* fix lint

* assertive first

* fix lint

* Add TODO

---------

Co-authored-by: dwelle <5153846+dwelle@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants