Kaynağa Gözat

Better name for app state (#1300)

* Better name for app state

* Snapshot
Lipis 5 yıl önce
ebeveyn
işleme
26fd2fe165

+ 2 - 1
src/appState.ts

@@ -1,5 +1,6 @@
 import { AppState, FlooredNumber } from "./types";
 import { getDateTime } from "./utils";
+import { t } from "./i18n";
 
 export const DEFAULT_FONT = "20px Virgil";
 
@@ -28,7 +29,7 @@ export function getDefaultAppState(): AppState {
     cursorY: 0,
     cursorButton: "up",
     scrolledOutside: false,
-    name: `excalidraw-${getDateTime()}`,
+    name: `${t("labels.untitled")}-${getDateTime()}`,
     username: "",
     isCollaborating: false,
     isResizing: false,

+ 2 - 1
src/locales/en.json

@@ -46,7 +46,8 @@
     "actions": "Actions",
     "language": "Language",
     "createRoom": "Share a live-collaboration session",
-    "duplicateSelection": "Duplicate"
+    "duplicateSelection": "Duplicate",
+    "untitled": "Untitled"
   },
   "buttons": {
     "clearReset": "Reset the canvas",

Dosya farkı çok büyük olduğundan ihmal edildi
+ 112 - 112
src/tests/__snapshots__/regressionTests.test.tsx.snap


+ 7 - 8
src/utils.ts

@@ -10,21 +10,20 @@ export function setDateTimeForTests(dateTime: string) {
   mockDateTime = dateTime;
 }
 
-export function getDateTime() {
+export const getDateTime = () => {
   if (mockDateTime) {
     return mockDateTime;
   }
 
   const date = new Date();
   const year = date.getFullYear();
-  const month = date.getMonth() + 1;
-  const day = date.getDate();
-  const hr = date.getHours();
-  const min = date.getMinutes();
-  const secs = date.getSeconds();
+  const month = `${date.getMonth() + 1}`.padStart(2, "0");
+  const day = `${date.getDate()}`.padStart(2, "0");
+  const hr = `${date.getHours()}`.padStart(2, "0");
+  const min = `${date.getMinutes()}`.padStart(2, "0");
 
-  return `${year}${month}${day}${hr}${min}${secs}`;
-}
+  return `${year}-${month}-${day}-${hr}${min}`;
+};
 
 export function capitalizeString(str: string) {
   return str.charAt(0).toUpperCase() + str.slice(1);

Bu fark içinde çok fazla dosya değişikliği olduğu için bazı dosyalar gösterilmiyor