Skip to content

Commit

Permalink
changed App.GetNameAsync and App.SetNameAsync to App.Name - Fixed the…
Browse files Browse the repository at this point in the history
… Splashscreen bug #357 #350
  • Loading branch information
GregorBiswanger committed Apr 18, 2020
1 parent 1e3fe61 commit d660dff
Show file tree
Hide file tree
Showing 15 changed files with 112 additions and 143 deletions.
4 changes: 4 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

# 8.31.1

ElectronNET.API:

* New Feature: Electron 8.2.3 support, but not all new features (we search contributors)

# Released

# 7.30.2
Expand Down
70 changes: 34 additions & 36 deletions ElectronNET.API/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,40 @@ public event Action<bool> AccessibilitySupportChanged

private event Action<bool> _accessibilitySupportChanged;

/// <summary>
/// A property that indicates the current application's name, which is the
/// name in the application's `package.json` file.
///
/// Usually the `name` field of `package.json` is a short lowercase name, according
/// to the npm modules spec.You should usually also specify a `productName` field,
/// which is your application's full capitalized name, and which will be preferred
/// over `name` by Electron.
/// </summary>
public string Name
{
get
{
return Task.Run<string>(() =>
{
var taskCompletionSource = new TaskCompletionSource<string>();
BridgeConnector.Socket.On("appGetNameCompleted", (result) =>
{
BridgeConnector.Socket.Off("appGetNameCompleted");
taskCompletionSource.SetResult((string)result);
});
BridgeConnector.Socket.Emit("appGetName");
return taskCompletionSource.Task;
}).Result;
}
set
{
BridgeConnector.Socket.Emit("appSetName", value);
}
}

internal App()
{
CommandLine = new CommandLine();
Expand Down Expand Up @@ -551,42 +585,6 @@ public void SetPath(string name, string path)
}
}

/// <summary>
/// Usually the name field of package.json is a short lowercased name, according to
/// the npm modules spec. You should usually also specify a productName field, which
/// is your application's full capitalized name, and which will be preferred over
/// name by Electron.
/// </summary>
/// <returns>The current application’s name, which is the name in the application’s package.json file.</returns>
public async Task<string> GetNameAsync(CancellationToken cancellationToken = default(CancellationToken))
{
cancellationToken.ThrowIfCancellationRequested();

var taskCompletionSource = new TaskCompletionSource<string>();
using(cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
{
BridgeConnector.Socket.On("appGetNameCompleted", (name) =>
{
BridgeConnector.Socket.Off("appGetNameCompleted");
taskCompletionSource.SetResult(name.ToString());
});

BridgeConnector.Socket.Emit("appGetName");

return await taskCompletionSource.Task
.ConfigureAwait(false);
}
}

/// <summary>
/// Overrides the current application's name.
/// </summary>
/// <param name="name">Application's name</param>
public void SetName(string name)
{
BridgeConnector.Socket.Emit("appSetName", name);
}

/// <summary>
/// The current application locale.
/// Note: When distributing your packaged app, you have to also ship the locales
Expand Down
17 changes: 4 additions & 13 deletions ElectronNET.Host/api/app.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ElectronNET.Host/api/app.js.map

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions ElectronNET.Host/api/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,11 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
});

socket.on('appGetName', () => {
const name = app.getName();
electronSocket.emit('appGetNameCompleted', name);
electronSocket.emit('appGetNameCompleted', app.name);
});

socket.on('appSetName', (name) => {
app.setName(name);
app.name = name;
});

socket.on('appGetLocale', () => {
Expand Down
37 changes: 14 additions & 23 deletions ElectronNET.Host/api/autoUpdater.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ElectronNET.Host/api/autoUpdater.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ElectronNET.Host/api/browserWindows.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ElectronNET.Host/api/browserWindows.js.map

Large diffs are not rendered by default.

Loading

0 comments on commit d660dff

Please sign in to comment.