Fix bug preventing replies from showing up on edited topics

This commit is contained in:
Eric Budd 2018-05-13 01:41:40 -04:00
parent 8c6dcb335e
commit cb0aca4e54
2 changed files with 10 additions and 4 deletions

View File

@ -17,11 +17,12 @@
* ~Mark unread topics/topics with unread replies in topics list~
* ~Add column headers for topics~
* ~Document new features~
* Keep replies on edited topics
* ~Keep replies on edited topics~
# Bugs:
* Is `Time.now.utc.iso8601` working as expected?
* Exclude user's own messages from "unread" count
* Fix message ordering when editing/deleting multiple messages
# Tech debt:
* Flesh out technical sections

11
iris.rb
View File

@ -86,7 +86,7 @@ end
class Corpus
def self.load
@@corpus = Config.find_files.map { |filepath| IrisFile.load_messages(filepath) }.flatten.sort_by(&:timestamp)
@@topics = @@corpus.select{ |m| m.parent == nil }
@@topics = @@corpus.select{ |m| m.parent == nil && m.show_me? }
@@my_corpus = IrisFile.load_messages.sort_by(&:timestamp)
@@my_reads = IrisFile.load_reads
@@all_hash_to_index = @@corpus.reduce({}) { |agg, msg| agg[msg.hash] = @@corpus.index(msg); agg }
@ -149,7 +149,7 @@ class Corpus
return [] unless hash
indexes = @@all_parent_hash_to_index[hash]
return [] unless indexes
indexes.map{ |idx| displayable[idx] }.compact
indexes.map{ |idx| all[idx] }.compact.select(&:show_me?)
end
def self.find_topic_by_id(topic_lookup)
@ -447,8 +447,13 @@ class Message
}.to_json
end
def edit_predecessor
return nil unless edit_hash
Corpus.find_message_by_hash(edit_hash)
end
def replies
Corpus.find_all_by_parent_hash(hash)
(Corpus.find_all_by_parent_hash(hash) + ((edit_predecessor && edit_predecessor.replies) || [])).compact
end
def id