Diff
Logged in as anonymous

Differences From Artifact [1f396dc2e6]:

To Artifact [90448b5782]:


70
71
72
73
74
75
76

77
78
79
80
81
82
83
84
85
86
87















88
89
90
91
92
93
94


















95
96
97








98
99
100
101
102
103
104
70
71
72
73
74
75
76
77











78
79
80
81
82
83
84
85
86
87
88
89
90
91
92







93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125







+
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
+
+
+
+
+







			let long = feeds.len() > 6;
			let (start, end) = if long {
				(page * 5, 5 + page * 5)
			} else {
				(0, 6)
			};
			let mut i = 0;
			if name.is_empty() {
			for (id, name) in feeds.iter() {
				if i < start { continue }
				if i > end { break }
				i += 1;
				kb.push(vec![
					InlineKeyboardButton::for_callback_data(
						format!("{}. {}", id, name),
						Callback::list("xxx", *page).to_string()), // XXX edit
				])
			}
			if name.is_empty() {
				for (id, name) in feeds.iter() {
					if i < start { continue }
					if i > end { break }
					i += 1;
					kb.push(vec![
						InlineKeyboardButton::for_callback_data(
							format!("{}. {}", id, name),
							Callback::list("xxx", *page).to_string()), // XXX edit
					]);
				}
			} else {
				let mut found = false;
				let mut first_page = None;
				for (id, feed_name) in feeds.iter() {
					if name == feed_name {
				// no name - reverting to pages, any unknown number means last page
				kb.push(vec![
					InlineKeyboardButton::for_callback_data("1",
						Callback::list("xxx", 0).to_string()),
				])
			} else {
				kb.push(vec![
						found = true;
					}
					i += 1;
					kb.push(vec![
						InlineKeyboardButton::for_callback_data(
							format!("{}. {}", id, feed_name),
							Callback::list("xxx", *page).to_string()), // XXX edit
					]);
					if i > end {
						// page complete, if found we got the right page, if not - reset and
						// continue.
						if found {
							break
						} else {
							if first_page.is_none() {
								first_page = Some(kb);
							}
							kb = vec![];
					InlineKeyboardButton::for_callback_data("1",
						Callback::list("xxx", 0).to_string()),
				])
							i = 0
						}
					}
				}
				if !found {
					// name not found, showing first page
					kb = first_page.unwrap_or_default();
				}
			}
			if long {
				kb.push(vec![
					InlineKeyboardButton::for_callback_data("<<",
						Callback::list("", if *page == 0 { *page } else { page - 1 } ).to_string()),
					InlineKeyboardButton::for_callback_data(">>",
						Callback::list("", page + 1).to_string()),