Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions app/Listeners/CopyIPv4Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ public function __construct()
*/
public function handle(ClickedCopyV4Link $event): void
{
Clipboard::text(
Settings::get('external_ipv4')
);
$ip = Settings::get('external_ipv4', false);

Notification::title('Copied to Clipboard')
->message(Settings::get('external_ipv4'))
->show();
if($ip) {
Clipboard::text($ip);

Notification::title('Copied to Clipboard')
->message($ip)
->show();
}
}
}
14 changes: 8 additions & 6 deletions app/Listeners/CopyIPv6Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ public function __construct()
*/
public function handle(ClickedCopyV6Link $event): void
{
Clipboard::text(
Settings::get('external_ipv6')
);
$ip = Settings::get('external_ipv6', false);

Notification::title('Copied to Clipboard')
->message(Settings::get('external_ipv6'))
->show();
if($ip) {
Clipboard::text($ip);

Notification::title('Copied to Clipboard')
->message($ip)
->show();
}
}
}
7 changes: 6 additions & 1 deletion app/Providers/NativeAppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function boot(): void
$externalIpv4 = IP::getV4();
$externalIpv6 = IP::getV6();

MenuBar::create()
$menu = MenuBar::create()
->icon(public_path('menuBarIcon.png'))
->withContextMenu(
Menu::new()
Expand All @@ -35,6 +35,11 @@ public function boot(): void
->label('Booting...')
;

if (PHP_OS_FAMILY === 'Linux') {
// without this, the context menu will not show on linux systems
$menu->onlyShowContextMenu();
}

RefreshIP::dispatchSync(onInit: true);
}
}
16 changes: 12 additions & 4 deletions app/Services/IP.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,21 @@

class IP
{
public static function getV4(): string
public static function getV4(): string|bool
{
return Http::get('https://ipv4.seeip.org')->body();
return Http::get('https://ipv4.seeip.org')->throw(function($error){
report($error);

return false;
})->body();
}

public static function getV6(): string
public static function getV6(): string|bool
{
return Http::get('https://ipv6.seeip.org')->body();
return Http::get('https://ipv6.seeip.org')->throw(function(){
report($e);

return false;
})->body();
}
}