MCPcopy Create free account
hub / github.com/OpenAnonymity/oa-chat / importMemoryFile

Method importMemoryFile

chat/components/MemoryEditor.js:1067–1099  ·  view source on GitHub ↗
(file)

Source from the content-addressed store, hash-verified

1065
1066 const archived = Number(result?.archived || 0);
1067 this._assertMemoryOperationActive(operation);
1068 if (archived > 0) {
1069 this.app?.showToast?.(`Archived ${archived} expired memor${archived === 1 ? 'y' : 'ies'}`, 'success');
1070 } else {
1071 this.app?.showToast?.('No expired memories found', 'info');
1072 }
1073 this.render();
1074 } catch (err) {
1075 if (this._handleMemoryOperationError(err)) return;
1076 console.error('[MemoryEditor] Clean expired error:', err);
1077 this.app?.showToast?.('Failed to clean expired memories', 'error');
1078 } finally {
1079 this._finishMemoryOperation(operation);
1080 }
1081 }
1082
1083 async _handleImportFileSelected(event) {
1084 const file = event.target.files?.[0];
1085 event.target.value = '';
1086 if (!file) return;
1087
1088 await this.importMemoryFile(file);
1089 }
1090
1091 async importMemoryFile(file) {
1092 if (!file) return;
1093 if (!this.isOpen) {
1094 // Import works with Memory off too; the preview needs the editor.
1095 const opened = await this.open({ allowWhileOff: true });
1096 if (!opened) return;
1097 }
1098
1099 const operation = this._beginMemoryOperation({ allowWhileOff: true });
1100 if (!operation) return;
1101
1102 try {

Callers 2

Calls 10

openMethod · 0.95
_beginMemoryOperationMethod · 0.95
renderMethod · 0.95
readOmfFileFunction · 0.90
validateOmfFunction · 0.90
previewOmfImportFunction · 0.90
showToastMethod · 0.80

Tested by

no test coverage detected