kopia lustrzana https://github.com/ryukoposting/Signal-Android
Only display outgoing messages when entering viewer through my stories.
rodzic
d40be0abf8
commit
cb7b2d90d5
|
@ -191,7 +191,7 @@ public abstract class MessageDatabase extends Database implements MmsSmsColumns
|
||||||
public abstract @NonNull Reader getOutgoingStoriesTo(@NonNull RecipientId recipientId);
|
public abstract @NonNull Reader getOutgoingStoriesTo(@NonNull RecipientId recipientId);
|
||||||
public abstract @NonNull Reader getAllOutgoingStories(boolean reverse, int limit);
|
public abstract @NonNull Reader getAllOutgoingStories(boolean reverse, int limit);
|
||||||
public abstract @NonNull Reader getAllOutgoingStoriesAt(long sentTimestamp);
|
public abstract @NonNull Reader getAllOutgoingStoriesAt(long sentTimestamp);
|
||||||
public abstract @NonNull List<StoryResult> getOrderedStoryRecipientsAndIds();
|
public abstract @NonNull List<StoryResult> getOrderedStoryRecipientsAndIds(boolean isOutgoingOnly);
|
||||||
public abstract @NonNull Reader getAllStoriesFor(@NonNull RecipientId recipientId, int limit);
|
public abstract @NonNull Reader getAllStoriesFor(@NonNull RecipientId recipientId, int limit);
|
||||||
public abstract @NonNull MessageId getStoryId(@NonNull RecipientId authorId, long sentTimestamp) throws NoSuchMessageException;
|
public abstract @NonNull MessageId getStoryId(@NonNull RecipientId authorId, long sentTimestamp) throws NoSuchMessageException;
|
||||||
public abstract int getNumberOfStoryReplies(long parentStoryId);
|
public abstract int getNumberOfStoryReplies(long parentStoryId);
|
||||||
|
|
|
@ -613,7 +613,7 @@ public class MmsDatabase extends MessageDatabase {
|
||||||
whereArgs = SqlUtil.buildArgs(recipientId);
|
whereArgs = SqlUtil.buildArgs(recipientId);
|
||||||
} else {
|
} else {
|
||||||
where += " AND " + THREAD_ID_WHERE;
|
where += " AND " + THREAD_ID_WHERE;
|
||||||
whereArgs = SqlUtil.buildArgs(1, 0, threadId);
|
whereArgs = SqlUtil.buildArgs(threadId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Reader(rawQuery(where, whereArgs));
|
return new Reader(rawQuery(where, whereArgs));
|
||||||
|
@ -798,7 +798,8 @@ public class MmsDatabase extends MessageDatabase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NonNull List<StoryResult> getOrderedStoryRecipientsAndIds() {
|
public @NonNull List<StoryResult> getOrderedStoryRecipientsAndIds(boolean isOutgoingOnly) {
|
||||||
|
String where = "WHERE is_story > 0 AND remote_deleted = 0" + (isOutgoingOnly ? " AND is_outgoing != 0" : "") + "\n";
|
||||||
SQLiteDatabase db = getReadableDatabase();
|
SQLiteDatabase db = getReadableDatabase();
|
||||||
String query = "SELECT\n"
|
String query = "SELECT\n"
|
||||||
+ " mms.date AS sent_timestamp,\n"
|
+ " mms.date AS sent_timestamp,\n"
|
||||||
|
@ -812,7 +813,7 @@ public class MmsDatabase extends MessageDatabase {
|
||||||
+ "FROM mms\n"
|
+ "FROM mms\n"
|
||||||
+ "JOIN thread\n"
|
+ "JOIN thread\n"
|
||||||
+ "ON mms.thread_id = thread._id\n"
|
+ "ON mms.thread_id = thread._id\n"
|
||||||
+ "WHERE is_story > 0 AND remote_deleted = 0\n"
|
+ where
|
||||||
+ "ORDER BY\n"
|
+ "ORDER BY\n"
|
||||||
+ "is_unread DESC,\n"
|
+ "is_unread DESC,\n"
|
||||||
+ "CASE\n"
|
+ "CASE\n"
|
||||||
|
|
|
@ -1413,7 +1413,7 @@ public class SmsDatabase extends MessageDatabase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NonNull List<StoryResult> getOrderedStoryRecipientsAndIds() {
|
public @NonNull List<StoryResult> getOrderedStoryRecipientsAndIds(boolean isOutgoingOnly) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,8 @@ data class StoryViewerArgs(
|
||||||
val groupReplyStartPosition: Int = -1,
|
val groupReplyStartPosition: Int = -1,
|
||||||
val isUnviewedOnly: Boolean = false,
|
val isUnviewedOnly: Boolean = false,
|
||||||
val isFromInfoContextMenuAction: Boolean = false,
|
val isFromInfoContextMenuAction: Boolean = false,
|
||||||
val isFromQuote: Boolean = false
|
val isFromQuote: Boolean = false,
|
||||||
|
val isFromMyStories: Boolean = false
|
||||||
) : Parcelable {
|
) : Parcelable {
|
||||||
|
|
||||||
class Builder(private val recipientId: RecipientId, private val isInHiddenStoryMode: Boolean) {
|
class Builder(private val recipientId: RecipientId, private val isInHiddenStoryMode: Boolean) {
|
||||||
|
|
|
@ -34,7 +34,7 @@ class StoriesLandingRepository(context: Context) {
|
||||||
val myStoriesId = SignalDatabase.recipients.getOrInsertFromDistributionListId(DistributionListId.MY_STORY)
|
val myStoriesId = SignalDatabase.recipients.getOrInsertFromDistributionListId(DistributionListId.MY_STORY)
|
||||||
val myStories = Recipient.resolved(myStoriesId)
|
val myStories = Recipient.resolved(myStoriesId)
|
||||||
|
|
||||||
val stories = SignalDatabase.mms.orderedStoryRecipientsAndIds
|
val stories = SignalDatabase.mms.getOrderedStoryRecipientsAndIds(false)
|
||||||
val mapping: MutableMap<Recipient, List<StoryResult>> = mutableMapOf()
|
val mapping: MutableMap<Recipient, List<StoryResult>> = mutableMapOf()
|
||||||
|
|
||||||
stories.forEach {
|
stories.forEach {
|
||||||
|
|
|
@ -151,7 +151,8 @@ class MyStoriesFragment : DSLSettingsFragment(
|
||||||
storyThumbTextModel = text,
|
storyThumbTextModel = text,
|
||||||
storyThumbUri = image,
|
storyThumbUri = image,
|
||||||
storyThumbBlur = blur,
|
storyThumbBlur = blur,
|
||||||
isFromInfoContextMenuAction = isFromInfoContextMenuAction
|
isFromInfoContextMenuAction = isFromInfoContextMenuAction,
|
||||||
|
isFromMyStories = true
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
options.toBundle()
|
options.toBundle()
|
||||||
|
|
|
@ -51,6 +51,7 @@ class StoryViewerFragment :
|
||||||
storyViewerArgs.isFromNotification,
|
storyViewerArgs.isFromNotification,
|
||||||
storyViewerArgs.groupReplyStartPosition,
|
storyViewerArgs.groupReplyStartPosition,
|
||||||
storyViewerArgs.isUnviewedOnly,
|
storyViewerArgs.isUnviewedOnly,
|
||||||
|
storyViewerArgs.isFromMyStories,
|
||||||
storyViewerArgs.isFromInfoContextMenuAction
|
storyViewerArgs.isFromInfoContextMenuAction
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ class StoryViewerPagerAdapter(
|
||||||
private val isFromNotification: Boolean,
|
private val isFromNotification: Boolean,
|
||||||
private val groupReplyStartPosition: Int,
|
private val groupReplyStartPosition: Int,
|
||||||
private val isUnviewedOnly: Boolean,
|
private val isUnviewedOnly: Boolean,
|
||||||
|
private val isOutgoingOnly: Boolean,
|
||||||
private val isFromInfoContextMenuAction: Boolean
|
private val isFromInfoContextMenuAction: Boolean
|
||||||
) : FragmentStateAdapter(fragment) {
|
) : FragmentStateAdapter(fragment) {
|
||||||
|
|
||||||
|
@ -34,7 +35,7 @@ class StoryViewerPagerAdapter(
|
||||||
override fun getItemCount(): Int = pages.size
|
override fun getItemCount(): Int = pages.size
|
||||||
|
|
||||||
override fun createFragment(position: Int): Fragment {
|
override fun createFragment(position: Int): Fragment {
|
||||||
return StoryViewerPageFragment.create(pages[position], initialStoryId, isFromNotification, groupReplyStartPosition, isUnviewedOnly, isFromInfoContextMenuAction)
|
return StoryViewerPageFragment.create(pages[position], initialStoryId, isFromNotification, groupReplyStartPosition, isUnviewedOnly, isOutgoingOnly, isFromInfoContextMenuAction)
|
||||||
}
|
}
|
||||||
|
|
||||||
private class Callback(
|
private class Callback(
|
||||||
|
|
|
@ -36,12 +36,12 @@ open class StoryViewerRepository {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getStories(hiddenStories: Boolean, unviewedOnly: Boolean): Single<List<RecipientId>> {
|
fun getStories(hiddenStories: Boolean, unviewedOnly: Boolean, isOutgoingOnly: Boolean): Single<List<RecipientId>> {
|
||||||
return Single.create<List<RecipientId>> { emitter ->
|
return Single.create<List<RecipientId>> { emitter ->
|
||||||
val myStoriesId = SignalDatabase.recipients.getOrInsertFromDistributionListId(DistributionListId.MY_STORY)
|
val myStoriesId = SignalDatabase.recipients.getOrInsertFromDistributionListId(DistributionListId.MY_STORY)
|
||||||
val myStories = Recipient.resolved(myStoriesId)
|
val myStories = Recipient.resolved(myStoriesId)
|
||||||
val releaseChannelId = SignalStore.releaseChannelValues().releaseChannelRecipientId
|
val releaseChannelId = SignalStore.releaseChannelValues().releaseChannelRecipientId
|
||||||
val recipientIds = SignalDatabase.mms.orderedStoryRecipientsAndIds.groupBy {
|
val recipientIds = SignalDatabase.mms.getOrderedStoryRecipientsAndIds(isOutgoingOnly).groupBy {
|
||||||
val recipient = Recipient.resolved(it.recipientId)
|
val recipient = Recipient.resolved(it.recipientId)
|
||||||
if (recipient.isDistributionList) {
|
if (recipient.isDistributionList) {
|
||||||
myStories
|
myStories
|
||||||
|
|
|
@ -89,7 +89,8 @@ class StoryViewerViewModel(
|
||||||
} else {
|
} else {
|
||||||
repository.getStories(
|
repository.getStories(
|
||||||
hiddenStories = storyViewerArgs.isInHiddenStoryMode,
|
hiddenStories = storyViewerArgs.isInHiddenStoryMode,
|
||||||
unviewedOnly = storyViewerArgs.isUnviewedOnly
|
unviewedOnly = storyViewerArgs.isUnviewedOnly,
|
||||||
|
isOutgoingOnly = storyViewerArgs.isFromMyStories
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,6 +115,7 @@ class StoryViewerPageFragment :
|
||||||
storyRecipientId,
|
storyRecipientId,
|
||||||
initialStoryId,
|
initialStoryId,
|
||||||
isUnviewedOnly,
|
isUnviewedOnly,
|
||||||
|
isOutgoingOnly,
|
||||||
StoryViewerPageRepository(
|
StoryViewerPageRepository(
|
||||||
requireContext()
|
requireContext()
|
||||||
),
|
),
|
||||||
|
@ -150,6 +151,9 @@ class StoryViewerPageFragment :
|
||||||
private val isUnviewedOnly: Boolean
|
private val isUnviewedOnly: Boolean
|
||||||
get() = requireArguments().getBoolean(ARG_IS_UNVIEWED_ONLY, false)
|
get() = requireArguments().getBoolean(ARG_IS_UNVIEWED_ONLY, false)
|
||||||
|
|
||||||
|
private val isOutgoingOnly: Boolean
|
||||||
|
get() = requireArguments().getBoolean(ARG_IS_OUTGOING_ONLY, false)
|
||||||
|
|
||||||
private val isFromInfoContextMenuAction: Boolean
|
private val isFromInfoContextMenuAction: Boolean
|
||||||
get() = requireArguments().getBoolean(ARG_IS_FROM_INFO_CONTEXT_MENU_ACTION, false)
|
get() = requireArguments().getBoolean(ARG_IS_FROM_INFO_CONTEXT_MENU_ACTION, false)
|
||||||
|
|
||||||
|
@ -985,6 +989,7 @@ class StoryViewerPageFragment :
|
||||||
private const val ARG_IS_FROM_NOTIFICATION = "is_from_notification"
|
private const val ARG_IS_FROM_NOTIFICATION = "is_from_notification"
|
||||||
private const val ARG_GROUP_REPLY_START_POSITION = "group_reply_start_position"
|
private const val ARG_GROUP_REPLY_START_POSITION = "group_reply_start_position"
|
||||||
private const val ARG_IS_UNVIEWED_ONLY = "is_unviewed_only"
|
private const val ARG_IS_UNVIEWED_ONLY = "is_unviewed_only"
|
||||||
|
private const val ARG_IS_OUTGOING_ONLY = "is_outgoing_only"
|
||||||
private const val ARG_IS_FROM_INFO_CONTEXT_MENU_ACTION = "is_from_info_context_menu_action"
|
private const val ARG_IS_FROM_INFO_CONTEXT_MENU_ACTION = "is_from_info_context_menu_action"
|
||||||
|
|
||||||
fun create(
|
fun create(
|
||||||
|
@ -993,6 +998,7 @@ class StoryViewerPageFragment :
|
||||||
isFromNotification: Boolean,
|
isFromNotification: Boolean,
|
||||||
groupReplyStartPosition: Int,
|
groupReplyStartPosition: Int,
|
||||||
isUnviewedOnly: Boolean,
|
isUnviewedOnly: Boolean,
|
||||||
|
isOutgoingOnly: Boolean,
|
||||||
isFromInfoContextMenuAction: Boolean
|
isFromInfoContextMenuAction: Boolean
|
||||||
): Fragment {
|
): Fragment {
|
||||||
return StoryViewerPageFragment().apply {
|
return StoryViewerPageFragment().apply {
|
||||||
|
@ -1002,7 +1008,8 @@ class StoryViewerPageFragment :
|
||||||
ARG_IS_FROM_NOTIFICATION to isFromNotification,
|
ARG_IS_FROM_NOTIFICATION to isFromNotification,
|
||||||
ARG_GROUP_REPLY_START_POSITION to groupReplyStartPosition,
|
ARG_GROUP_REPLY_START_POSITION to groupReplyStartPosition,
|
||||||
ARG_IS_UNVIEWED_ONLY to isUnviewedOnly,
|
ARG_IS_UNVIEWED_ONLY to isUnviewedOnly,
|
||||||
ARG_IS_FROM_INFO_CONTEXT_MENU_ACTION to isFromInfoContextMenuAction
|
ARG_IS_OUTGOING_ONLY to isOutgoingOnly,
|
||||||
|
ARG_IS_FROM_INFO_CONTEXT_MENU_ACTION to isFromInfoContextMenuAction,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ open class StoryViewerPageRepository(context: Context) {
|
||||||
|
|
||||||
fun isReadReceiptsEnabled(): Boolean = TextSecurePreferences.isReadReceiptsEnabled(context)
|
fun isReadReceiptsEnabled(): Boolean = TextSecurePreferences.isReadReceiptsEnabled(context)
|
||||||
|
|
||||||
private fun getStoryRecords(recipientId: RecipientId, isUnviewedOnly: Boolean): Observable<List<MessageRecord>> {
|
private fun getStoryRecords(recipientId: RecipientId, isUnviewedOnly: Boolean, isOutgoingOnly: Boolean): Observable<List<MessageRecord>> {
|
||||||
return Observable.create { emitter ->
|
return Observable.create { emitter ->
|
||||||
val recipient = Recipient.resolved(recipientId)
|
val recipient = Recipient.resolved(recipientId)
|
||||||
|
|
||||||
|
@ -48,16 +48,14 @@ open class StoryViewerPageRepository(context: Context) {
|
||||||
SignalDatabase.mms.getAllOutgoingStories(false, 100)
|
SignalDatabase.mms.getAllOutgoingStories(false, 100)
|
||||||
} else if (isUnviewedOnly) {
|
} else if (isUnviewedOnly) {
|
||||||
SignalDatabase.mms.getUnreadStories(recipientId, 100)
|
SignalDatabase.mms.getUnreadStories(recipientId, 100)
|
||||||
|
} else if (isOutgoingOnly) {
|
||||||
|
SignalDatabase.mms.getOutgoingStoriesTo(recipientId)
|
||||||
} else {
|
} else {
|
||||||
SignalDatabase.mms.getAllStoriesFor(recipientId, 100)
|
SignalDatabase.mms.getAllStoriesFor(recipientId, 100)
|
||||||
}
|
}
|
||||||
|
|
||||||
val results = mutableListOf<MessageRecord>()
|
val results = stories.filterNot {
|
||||||
|
recipient.isMyStory && it.recipient.isGroup
|
||||||
while (stories.next != null) {
|
|
||||||
if (!(recipient.isMyStory && stories.current.recipient.isGroup)) {
|
|
||||||
results.add(stories.current)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
emitter.onNext(results)
|
emitter.onNext(results)
|
||||||
|
@ -150,8 +148,8 @@ open class StoryViewerPageRepository(context: Context) {
|
||||||
return Stories.enqueueAttachmentsFromStoryForDownload(post.conversationMessage.messageRecord as MmsMessageRecord, true)
|
return Stories.enqueueAttachmentsFromStoryForDownload(post.conversationMessage.messageRecord as MmsMessageRecord, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getStoryPostsFor(recipientId: RecipientId, isUnviewedOnly: Boolean): Observable<List<StoryPost>> {
|
fun getStoryPostsFor(recipientId: RecipientId, isUnviewedOnly: Boolean, isOutgoingOnly: Boolean): Observable<List<StoryPost>> {
|
||||||
return getStoryRecords(recipientId, isUnviewedOnly)
|
return getStoryRecords(recipientId, isUnviewedOnly, isOutgoingOnly)
|
||||||
.switchMap { records ->
|
.switchMap { records ->
|
||||||
val posts = records.map { getStoryPostFromRecord(recipientId, it) }
|
val posts = records.map { getStoryPostFromRecord(recipientId, it) }
|
||||||
if (posts.isEmpty()) {
|
if (posts.isEmpty()) {
|
||||||
|
|
|
@ -26,6 +26,7 @@ class StoryViewerPageViewModel(
|
||||||
private val recipientId: RecipientId,
|
private val recipientId: RecipientId,
|
||||||
private val initialStoryId: Long,
|
private val initialStoryId: Long,
|
||||||
private val isUnviewedOnly: Boolean,
|
private val isUnviewedOnly: Boolean,
|
||||||
|
private val isOutgoingOnly: Boolean,
|
||||||
private val repository: StoryViewerPageRepository,
|
private val repository: StoryViewerPageRepository,
|
||||||
val storyCache: StoryCache
|
val storyCache: StoryCache
|
||||||
) : ViewModel() {
|
) : ViewModel() {
|
||||||
|
@ -61,7 +62,7 @@ class StoryViewerPageViewModel(
|
||||||
|
|
||||||
fun refresh() {
|
fun refresh() {
|
||||||
disposables.clear()
|
disposables.clear()
|
||||||
disposables += repository.getStoryPostsFor(recipientId, isUnviewedOnly).subscribe { posts ->
|
disposables += repository.getStoryPostsFor(recipientId, isUnviewedOnly, isOutgoingOnly).subscribe { posts ->
|
||||||
store.update { state ->
|
store.update { state ->
|
||||||
val isDisplayingInitialState = state.posts.isEmpty() && posts.isNotEmpty()
|
val isDisplayingInitialState = state.posts.isEmpty() && posts.isNotEmpty()
|
||||||
val startIndex = if (state.posts.isEmpty() && initialStoryId > 0) {
|
val startIndex = if (state.posts.isEmpty() && initialStoryId > 0) {
|
||||||
|
@ -286,11 +287,12 @@ class StoryViewerPageViewModel(
|
||||||
private val recipientId: RecipientId,
|
private val recipientId: RecipientId,
|
||||||
private val initialStoryId: Long,
|
private val initialStoryId: Long,
|
||||||
private val isUnviewedOnly: Boolean,
|
private val isUnviewedOnly: Boolean,
|
||||||
|
private val isOutgoingOnly: Boolean,
|
||||||
private val repository: StoryViewerPageRepository,
|
private val repository: StoryViewerPageRepository,
|
||||||
private val storyCache: StoryCache
|
private val storyCache: StoryCache
|
||||||
) : ViewModelProvider.Factory {
|
) : ViewModelProvider.Factory {
|
||||||
override fun <T : ViewModel> create(modelClass: Class<T>): T {
|
override fun <T : ViewModel> create(modelClass: Class<T>): T {
|
||||||
return modelClass.cast(StoryViewerPageViewModel(recipientId, initialStoryId, isUnviewedOnly, repository, storyCache)) as T
|
return modelClass.cast(StoryViewerPageViewModel(recipientId, initialStoryId, isUnviewedOnly, isOutgoingOnly, repository, storyCache)) as T
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ class StoryViewerViewModelTest {
|
||||||
testScheduler.triggerActions()
|
testScheduler.triggerActions()
|
||||||
|
|
||||||
// THEN
|
// THEN
|
||||||
verify(repository, never()).getStories(any(), any())
|
verify(repository, never()).getStories(any(), any(), any())
|
||||||
assertEquals(injectedStories, testSubject.stateSnapshot.pages)
|
assertEquals(injectedStories, testSubject.stateSnapshot.pages)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ class StoryViewerViewModelTest {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
val stories: List<RecipientId> = (1L..5L).map(RecipientId::from)
|
val stories: List<RecipientId> = (1L..5L).map(RecipientId::from)
|
||||||
val startStory = RecipientId.from(2L)
|
val startStory = RecipientId.from(2L)
|
||||||
whenever(repository.getStories(any(), any())).doReturn(Single.just(stories))
|
whenever(repository.getStories(any(), any(), any())).doReturn(Single.just(stories))
|
||||||
|
|
||||||
// WHEN
|
// WHEN
|
||||||
val testSubject = StoryViewerViewModel(
|
val testSubject = StoryViewerViewModel(
|
||||||
|
@ -99,7 +99,7 @@ class StoryViewerViewModelTest {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
val stories: List<RecipientId> = (1L..5L).map(RecipientId::from)
|
val stories: List<RecipientId> = (1L..5L).map(RecipientId::from)
|
||||||
val startStory = RecipientId.from(1L)
|
val startStory = RecipientId.from(1L)
|
||||||
whenever(repository.getStories(any(), any())).doReturn(Single.just(stories))
|
whenever(repository.getStories(any(), any(), any())).doReturn(Single.just(stories))
|
||||||
val testSubject = StoryViewerViewModel(
|
val testSubject = StoryViewerViewModel(
|
||||||
StoryViewerArgs(
|
StoryViewerArgs(
|
||||||
recipientId = startStory,
|
recipientId = startStory,
|
||||||
|
@ -125,7 +125,7 @@ class StoryViewerViewModelTest {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
val stories: List<RecipientId> = (1L..5L).map(RecipientId::from)
|
val stories: List<RecipientId> = (1L..5L).map(RecipientId::from)
|
||||||
val startStory = stories.last()
|
val startStory = stories.last()
|
||||||
whenever(repository.getStories(any(), any())).doReturn(Single.just(stories))
|
whenever(repository.getStories(any(), any(), any())).doReturn(Single.just(stories))
|
||||||
val testSubject = StoryViewerViewModel(
|
val testSubject = StoryViewerViewModel(
|
||||||
StoryViewerArgs(
|
StoryViewerArgs(
|
||||||
recipientId = startStory,
|
recipientId = startStory,
|
||||||
|
@ -151,7 +151,7 @@ class StoryViewerViewModelTest {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
val stories: List<RecipientId> = (1L..5L).map(RecipientId::from)
|
val stories: List<RecipientId> = (1L..5L).map(RecipientId::from)
|
||||||
val startStory = stories.last()
|
val startStory = stories.last()
|
||||||
whenever(repository.getStories(any(), any())).doReturn(Single.just(stories))
|
whenever(repository.getStories(any(), any(), any())).doReturn(Single.just(stories))
|
||||||
val testSubject = StoryViewerViewModel(
|
val testSubject = StoryViewerViewModel(
|
||||||
StoryViewerArgs(
|
StoryViewerArgs(
|
||||||
recipientId = startStory,
|
recipientId = startStory,
|
||||||
|
@ -177,7 +177,7 @@ class StoryViewerViewModelTest {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
val stories: List<RecipientId> = (1L..5L).map(RecipientId::from)
|
val stories: List<RecipientId> = (1L..5L).map(RecipientId::from)
|
||||||
val startStory = stories.first()
|
val startStory = stories.first()
|
||||||
whenever(repository.getStories(any(), any())).doReturn(Single.just(stories))
|
whenever(repository.getStories(any(), any(), any())).doReturn(Single.just(stories))
|
||||||
val testSubject = StoryViewerViewModel(
|
val testSubject = StoryViewerViewModel(
|
||||||
StoryViewerArgs(
|
StoryViewerArgs(
|
||||||
recipientId = startStory,
|
recipientId = startStory,
|
||||||
|
@ -203,7 +203,7 @@ class StoryViewerViewModelTest {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
val stories: List<RecipientId> = (1L..5L).map(RecipientId::from)
|
val stories: List<RecipientId> = (1L..5L).map(RecipientId::from)
|
||||||
val startStory = stories.first()
|
val startStory = stories.first()
|
||||||
whenever(repository.getStories(any(), any())).doReturn(Single.just(stories))
|
whenever(repository.getStories(any(), any(), any())).doReturn(Single.just(stories))
|
||||||
val testSubject = StoryViewerViewModel(
|
val testSubject = StoryViewerViewModel(
|
||||||
StoryViewerArgs(
|
StoryViewerArgs(
|
||||||
recipientId = startStory,
|
recipientId = startStory,
|
||||||
|
|
|
@ -42,7 +42,7 @@ class StoryViewerPageViewModelTest {
|
||||||
fun `Given first page and first post, when I goToPreviousPost, then I expect storyIndex to be 0`() {
|
fun `Given first page and first post, when I goToPreviousPost, then I expect storyIndex to be 0`() {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
val storyPosts = createStoryPosts(3) { true }
|
val storyPosts = createStoryPosts(3) { true }
|
||||||
whenever(repository.getStoryPostsFor(any(), any())).thenReturn(Observable.just(storyPosts))
|
whenever(repository.getStoryPostsFor(any(), any(), any())).thenReturn(Observable.just(storyPosts))
|
||||||
val testSubject = createTestSubject()
|
val testSubject = createTestSubject()
|
||||||
testSubject.setIsFirstPage(true)
|
testSubject.setIsFirstPage(true)
|
||||||
testScheduler.triggerActions()
|
testScheduler.triggerActions()
|
||||||
|
@ -61,7 +61,7 @@ class StoryViewerPageViewModelTest {
|
||||||
fun `Given first page and second post, when I goToPreviousPost, then I expect storyIndex to be 0`() {
|
fun `Given first page and second post, when I goToPreviousPost, then I expect storyIndex to be 0`() {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
val storyPosts = createStoryPosts(3) { true }
|
val storyPosts = createStoryPosts(3) { true }
|
||||||
whenever(repository.getStoryPostsFor(any(), any())).thenReturn(Observable.just(storyPosts))
|
whenever(repository.getStoryPostsFor(any(), any(), any())).thenReturn(Observable.just(storyPosts))
|
||||||
val testSubject = createTestSubject()
|
val testSubject = createTestSubject()
|
||||||
testSubject.setIsFirstPage(true)
|
testSubject.setIsFirstPage(true)
|
||||||
testScheduler.triggerActions()
|
testScheduler.triggerActions()
|
||||||
|
@ -82,7 +82,7 @@ class StoryViewerPageViewModelTest {
|
||||||
fun `Given no initial story and 3 records all viewed, when I initialize, then I expect storyIndex to be 0`() {
|
fun `Given no initial story and 3 records all viewed, when I initialize, then I expect storyIndex to be 0`() {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
val storyPosts = createStoryPosts(3) { true }
|
val storyPosts = createStoryPosts(3) { true }
|
||||||
whenever(repository.getStoryPostsFor(any(), any())).thenReturn(Observable.just(storyPosts))
|
whenever(repository.getStoryPostsFor(any(), any(), any())).thenReturn(Observable.just(storyPosts))
|
||||||
|
|
||||||
// WHEN
|
// WHEN
|
||||||
val testSubject = createTestSubject()
|
val testSubject = createTestSubject()
|
||||||
|
@ -98,7 +98,7 @@ class StoryViewerPageViewModelTest {
|
||||||
fun `Given no initial story and 3 records all not viewed, when I initialize, then I expect storyIndex to be 0`() {
|
fun `Given no initial story and 3 records all not viewed, when I initialize, then I expect storyIndex to be 0`() {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
val storyPosts = createStoryPosts(3) { false }
|
val storyPosts = createStoryPosts(3) { false }
|
||||||
whenever(repository.getStoryPostsFor(any(), any())).thenReturn(Observable.just(storyPosts))
|
whenever(repository.getStoryPostsFor(any(), any(), any())).thenReturn(Observable.just(storyPosts))
|
||||||
|
|
||||||
// WHEN
|
// WHEN
|
||||||
val testSubject = createTestSubject()
|
val testSubject = createTestSubject()
|
||||||
|
@ -114,7 +114,7 @@ class StoryViewerPageViewModelTest {
|
||||||
fun `Given no initial story and 3 records with 2nd is not viewed, when I initialize, then I expect storyIndex to be 1`() {
|
fun `Given no initial story and 3 records with 2nd is not viewed, when I initialize, then I expect storyIndex to be 1`() {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
val storyPosts = createStoryPosts(3) { it % 2 != 0 }
|
val storyPosts = createStoryPosts(3) { it % 2 != 0 }
|
||||||
whenever(repository.getStoryPostsFor(any(), any())).thenReturn(Observable.just(storyPosts))
|
whenever(repository.getStoryPostsFor(any(), any(), any())).thenReturn(Observable.just(storyPosts))
|
||||||
|
|
||||||
// WHEN
|
// WHEN
|
||||||
val testSubject = createTestSubject()
|
val testSubject = createTestSubject()
|
||||||
|
@ -130,7 +130,7 @@ class StoryViewerPageViewModelTest {
|
||||||
fun `Given no initial story and 3 records with 1st and 3rd not viewed, when I goToNext, then I expect storyIndex to be 2`() {
|
fun `Given no initial story and 3 records with 1st and 3rd not viewed, when I goToNext, then I expect storyIndex to be 2`() {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
val storyPosts = createStoryPosts(3) { it % 2 == 0 }
|
val storyPosts = createStoryPosts(3) { it % 2 == 0 }
|
||||||
whenever(repository.getStoryPostsFor(any(), any())).thenReturn(Observable.just(storyPosts))
|
whenever(repository.getStoryPostsFor(any(), any(), any())).thenReturn(Observable.just(storyPosts))
|
||||||
|
|
||||||
// WHEN
|
// WHEN
|
||||||
val testSubject = createTestSubject()
|
val testSubject = createTestSubject()
|
||||||
|
@ -148,7 +148,7 @@ class StoryViewerPageViewModelTest {
|
||||||
fun `Given a single story, when I goToPrevious, then I expect storyIndex to be -1`() {
|
fun `Given a single story, when I goToPrevious, then I expect storyIndex to be -1`() {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
val storyPosts = createStoryPosts(1)
|
val storyPosts = createStoryPosts(1)
|
||||||
whenever(repository.getStoryPostsFor(any(), any())).thenReturn(Observable.just(storyPosts))
|
whenever(repository.getStoryPostsFor(any(), any(), any())).thenReturn(Observable.just(storyPosts))
|
||||||
|
|
||||||
// WHEN
|
// WHEN
|
||||||
val testSubject = createTestSubject()
|
val testSubject = createTestSubject()
|
||||||
|
@ -167,6 +167,7 @@ class StoryViewerPageViewModelTest {
|
||||||
RecipientId.from(1),
|
RecipientId.from(1),
|
||||||
-1L,
|
-1L,
|
||||||
false,
|
false,
|
||||||
|
false,
|
||||||
repository,
|
repository,
|
||||||
mock()
|
mock()
|
||||||
)
|
)
|
||||||
|
|
Ładowanie…
Reference in New Issue