Skip to content

Commit d660dff

Browse files
changed App.GetNameAsync and App.SetNameAsync to App.Name - Fixed the Splashscreen bug #357 #350
1 parent 1e3fe61 commit d660dff

File tree

15 files changed

+112
-143
lines changed

15 files changed

+112
-143
lines changed

Changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
# 8.31.1
44

5+
ElectronNET.API:
6+
7+
* New Feature: Electron 8.2.3 support, but not all new features (we search contributors)
8+
59
# Released
610

711
# 7.30.2

ElectronNET.API/App.cs

Lines changed: 34 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,40 @@ public event Action<bool> AccessibilitySupportChanged
351351

352352
private event Action<bool> _accessibilitySupportChanged;
353353

354+
/// <summary>
355+
/// A property that indicates the current application's name, which is the
356+
/// name in the application's `package.json` file.
357+
///
358+
/// Usually the `name` field of `package.json` is a short lowercase name, according
359+
/// to the npm modules spec.You should usually also specify a `productName` field,
360+
/// which is your application's full capitalized name, and which will be preferred
361+
/// over `name` by Electron.
362+
/// </summary>
363+
public string Name
364+
{
365+
get
366+
{
367+
return Task.Run<string>(() =>
368+
{
369+
var taskCompletionSource = new TaskCompletionSource<string>();
370+
371+
BridgeConnector.Socket.On("appGetNameCompleted", (result) =>
372+
{
373+
BridgeConnector.Socket.Off("appGetNameCompleted");
374+
taskCompletionSource.SetResult((string)result);
375+
});
376+
377+
BridgeConnector.Socket.Emit("appGetName");
378+
379+
return taskCompletionSource.Task;
380+
}).Result;
381+
}
382+
set
383+
{
384+
BridgeConnector.Socket.Emit("appSetName", value);
385+
}
386+
}
387+
354388
internal App()
355389
{
356390
CommandLine = new CommandLine();
@@ -551,42 +585,6 @@ public void SetPath(string name, string path)
551585
}
552586
}
553587

554-
/// <summary>
555-
/// Usually the name field of package.json is a short lowercased name, according to
556-
/// the npm modules spec. You should usually also specify a productName field, which
557-
/// is your application's full capitalized name, and which will be preferred over
558-
/// name by Electron.
559-
/// </summary>
560-
/// <returns>The current application’s name, which is the name in the application’s package.json file.</returns>
561-
public async Task<string> GetNameAsync(CancellationToken cancellationToken = default(CancellationToken))
562-
{
563-
cancellationToken.ThrowIfCancellationRequested();
564-
565-
var taskCompletionSource = new TaskCompletionSource<string>();
566-
using(cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
567-
{
568-
BridgeConnector.Socket.On("appGetNameCompleted", (name) =>
569-
{
570-
BridgeConnector.Socket.Off("appGetNameCompleted");
571-
taskCompletionSource.SetResult(name.ToString());
572-
});
573-
574-
BridgeConnector.Socket.Emit("appGetName");
575-
576-
return await taskCompletionSource.Task
577-
.ConfigureAwait(false);
578-
}
579-
}
580-
581-
/// <summary>
582-
/// Overrides the current application's name.
583-
/// </summary>
584-
/// <param name="name">Application's name</param>
585-
public void SetName(string name)
586-
{
587-
BridgeConnector.Socket.Emit("appSetName", name);
588-
}
589-
590588
/// <summary>
591589
/// The current application locale.
592590
/// Note: When distributing your packaged app, you have to also ship the locales

ElectronNET.Host/api/app.js

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

ElectronNET.Host/api/app.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ElectronNET.Host/api/app.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,11 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
137137
});
138138

139139
socket.on('appGetName', () => {
140-
const name = app.getName();
141-
electronSocket.emit('appGetNameCompleted', name);
140+
electronSocket.emit('appGetNameCompleted', app.name);
142141
});
143142

144143
socket.on('appSetName', (name) => {
145-
app.setName(name);
144+
app.name = name;
146145
});
147146

148147
socket.on('appGetLocale', () => {

ElectronNET.Host/api/autoUpdater.js

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

ElectronNET.Host/api/autoUpdater.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ElectronNET.Host/api/browserWindows.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ElectronNET.Host/api/browserWindows.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)