MCPcopy Create free account
hub / github.com/error311/FileRise / openFileLinkModal

Function openFileLinkModal

public/js/fileLink.js:107–128  ·  view source on GitHub ↗
(fileObj, folder)

Source from the content-addressed store, hash-verified

105}
106
107export async function openFileLinkModal(fileObj, folder) {
108 const fileName = String(fileObj?.name || '').trim();
109 if (!fileName) {
110 showToast(t('unknown_error'), 'error');
111 return;
112 }
113 const targetFolder = String(folder || fileObj?.folder || window.currentFolder || 'root');
114 const sourceId = String(fileObj?.sourceId || (window.__frGetActiveSourceId ? window.__frGetActiveSourceId() : '') || '').trim();
115
116 try {
117 const data = await createAuthFileLink(targetFolder, fileName, sourceId);
118 const token = String(data.token || '').trim();
119 if (!token) {
120 throw new Error(t('file_link_create_failed'));
121 }
122 const link = buildInternalLink(token);
123 openFileLinkResultModal(fileName, link);
124 } catch (e) {
125 const msg = (e && e.message) ? e.message : t('file_link_create_failed');
126 showToast(t('file_link_create_failed_detail', { error: msg }), 'error');
127 }
128}

Callers 1

menuClickDelegateFunction · 0.85

Calls 5

tFunction · 0.85
createAuthFileLinkFunction · 0.85
buildInternalLinkFunction · 0.85
openFileLinkResultModalFunction · 0.85
showToastFunction · 0.70

Tested by

no test coverage detected