Skip to content

Commit

Permalink
Remove react-toastify in favour of react-hot-toast
Browse files Browse the repository at this point in the history
  • Loading branch information
marcus-crane committed Jun 2, 2022
1 parent 3dcbe93 commit 3a78a56
Show file tree
Hide file tree
Showing 21 changed files with 338 additions and 447 deletions.
28 changes: 15 additions & 13 deletions backend/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,27 +149,29 @@ func (Bookmark) TableName() string {

func GetKoboMetadata(detectedPaths []string) []Kobo {
var kobos []Kobo
log.Debug().Int("path_count", len(detectedPaths)).Msg("Found the location of possible Kobo(s)")
for _, path := range detectedPaths {
_, _, deviceId, err := kobo.ParseKoboVersion(path)
if err != nil {
log.Error().Err(err).Msg("Failed to parse Kobo version")
log.Error().Msg(fmt.Sprintf("Failed to parse version for Kobo at %s", path))
}
log.Debug().Str("device_id", deviceId).Msg("Found Kobo")
log.Debug().Msg(fmt.Sprintf("Found device with ID %s", deviceId))
device, found := kobo.DeviceByID(deviceId)
if !found {
log.Warn().Msg("Found a device that isn't officially supported but may still work anyway")
// We can handle unsupported Kobos in future but at present, there are none
log.Debug().Str("device_id", deviceId).Msg("Found an unrecognised Kobo")
continue
kobos = append(kobos, Kobo{
MntPath: path,
DbPath: fmt.Sprintf("%s/.kobo/KoboReader.sqlite", path),
})
} else {
kobos = append(kobos, Kobo{
Name: device.Name(),
Storage: device.StorageGB(),
DisplayPPI: device.DisplayPPI(),
MntPath: path,
DbPath: fmt.Sprintf("%s/.kobo/KoboReader.sqlite", path),
})
}
log.Info().Str("device_name", device.Name()).Msg("Identified Kobo")
kobos = append(kobos, Kobo{
Name: device.Name(),
Storage: device.StorageGB(),
DisplayPPI: device.DisplayPPI(),
MntPath: path,
DbPath: fmt.Sprintf("%s/.kobo/KoboReader.sqlite", path),
})
}
return kobos
}
Expand Down
9 changes: 0 additions & 9 deletions backend/device_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,6 @@ func TestGetKoboMetadata_HandleNoDevices(t *testing.T) {
assert.Equal(t, expected, actual)
}

// If you were to disconnect a device at the precise time between getting the connected paths
// and checking the version at those paths, it would look the same as trying to access a file
// that doesn't exist
func TestGetKoboMetadata_HandleDisconnectedDevice(t *testing.T) {
var expected []Kobo
actual := GetKoboMetadata([]string{os.TempDir()})
assert.Equal(t, expected, actual)
}

func TestGetKoboMetadata_HandleConnectedDevices(t *testing.T) {
libraTempDir := t.TempDir()
fakeLibraVolume := setupTmpKobo(libraTempDir, libraTwoDeviceId)
Expand Down
1 change: 0 additions & 1 deletion frontend/dist/assets/index.0b1a9ab5.css

This file was deleted.

234 changes: 234 additions & 0 deletions frontend/dist/assets/index.9fa72c53.js

Large diffs are not rendered by default.

234 changes: 0 additions & 234 deletions frontend/dist/assets/index.bc6cfc65.js

This file was deleted.

1 change: 1 addition & 0 deletions frontend/dist/assets/index.c7d5b2c6.css

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

4 changes: 2 additions & 2 deletions frontend/dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<meta charset="UTF-8" />
<meta content="width=device-width, initial-scale=1.0" name="viewport" />
<title>October</title>
<script type="module" crossorigin src="/assets/index.bc6cfc65.js"></script>
<link rel="stylesheet" href="/assets/index.0b1a9ab5.css">
<script type="module" crossorigin src="/assets/index.9fa72c53.js"></script>
<link rel="stylesheet" href="/assets/index.c7d5b2c6.css">
</head>
<body class="max-h-screen bg-gray-100 dark:bg-gray-800">
<div id="root"></div>
Expand Down
36 changes: 1 addition & 35 deletions frontend/package-lock.json

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

3 changes: 1 addition & 2 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
"react": "^18.1.0",
"react-dom": "^18.1.0",
"react-hot-toast": "^2.2.0",
"react-router-dom": "^6.3.0",
"react-toastify": "^9.0.3"
"react-router-dom": "^6.3.0"
},
"scripts": {
"dev": "vite",
Expand Down
16 changes: 12 additions & 4 deletions frontend/src/main.jsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
import React from 'react';
import { createRoot } from 'react-dom/client'
import { HashRouter, Route, Routes } from "react-router-dom"
import { Toaster } from 'react-hot-toast'

import 'react-toastify/dist/ReactToastify.css';
import './style.css';
import DeviceSelector from './pages/DeviceSelector';
import Overview from './pages/Overview';
import Settings from './pages/Settings';

import Router from './router';
import './style.css';

const routes = (
<React.StrictMode>
<Router />
<HashRouter>
<Routes>
<Route path="/" element={<DeviceSelector />} />
<Route path="/overview" element={<Overview />} />
<Route path="/settings" element={<Settings />} />
</Routes>
</HashRouter>
<Toaster />
</React.StrictMode>
)
Expand Down
Loading

0 comments on commit 3a78a56

Please sign in to comment.