fun SyncedTabsView.ErrorType.toSyncedTabsListItem(context: Context, navController: NavController) = when (this) { SyncedTabsView.ErrorType.MULTIPLE_DEVICES_UNAVAILABLE -> SyncedTabsListItem.Error(errorText = context.getString(R.string.synced_tabs_connect_another_device)) SyncedTabsView.ErrorType.SYNC_ENGINE_UNAVAILABLE -> SyncedTabsListItem.Error(errorText = context.getString(R.string.synced_tabs_enable_tab_syncing)) SyncedTabsView.ErrorType.SYNC_NEEDS_REAUTHENTICATION -> SyncedTabsListItem.Error(errorText = context.getString(R.string.synced_tabs_reauth)) SyncedTabsView.ErrorType.NO_TABS_AVAILABLE -> SyncedTabsListItem.Error( errorText = context.getString(R.string.synced_tabs_no_tabs), ) SyncedTabsView.ErrorType.SYNC_UNAVAILABLE -> SyncedTabsListItem.Error( errorText = context.getString(R.string.synced_tabs_sign_in_message), errorButton = SyncedTabsListItem.ErrorButton( buttonText = context.getString(R.string.synced_tabs_sign_in_button), ) { navController.navigate(NavGraphDirections.actionGlobalTurnOnSync()) }, ) }
Converts [SyncedTabsView.ErrorType] to [SyncedTabsListItem.Error] with a lambda for ONLY [SyncedTabsView.ErrorType.SYNC_UNAVAILABLE]