|
11 | 11 | import { languages } from '$lib/localization'; |
12 | 12 | import { type PopupSettings, getModalStore, popup } from '$lib/skeletonExtensions'; |
13 | 13 | import { addQueuedModAction, hasPendingProfileChange, queuedMods } from '$lib/store/actionQueue'; |
14 | | - import { lockfileMods, manifestMods } from '$lib/store/ficsitCLIStore'; |
| 14 | + import { lockfileMods } from '$lib/store/ficsitCLIStore'; |
15 | 15 | import { error } from '$lib/store/generalStore'; |
16 | 16 | import { |
17 | 17 | debug, |
|
148 | 148 |
|
149 | 149 | async function copyModList() { |
150 | 150 | // Generate mod entries |
151 | | - const modList = await Promise.all(Object.keys($manifestMods).map(async (modReference) => { |
| 151 | + const modList = (await Promise.all(Object.keys($lockfileMods).map(async (modReference) => { |
152 | 152 | let modName = modReference; |
153 | 153 | if($offline) { |
154 | 154 | modName = (await OfflineGetMod(modReference)).name; |
|
158 | 158 | modName = result.data.getModByReference.name; |
159 | 159 | } |
160 | 160 | } |
| 161 | +
|
161 | 162 | return { |
162 | 163 | friendlyName: modName, |
163 | 164 | modReference, |
164 | 165 | version: $lockfileMods[modReference].version, |
165 | 166 | }; |
166 | | - })); |
| 167 | + }))); |
167 | 168 | // Sort by Friendly Name |
168 | 169 | modList.sort((a, b) => { |
169 | 170 | const x = a.friendlyName.toLowerCase(); |
|
180 | 181 | mod.modReference = mod.modReference.padEnd(maxModReferenceLen, ' '); |
181 | 182 | modListString += `${mod.friendlyName} ${mod.modReference} ${mod.version}\n`; |
182 | 183 | }); |
183 | | - navigator.clipboard.writeText(modListString.trim()); |
| 184 | + const markdownCodeblockFence = '```'; |
| 185 | + navigator.clipboard.writeText(`${markdownCodeblockFence}\n${modListString.trim()}\n${markdownCodeblockFence}`); |
184 | 186 | } |
185 | 187 |
|
186 | 188 | function localeName(locale: string) { |
187 | 189 | if (!locale) return 'N/A'; |
188 | 190 | return new Intl.DisplayNames([locale], { type: 'language' }).of(locale); |
189 | 191 | } |
190 | 192 |
|
| 193 | + // appease svelte "stores must be declared at the top of the file" |
| 194 | + function displayError(err: string) { |
| 195 | + $error = err; |
| 196 | + } |
| 197 | +
|
191 | 198 | $: if ($queueAutoStart && $queuedMods.length === 0 && $hasPendingProfileChange) { |
192 | 199 | $hasPendingProfileChange = false; |
193 | 200 | addQueuedModAction('__apply__', 'apply', Apply).catch((e) => error.set(e)); |
|
336 | 343 | </li> |
337 | 344 | <hr class="divider" /> |
338 | 345 | <li> |
339 | | - <button on:click={() => copyModList()}> |
| 346 | + <button |
| 347 | + on:click={() => { |
| 348 | + copyModList().catch((error) => { |
| 349 | + displayError(`failed to copy mod list: ${error}`); |
| 350 | + }); |
| 351 | + }}> |
340 | 352 | <span class="h-5 w-5"/> |
341 | 353 | <span class="flex-auto"> |
342 | 354 | <T defaultValue="Copy mod list" keyName="settings.copy-mod-list"/> |
|
0 commit comments