dmed-voice-assistant 1.2.14 → 1.2.16

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.
@@ -60,7 +60,7 @@ const RecordListItem = _ref => {
60
60
  const openAnchorEl = Boolean(anchorEl);
61
61
  const [isPlaying, setIsPlaying] = (0, _react.useState)(false);
62
62
  const [isEditing, setIsEditing] = (0, _react.useState)(false);
63
- const [newLabel, setNewLabel] = (0, _react.useState)(label);
63
+ const [newLabel, setNewLabel] = (0, _react.useState)("");
64
64
  const handlePopoverOpen = event => {
65
65
  setAnchorEl(event.currentTarget);
66
66
  };
@@ -111,6 +111,9 @@ const RecordListItem = _ref => {
111
111
  }
112
112
  handlePopoverClose();
113
113
  };
114
+ (0, _react.useEffect)(() => {
115
+ setNewLabel(label);
116
+ }, [label]);
114
117
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
115
118
  children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
116
119
  className: "flex items-center justify-between",
package/dist/recorder.js CHANGED
@@ -75,6 +75,7 @@ const RecorderBox = _ref => {
75
75
  };
76
76
  const initRecorder = async () => {
77
77
  try {
78
+ fetchAudioInputDevices();
78
79
  const stream = await navigator.mediaDevices.getUserMedia({
79
80
  audio: true
80
81
  });
@@ -86,6 +87,27 @@ const RecorderBox = _ref => {
86
87
  console.error("Unable to access microphone", error);
87
88
  }
88
89
  };
90
+ const fetchAudioInputDevices = async () => {
91
+ try {
92
+ // Request permission to access media devices
93
+ await navigator.mediaDevices.getUserMedia({
94
+ audio: true
95
+ });
96
+
97
+ // Enumerate all media devices
98
+ const devices = await navigator.mediaDevices.enumerateDevices();
99
+
100
+ // Filter only audio input devices
101
+ const audioInputs = devices.filter(device => device.kind === "audioinput");
102
+ let temp = ['Auto-Detect'];
103
+ audioInputs.forEach(device => {
104
+ temp.push(device.label);
105
+ });
106
+ setVoiceList(temp);
107
+ } catch (error) {
108
+ console.error("Error accessing audio devices:", error);
109
+ }
110
+ };
89
111
  const startRecording = async () => {
90
112
  if (!mediaRecorderRef.current) {
91
113
  await initRecorder();
@@ -151,10 +173,11 @@ const RecorderBox = _ref => {
151
173
  }
152
174
  };
153
175
  const handleDelete = id => {
154
- setRecordList(prevRecords => prevRecords.filter((record, index) => index !== id));
176
+ // setRecordList((prevList) => prevList.filter((record) => record.union_id !== id));
177
+
155
178
  if (onRecordDeleteEvent) {
156
179
  onRecordDeleteEvent({
157
- id: recordList[id].union_id
180
+ id: id
158
181
  });
159
182
  }
160
183
  };
@@ -174,31 +197,7 @@ const RecorderBox = _ref => {
174
197
  setIsRunning(false); // Set the counter as not running
175
198
  };
176
199
  (0, _react.useEffect)(() => {
177
- const fetchAudioInputDevices = async () => {
178
- try {
179
- // Request permission to access media devices
180
- await navigator.mediaDevices.getUserMedia({
181
- audio: true
182
- });
183
-
184
- // Enumerate all media devices
185
- const devices = await navigator.mediaDevices.enumerateDevices();
186
-
187
- // Filter only audio input devices
188
- const audioInputs = devices.filter(device => device.kind === "audioinput");
189
- let temp = ['Auto-Detect'];
190
- audioInputs.forEach(device => {
191
- temp.push(device.label);
192
- });
193
- setVoiceList(temp);
194
- } catch (error) {
195
- console.error("Error accessing audio devices:", error);
196
- }
197
- };
198
- fetchAudioInputDevices();
199
- }, []);
200
- (0, _react.useEffect)(() => {
201
- setRecordList(recordHistoryList);
200
+ setRecordList([...recordHistoryList]);
202
201
  }, [recordHistoryList]);
203
202
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
204
203
  className: "bg-[#0B0B0B] rounded-[5px] border p-[20px] w-[850px]",
@@ -590,7 +589,7 @@ const RecorderBox = _ref => {
590
589
  time: parseInt(record.voice_duration),
591
590
  createdDate: record.date,
592
591
  onLabelChange: newLabel => handleLabelChange(index, newLabel),
593
- onDelete: () => handleDelete(index)
592
+ onDelete: () => handleDelete(record.union_id)
594
593
  }, index);
595
594
  })
596
595
  })]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dmed-voice-assistant",
3
- "version": "1.2.14",
3
+ "version": "1.2.16",
4
4
  "main": "dist/index.js",
5
5
  "files": [
6
6
  "dist"