Skip to content

Commit 2565118

Browse files
committed
electron app: add preview mode option to open window without recording
1 parent e0615fa commit 2565118

File tree

4 files changed

+21
-11
lines changed

4 files changed

+21
-11
lines changed

src/electron/electron-rec-preload.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ const { ipcRenderer, contextBridge } = require('electron');
1111

1212
// ===========================================================================
1313
contextBridge.exposeInMainWorld('archivewebpage', {
14-
record: (url, collId) => {
15-
ipcRenderer.send("start-rec", url, collId);
14+
record: (url, collId, startRec) => {
15+
ipcRenderer.send("start-rec", url, collId, startRec);
1616
},
1717

1818
ipfsPin: (collId) => {

src/electron/electron-recorder-app.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ class ElectronRecorderApp extends ElectronReplayApp
3939

4040
app.userAgentFallback = desktopUA;
4141

42-
ipcMain.on("start-rec", (event, url, collId) => {
43-
this.createRecordWindow(url, collId);
42+
ipcMain.on("start-rec", (event, url, collId, startRec) => {
43+
this.createRecordWindow(url, collId, startRec);
4444
});
4545

4646
ipcMain.on("start-ipfs", (event, validPins) => {
@@ -217,7 +217,7 @@ class ElectronRecorderApp extends ElectronReplayApp
217217

218218
view.webContents.on("new-window", (event, url, frameName, disposition, options, additionalFeatures, referrer) => {
219219
event.preventDefault();
220-
event.newGuest = this.createRecordWindow(url, collId);
220+
event.newGuest = this.createRecordWindow(url, collId, startRec);
221221
console.log("new-window", url, frameName, disposition, options, additionalFeatures, referrer);
222222
});
223223

src/ui.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ class ArchiveWebApp extends ReplayWebApp
232232
</div>
233233
</div>
234234
235-
<form class="is-flex" @submit="${this.onStartRecord}">
235+
<form class="is-flex is-flex-direction-row" @submit="${this.onStartRecord}">
236236
<div class="field has-addons">
237237
<p class="control is-expanded">
238238
<input class="input" type="url" required
@@ -248,6 +248,10 @@ class ArchiveWebApp extends ReplayWebApp
248248
</button>
249249
</div>
250250
</div>
251+
${IS_APP ? html`
252+
<label class="checkbox">
253+
<input id="preview" type="checkbox"><span>&nbsp;Start in Preview Mode (without recording.)</span>
254+
</label>` : ``}
251255
</form>
252256
</wr-modal>`;
253257
}
@@ -264,7 +268,7 @@ class ArchiveWebApp extends ReplayWebApp
264268
<section class="modal-card-body">
265269
<div class="container">
266270
<div class="content">
267-
<div style="display: flex">
271+
<div class="is-flex">
268272
<div class="has-text-centered" style="width: 220px">
269273
<fa-icon class="logo" size="48px" .svg="${wrLogo}"></fa-icon>
270274
<div style="font-size: smaller; margin-bottom: 1em">${IS_APP ? 'App' : 'Extension'} v${__VERSION__}</div>
@@ -359,7 +363,9 @@ class ArchiveWebApp extends ReplayWebApp
359363
collId: this.selCollId,
360364
});
361365
} else if (window.archivewebpage && window.archivewebpage.record) {
362-
window.archivewebpage.record(url, this.selCollId);
366+
const previewCheckbox = this.renderRoot.querySelector("#preview");
367+
const startRec = !(previewCheckbox && previewCheckbox.checked);
368+
window.archivewebpage.record(url, this.selCollId, startRec);
363369
}
364370
return false;
365371
}

wr-ext/replay/ui.js

Lines changed: 7 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)