Skip to content

Commit fb7c214

Browse files
committed
fix crop
1 parent 4366f49 commit fb7c214

7 files changed

Lines changed: 60 additions & 22 deletions

File tree

.github/workflows/deploy-pages.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
- run: npm run build
3232
env:
3333
BASE_PATH: ''
34-
- run: cp build/index.html build/404.html
34+
- run: cp build/200.html build/404.html
3535
- run: touch build/.nojekyll
3636
- uses: actions/upload-pages-artifact@v3
3737
with:

electron/main.cjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,10 @@ function registerNotificationHandlers() {
245245
});
246246
}
247247

248+
function registerAppInfoHandlers() {
249+
ipcMain.handle('app-info:version', () => app.getVersion());
250+
}
251+
248252
async function uploadToNostrBuild(payload) {
249253
const authorization = typeof payload?.authorization === 'string' ? payload.authorization : '';
250254
const mediaType = ['avatar', 'banner', 'media'].includes(payload?.mediaType) ? payload.mediaType : 'media';
@@ -313,6 +317,7 @@ if (!gotSingleInstanceLock) {
313317
});
314318

315319
app.whenReady().then(() => {
320+
registerAppInfoHandlers();
316321
registerSecureSessionHandlers();
317322
registerUploadHandlers();
318323
registerNotificationHandlers();

electron/preload.cjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,7 @@ contextBridge.exposeInMainWorld('nostrDesktopNotifications', {
1515
isAvailable: () => ipcRenderer.invoke('notification:available'),
1616
show: (payload) => ipcRenderer.invoke('notification:show', payload)
1717
});
18+
19+
contextBridge.exposeInMainWorld('nostrDesktopApp', {
20+
version: () => ipcRenderer.invoke('app-info:version')
21+
});

src/app.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ declare global {
2323
isAvailable(): Promise<boolean>;
2424
show(payload: { title: string; body: string; route: string }): Promise<boolean>;
2525
};
26+
nostrDesktopApp?: {
27+
version(): Promise<string>;
28+
};
2629
nostr?: {
2730
getPublicKey(): Promise<string>;
2831
signEvent(event: Record<string, unknown>): Promise<Record<string, unknown>>;

src/lib/components/ImageCropDialog.svelte

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -206,28 +206,35 @@
206206
cropImageNaturalHeight = cropImageElement.naturalHeight;
207207
resetCrop();
208208
}}
209+
on:error={() => {
210+
cropImageNaturalWidth = 0;
211+
cropImageNaturalHeight = 0;
212+
error = 'Could not read this image. Try saving it as a JPEG or PNG first.';
213+
}}
209214
/>
210-
<div
211-
class="crop-box"
212-
style={cropBoxStyle}
213-
role="presentation"
214-
on:pointerdown={startCropDrag}
215-
on:pointermove={dragCrop}
216-
on:pointerup={stopCropDrag}
217-
on:pointercancel={stopCropDrag}
218-
>
219-
{#each cropResizeHandles as handle}
220-
<button
221-
type="button"
222-
class={`crop-handle ${handle}`}
223-
aria-label={`Resize crop ${handle}`}
224-
on:pointerdown={(event) => startCropResize(event, handle)}
225-
on:pointermove={resizeCrop}
226-
on:pointerup={stopCropResize}
227-
on:pointercancel={stopCropResize}
228-
></button>
229-
{/each}
230-
</div>
215+
{#if cropImageNaturalWidth && cropImageNaturalHeight}
216+
<div
217+
class="crop-box"
218+
style={cropBoxStyle}
219+
role="presentation"
220+
on:pointerdown={startCropDrag}
221+
on:pointermove={dragCrop}
222+
on:pointerup={stopCropDrag}
223+
on:pointercancel={stopCropDrag}
224+
>
225+
{#each cropResizeHandles as handle}
226+
<button
227+
type="button"
228+
class={`crop-handle ${handle}`}
229+
aria-label={`Resize crop ${handle}`}
230+
on:pointerdown={(event) => startCropResize(event, handle)}
231+
on:pointermove={resizeCrop}
232+
on:pointerup={stopCropResize}
233+
on:pointercancel={stopCropResize}
234+
></button>
235+
{/each}
236+
</div>
237+
{/if}
231238
</div>
232239
<div class="crop-controls">
233240
<span>Drag the edges or corners to crop.</span>

src/lib/components/RightRail.svelte

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,13 @@
2727
let installed = false;
2828
let installBusy = false;
2929
let installDialogOpen = false;
30+
let desktopAppVersion = '';
3031
3132
$: showInstallButton = !installed;
3233
3334
onMount(() => {
3435
installed = isStandalone();
36+
void loadDesktopAppVersion();
3537
const beforeInstallPrompt = (event: Event) => {
3638
event.preventDefault();
3739
installPrompt = event as BeforeInstallPromptEvent;
@@ -72,6 +74,10 @@
7274
function isStandalone() {
7375
return window.matchMedia('(display-mode: standalone)').matches || window.matchMedia('(display-mode: window-controls-overlay)').matches;
7476
}
77+
78+
async function loadDesktopAppVersion() {
79+
desktopAppVersion = (await window.nostrDesktopApp?.version().catch(() => '')) ?? '';
80+
}
7581
</script>
7682

7783
<aside class="rail" class:collapsed>
@@ -112,6 +118,10 @@
112118
</section>
113119

114120
{/if}
121+
122+
{#if desktopAppVersion}
123+
<div class="desktop-version">v{desktopAppVersion}</div>
124+
{/if}
115125
{/if}
116126
</aside>
117127

src/styles.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1394,6 +1394,14 @@ label span, label strong { color: var(--text); }
13941394
}
13951395
.rail .panel { box-shadow: none; }
13961396
.rail .panel > button { width: 100%; justify-content: flex-start; margin-top: 8px; }
1397+
.desktop-version {
1398+
justify-self: end;
1399+
margin-top: -4px;
1400+
color: var(--muted);
1401+
font-size: 11px;
1402+
font-weight: 800;
1403+
line-height: 1;
1404+
}
13971405
.desktop-install-dialog .dialog-head {
13981406
align-items: start;
13991407
}
@@ -1647,6 +1655,7 @@ label span, label strong { color: var(--text); }
16471655
.crop-frame {
16481656
position: relative;
16491657
width: 100%;
1658+
aspect-ratio: 1 / 1;
16501659
max-height: min(62svh, 640px);
16511660
overflow: hidden;
16521661
border: 1px solid var(--line);

0 commit comments

Comments
 (0)