Skip to content

Commit

Permalink
~ Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
modernben committed Aug 1, 2023
1 parent 1de7a29 commit f7da627
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 57 deletions.
36 changes: 14 additions & 22 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,23 @@
namespace App\Console;

use App\Jobs\RefreshIP;
use Native\Laravel\Facades\MenuBar;
use Illuminate\Support\Facades\Http;
use Native\Laravel\Facades\Settings;
use Native\Laravel\Facades\Notification;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

class Kernel extends ConsoleKernel
{



protected function schedule(Schedule $schedule): void
{
// update IP address every minute
$schedule->job(RefreshIP::class)->everyMinute();
}




protected function commands(): void
{
$this->load(__DIR__.'/Commands');

require base_path('routes/console.php');
}
protected function schedule(Schedule $schedule): void
{
// update IP address every minute
$schedule->call(function(){
RefreshIP::dispatchSync();
})->everyMinute();
}

protected function commands(): void
{
$this->load(__DIR__.'/Commands');

require base_path('routes/console.php');
}
}
6 changes: 5 additions & 1 deletion app/Jobs/RefreshIP.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
namespace App\Jobs;

use App\Services\IP;
use Illuminate\Support\Str;
use Illuminate\Bus\Queueable;
use Native\Laravel\Menu\Menu;
use App\Events\ClickedCopyV4Link;
use App\Events\ClickedCopyV6Link;
use Native\Laravel\Facades\MenuBar;
use Native\Laravel\Facades\Settings;
use Illuminate\Queue\SerializesModels;
Expand All @@ -13,7 +17,7 @@
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Contracts\Queue\ShouldBeUnique;

class RefreshIP implements ShouldQueue
class RefreshIP
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

Expand Down
8 changes: 0 additions & 8 deletions app/Listeners/CopyIPv4Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,6 @@

class CopyIPv4Address
{
/**
* Create the event listener.
*/
public function __construct()
{
//
}

/**
* Handle the event.
*/
Expand Down
8 changes: 0 additions & 8 deletions app/Listeners/CopyIPv6Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,6 @@

class CopyIPv6Address
{
/**
* Create the event listener.
*/
public function __construct()
{
//
}

/**
* Handle the event.
*/
Expand Down
10 changes: 3 additions & 7 deletions app/Providers/NativeAppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ public function boot(): void
$externalIpv4 = IP::getV4();
$externalIpv6 = IP::getV6();

$menu = MenuBar::create()
MenuBar::create()
->icon(public_path('menuBarIcon.png'))
->withContextMenu(
Menu::new()
->event(ClickedCopyV4Link::class, 'IPv4: ' . $externalIpv4)
->event(ClickedCopyV4Link::class, 'IPv4: ' . $externalIpv4 ?: 'N/A')
->event(ClickedCopyV6Link::class, 'IPv6: ' . (Str::contains($externalIpv6, '::') ? $externalIpv6 : 'N/A'))
->separator()
->link('https://whatismyipaddress.com', 'What Is My IP?')
Expand All @@ -33,13 +33,9 @@ public function boot(): void
'url' => 'https://whatismyipaddress.com/'
])
->label('Booting...')
->onlyShowContextMenu()
;

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

RefreshIP::dispatchSync(onInit: true);
}
}
8 changes: 4 additions & 4 deletions app/Services/IP.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ class IP
public static function getV4(): string|bool
{
return Http::get('https://ipv4.seeip.org')->throw(function($error){
report($error);
report($error);

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

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

return false;
})->body();
Expand Down
62 changes: 55 additions & 7 deletions composer.lock

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

0 comments on commit f7da627

Please sign in to comment.