Skip to content

Commit 5c27b15

Browse files
committed
Merge branch 'main' of github.com:prof18/feed-flow
2 parents 8059e27 + 63b0f8d commit 5c27b15

File tree

7 files changed

+28
-3
lines changed

7 files changed

+28
-3
lines changed

core/src/jvmMain/kotlin/com/prof18/feedflow/core/utils/DesktopOS.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,5 @@ fun DesktopOS.isMacOs() = this == DesktopOS.MAC
2020
fun DesktopOS.isNotMacOs() = !isMacOs()
2121

2222
fun DesktopOS.isLinux() = this == DesktopOS.LINUX
23+
24+
fun DesktopOS.isWindows() = this == DesktopOS.WINDOWS

desktopApp/src/jvmMain/kotlin/com/prof18/feedflow/desktop/home/menubar/FileMenu.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import androidx.compose.ui.input.key.Key
55
import androidx.compose.ui.input.key.KeyShortcut
66
import androidx.compose.ui.window.MenuBarScope
77
import androidx.compose.ui.window.MenuScope
8+
import com.prof18.feedflow.core.utils.getDesktopOS
9+
import com.prof18.feedflow.core.utils.isWindows
810
import com.prof18.feedflow.shared.ui.utils.LocalFeedFlowStrings
911

1012
@Composable
@@ -81,6 +83,15 @@ internal fun MenuBarScope.FileMenu(
8183
},
8284
)
8385

86+
if (getDesktopOS().isWindows()) {
87+
Separator()
88+
89+
Item(
90+
text = LocalFeedFlowStrings.current.exitMenu,
91+
onClick = actions.onExitClick,
92+
)
93+
}
94+
8495
DebugMenu(
8596
showDebugMenu = state.showDebugMenu,
8697
deleteFeeds = actions.deleteFeeds,

desktopApp/src/jvmMain/kotlin/com/prof18/feedflow/desktop/home/menubar/MenuBar.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ data class MenuBarActions(
279279
val onFeedFontScaleClick: () -> Unit,
280280
val deleteFeeds: () -> Unit,
281281
val onBackupClick: () -> Unit,
282+
val onExitClick: () -> Unit,
282283
)
283284

284285
data class MenuBarState(

desktopApp/src/jvmMain/kotlin/com/prof18/feedflow/desktop/main/MainWindow.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,9 @@ private fun FrameWindowScope.MainWindowContent(
367367
onBackupClick = {
368368
homeViewModel.enqueueBackup()
369369
},
370+
onExitClick = {
371+
window.dispatchEvent(WindowEvent(window, WindowEvent.WINDOW_CLOSING))
372+
},
370373
),
371374
)
372375

feedSync/googledrive/src/jvmMain/kotlin/com/prof18/feedflow/feedsync/googledrive/GoogleDriveDataSourceJvmImpl.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@ class GoogleDriveDataSourceJvmImpl(
3636
override suspend fun startAuthFlow(): Boolean = withContext(dispatcherProvider.io) {
3737
try {
3838
val flow = buildAuthFlow()
39-
40-
@Suppress("MagicNumber")
41-
val receiver = LocalServerReceiver.Builder().setPort(8888).build()
39+
val receiver = buildLocalServerReceiver()
4240
val credential = AuthorizationCodeInstalledApp(flow, receiver).authorize("user")
4341

4442
driveService = Drive.Builder(httpTransport, jsonFactory, credential)
@@ -183,3 +181,5 @@ internal fun requireGoogleDriveBackupFileId(
183181
): String = fileId ?: throw GoogleDriveDownloadException(
184182
errorMessage = "No Google Drive backup file found for '$fileName'",
185183
)
184+
185+
internal fun buildLocalServerReceiver(): LocalServerReceiver = LocalServerReceiver.Builder().build()

feedSync/googledrive/src/jvmTest/kotlin/com/prof18/feedflow/feedsync/googledrive/GoogleDriveDataSourceJvmImplTest.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,11 @@ class GoogleDriveDataSourceJvmImplTest {
3030
exception.message,
3131
)
3232
}
33+
34+
@Test
35+
fun `buildLocalServerReceiver uses dynamic free port`() {
36+
val receiver = buildLocalServerReceiver()
37+
38+
assertEquals(-1, receiver.port)
39+
}
3340
}

i18n/src/commonMain/resources/locale/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@
261261
<string name="widget_background_opacity_title">Background opacity: %s%%</string>
262262
<string name="widget_font_size_title">Font size</string>
263263
<string name="file_menu">File</string>
264+
<string name="exit_menu">Exit</string>
264265
<string name="menu_view">View</string>
265266
<string name="settings_left_swipe_action">Left swipe</string>
266267
<string name="settings_right_swipe_action">Right swipe</string>

0 commit comments

Comments
 (0)