Fix insert bug.

This commit is contained in:
BoHung Chiu 2022-05-23 13:08:00 +08:00
parent ffee522538
commit c405ef3c57
1 changed files with 8 additions and 4 deletions

View File

@ -43,8 +43,10 @@ class FeedsController < ApplicationController
end
insert_idx = 0
if time_field_value
insert_idx = feed_annc[:all_contents_for_feed][locale_sym].index{|aa| aa[feeds_time_field] <= time_field_value}
insert_idx = 0 if insert_idx.nil?
insert_idx = feed_annc[:all_contents_for_feed][locale_sym].index{|aa| (aa["org_is_top"] < a["org_is_top"] rescue false) || ((aa["org_is_top"] == a["org_is_top"]) && (aa[feeds_time_field] <= time_field_value))}
if insert_idx.nil?
insert_idx = ((a["org_is_top"] == 1) ? 0 : -1)
end
end
feed_annc.all_contents_for_feed_will_change!
feed_annc[:all_contents_for_feed][locale_sym].insert(insert_idx, feed_annc.process_tmp(a,locale,trans,site_root_url))
@ -93,8 +95,10 @@ class FeedsController < ApplicationController
unless has_create
insert_idx = 0
if time_field_value
insert_idx = feed_annc[:all_contents_for_feed][locale_sym].index{|aa| aa[feeds_time_field] <= time_field_value}
insert_idx = 0 if insert_idx.nil?
insert_idx = feed_annc[:all_contents_for_feed][locale_sym].index{|aa| (aa["org_is_top"] < a["org_is_top"] rescue false) || ((aa["org_is_top"] == a["org_is_top"]) && (aa[feeds_time_field] <= time_field_value))}
if insert_idx.nil?
insert_idx = ((a["org_is_top"] == 1) ? 0 : -1)
end
end
feed_annc.all_contents_for_feed_will_change!
feed_annc[:all_contents_for_feed][locale_sym].insert(insert_idx, feed_annc.process_tmp(a,locale,trans,site_root_url))